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.
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.