Skip to main content

MCPServer

method init

Initialize an MCP server.Parameters
str | None
default:"None"
Server name for identification
str | None
default:"None"
Server version string
str | None
default:"None"
Instructions for the AI model using this server
list[Icon] | None
default:"None"
Optional list of icons for the server implementation
BearerAuthProvider | None
default:"None"
Parameter value
list[Middleware] | None
default:"None"
List of middleware to apply to requests
bool
default:"False"
Enable debug mode (adds /docs, /inspector, /openmcp.json endpoints)
str
default:"/mcp"
Path for MCP endpoint (default: “/mcp”)
str
default:"/docs"
Path for documentation endpoint (default: “/docs”)
str
default:"/"
Base path prefix for the inspector UI; final route is <prefix>/inspector.
str
default:"/openmcp.json"
Path for OpenMCP metadata (default: “/openmcp.json”)
bool
default:"False"
Show inspector-related logs
bool
default:"False"
Pretty print JSON-RPC messages in logs
bool
default:"False"
Only show MCP protocol logs, suppress HTTP access logs (default: False)
str
default:"0.0.0.0"
Default host for server binding (default: “0.0.0.0”). Can be overridden in run().
int
default:"8000"
Default port for server binding (default: 8000). Can be overridden in run().
bool
default:"False"
Enable DNS rebinding protection by validating Host/Origin
Signature

property debug

Whether debug mode is enabled.Returns
bool
Signature

method include_router

Include a router’s tools, resources, and prompts into this server.Similar to FastAPI’s include_router, this allows you to organize your MCP server into multiple files/modules.Example:
Parameters
MCPRouter
required
The MCPRouter instance to include
str
default:""
Optional prefix to add to all tool names (e.g., “math” -> “math_add”)
bool
default:"True"
Whether to enable this router (default True). Set to False to skip registration.
Signature

method notify_resource_updated

Notify all subscribed sessions that a resource has been updated.Broadcasts a notifications/resources/updated message to every session that called resources/subscribe for this URI.Can be called from within a tool handler or from any async context.Parameters
str
required
The URI of the resource that was updated.
Signature