Class AbstractMcpEndpoint
MCP endpoints expose services to MCP clients such as LLM chat agent desktop applications and agents running on other services. They can provide tools, resources, and prompts that AI models can use to extend their capabilities.
MCP Capabilities:
- Tools: Functions/logic that MCP clients can call on behalf of the LLM
- Resources: Static resources or dynamic resource templates that clients can fetch
- Prompts: Template prompts created from input parameters
Basic Usage:
@Acl(allow = @Acl.Matcher(principal = Acl.Principal.ALL))
@McpEndpoint(
serverName = "my-service-mcp",
serverVersion = "1.0.0")
public class MyMcpEndpoint extends AbstractMcpEndpoint {
@McpTool(description = "Adds two numbers")
public String add(@Description("First number") int a, @Description("Second number") int b) {
return String.valueOf(a + b);
}
}
Request Context: Extending this class provides access to McpRequestContext
via requestContext()
without requiring constructor injection. The
context provides access to request headers, JWT claims, principals, and tracing information.
Alternative Approach: Instead of extending this class, you can inject McpRequestContext
directly into your endpoint constructor or use dependency injection for other
services like ComponentClient
.
MCP endpoints are made available using a stateless streamable HTTP transport as defined by the
MCP specification. By default, endpoints are served at the /mcp
path.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final McpRequestContext
Always available from request handling methods, not available from the constructor.
-
Constructor Details
-
AbstractMcpEndpoint
public AbstractMcpEndpoint()
-
-
Method Details
-
requestContext
Always available from request handling methods, not available from the constructor.
-