Interface McpServer
- All Known Implementing Classes:
McpServerBase,McpSseServer,McpStdioServer,McpStreamableServer
This interface defines the contract for MCP servers, including capability definition, server specification creation, server instantiation, and component registration. Implementations of this interface should provide the specific behavior for different server modes (STDIO, SSE, STREAMABLE).
Typical usage involves implementing this interface for a specific server mode and providing the necessary configuration and component registration logic.
- Author:
- codeboyzhou
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionio.modelcontextprotocol.server.McpSyncServerCreates and returns a fully configured MCP synchronous server instance.io.modelcontextprotocol.server.McpServer.SyncSpecification<?>Creates and returns the synchronization specification for this MCP server.io.modelcontextprotocol.spec.McpSchema.ServerCapabilitiesDefines and returns the server capabilities that this MCP server supports.voidregisterComponents(io.modelcontextprotocol.server.McpSyncServer mcpSyncServer) Registers all MCP server components (resources, prompts, tools) with the specified synchronous server instance.
-
Method Details
-
defineCapabilities
io.modelcontextprotocol.spec.McpSchema.ServerCapabilities defineCapabilities()Defines and returns the server capabilities that this MCP server supports.Capabilities include support for resources, prompts, tools, and completions, as well as change notification settings for each component type.
- Returns:
- the server capabilities configuration
- See Also:
-
McpSchema.ServerCapabilities
-
createSyncSpecification
io.modelcontextprotocol.server.McpServer.SyncSpecification<?> createSyncSpecification()Creates and returns the synchronization specification for this MCP server.The sync specification contains the transport provider and other configuration details needed to create a synchronized MCP server instance.
- Returns:
- the synchronization specification for the server
- See Also:
-
McpServer.SyncSpecification
-
createSyncServer
io.modelcontextprotocol.server.McpSyncServer createSyncServer()Creates and returns a fully configured MCP synchronous server instance.This method should create a server instance with all necessary configurations applied, including server info, capabilities, and transport settings.
- Returns:
- a fully configured MCP synchronous server
- See Also:
-
McpSyncServer
-
registerComponents
void registerComponents(io.modelcontextprotocol.server.McpSyncServer mcpSyncServer) Registers all MCP server components (resources, prompts, tools) with the specified synchronous server instance.This method should scan for annotated methods and register them as appropriate MCP components with the server. Components are discovered using reflection and registered through the component registry.
- Parameters:
mcpSyncServer- the synchronous server instance to register components with
-