Learn how to implement and configure a Model Context Protocol (MCP) server
io.modelcontextprotocol.sdk:mcp
module provides STDIO and SSE server transport implementations without requiring external web frameworks.Spring-specific transport implementations are available as an optional dependencies io.modelcontextprotocol.sdk:mcp-spring-webflux
, io.modelcontextprotocol.sdk:mcp-spring-webmvc
for Spring Framework users.mcpClient.setLoggingLevel(level)
request. Messages below the set level will be filtered out.
Supported logging levels (in order of increasing severity): DEBUG (0), INFO (1), NOTICE (2), WARNING (3), ERROR (4), CRITICAL (5), ALERT (6), EMERGENCY (7)
name
, description
, and parameter schema
followed by a call handler that implements the tool’s logic.
The function’s first argument is McpAsyncServerExchange
for client interaction, and the second is a map of tool arguments.
name
, description
, and MIME type
.
The first argument of the function that handles resource read requests is an McpAsyncServerExchange
upon which the server can
interact with the connected client.
The second arguments is a McpSchema.ReadResourceRequest
.
McpAsyncServerExchange
for client interaction, and the second argument is a GetPromptRequest
instance.
McpSchema.CompletionReference
definition defines the type (PromptRefernce
or ResourceRefernce
) and the identifier for the completion specification (e.g handler).
The handler function processes requests and returns the completion response.
The first argument is McpAsyncServerExchange
for client interaction, and the second argument is a CompleteRequest
instance.
Check the using completion to learn how to use the completion capabilities on the client side.
CreateMessageRequest
object allows you to specify: Content
- the input text or image for the model,
Model Preferences
- hints and priorities for model selection, System Prompt
- instructions for the model’s behavior and
Max Tokens
- maximum length of the generated response.
McpAsyncServerExchange
/McpSyncServerExchange
object in the tool/resource/prompt handler function:
mcpClient.setLoggingLevel(level)
request. Messages below the set level will be filtered out.
Supported logging levels (in order of increasing severity): DEBUG (0), INFO (1), NOTICE (2), WARNING (3), ERROR (4), CRITICAL (5), ALERT (6), EMERGENCY (7)