Skip to main content

Overview

Creates an in-process MCP server that runs directly in your application’s process. Unlike external MCP servers that run as separate processes, SDK MCP servers provide better performance, simpler deployment, and easier debugging.

Signature

Parameters

name
str
required
Unique identifier for the server. This name is used to reference the server in the mcp_servers configuration.
version
str
default:"1.0.0"
Server version string. This is for informational purposes and doesn’t affect functionality.
tools
list[SdkMcpTool[Any]] | None
default:"None"
List of SdkMcpTool instances created with the @tool decorator. These are the functions that Claude can call through this server. If None or empty, the server will have no tools.

Returns

McpSdkServerConfig - A configuration object that can be passed to ClaudeAgentOptions.mcp_servers. This config contains the server instance and metadata needed for the SDK to route tool calls.

Benefits of SDK MCP Servers

Better Performance

No IPC overhead - tools run directly in your process

Simpler Deployment

Single process deployment with no external dependencies

Easier Debugging

Debug tools in the same process as your application

Direct State Access

Tools have direct access to your application’s variables and state

Examples

Simple Calculator Server

Basic server with multiple arithmetic tools:

Server with Application State Access

Server tools that access and modify application state:

Multiple Servers

Using multiple SDK MCP servers in one application:

Usage with query()

SDK MCP servers are configured through ClaudeAgentOptions:

Notes

Server Lifecycle: The server lifecycle is managed automatically by the SDK. You don’t need to start or stop servers manually.
Tool Access: Tools defined in SDK MCP servers have direct access to your application’s variables, functions, and state. This enables powerful integrations but requires careful consideration of scope and side effects.
Performance: SDK MCP servers run in-process, eliminating the overhead of subprocess creation and inter-process communication found in external MCP servers.

See Also