Interface RemoteMcpTools
MCP servers provide tools that agents can use to extend their capabilities. This class allows agents to connect to remote MCP servers and use their tools, including third-party services and other Akka services with MCP endpoints.
Security: When using MCP endpoints in other Akka services, service ACLs apply just like for HTTP and gRPC endpoints. For third-party MCP servers, use HTTPS and appropriate authentication headers.
Tool Filtering: You can control which tools from the MCP server are available to the agent using tool name filters or explicit allow lists.
Not for user extension, create instances using fromServer(String)
or fromService(String)
.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
static interface
Context details about the intercepted MCP tool call. -
Method Summary
Modifier and TypeMethodDescriptionaddClientHeader
(akka.http.javadsl.model.HttpHeader header) static RemoteMcpTools
fromServer
(String serverUri) static RemoteMcpTools
fromService
(String serviceName) withAllowedToolNames
(String allowedToolName, String... moreAllowedToolNames) Define a set of allowed tool names.withAllowedToolNames
(Set<String> allowedToolNames) Define a set of allowed tool names.withToolInterceptor
(RemoteMcpTools.ToolInterceptor interceptor) Specify an interceptor that has the capability to allow or deny calls (by throwing an exception) and also to modify and filter input to the MCP server tool.withToolNameFilter
(Predicate<String> toolNameFilter) Define a filter to select what discovered tool names are passed on to the chat model.
-
Method Details
-
fromServer
- Parameters:
serverUri
- A URI to the remote MCP HTTP server, for example "https://example.com/sse" or "https://example.com/mcp
-
fromService
- Parameters:
serviceName
- A service name of another Akka service with an MCP endpoint in the default path/mcp
-
withToolNameFilter
Define a filter to select what discovered tool names are passed on to the chat model. Names that are filtered will not be described to the model and will not allow calls. Will override a previous call towithAllowedToolNames(Set)
.By default, all tools are allowed.
-
withAllowedToolNames
Define a set of allowed tool names. Will override a previously definedwithToolNameFilter(Predicate)
By default, all tools are allowed.
-
withAllowedToolNames
Define a set of allowed tool names. Will override a previously definedwithToolNameFilter(Predicate)
By default, all tools are allowed.
-
withToolInterceptor
Specify an interceptor that has the capability to allow or deny calls (by throwing an exception) and also to modify and filter input to the MCP server tool. -
addClientHeader
- Parameters:
header
- A header that should be passed with each call to the MCP server, for example some authentication token in anOAuth2BearerToken
-