Files
mcp-use__mcp-use/docs/python/api-reference/mcp_use_server_server.mdx
pietrozullo ad42b4bb3e docs: noindex auto-generated Python API reference instead of searchable flag
The searchable: false approach on the API Reference tab was inert on
visible tabs. Switch to per-page noindex: true frontmatter, which keeps
pages in the sidebar but excludes them from search indexing (search
engines, internal docs search, and AI context) so generic queries like
"CLI" surface curated guides instead of the generated reference.

Applied to all 73 existing reference pages and emitted by the generator
on every regeneration.

Closes MCP-2398
2026-06-29 10:23:42 +02:00

138 lines
5.8 KiB
Plaintext

---
title: "Server"
description: "Server API Documentation"
icon: "code"
github: "https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/server/server.py"
noindex: true
---
import {RandomGradientBackground} from "/snippets/gradient.jsx"
<Callout type="info" title="Source Code">
View the source code for this module on GitHub: <a href='https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/server/server.py' target='_blank' rel='noopener noreferrer'>https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/server/server.py</a>
</Callout>
## MCPServer
<div>
<RandomGradientBackground className="rounded-lg p-4 w-full h-full rounded-full">
<div className="text-black">
<div className="text-black font-bold text-xl mb-2 mt-8"><code className="!text-black">class</code> MCPServer</div>
Main MCP Server class with integrated inspector and development tools.
</div>
</RandomGradientBackground>
```python
from mcp_use.server.server import MCPServer
```
<Card type="info">
### `method` __init__
Initialize an MCP server.
**Parameters**
><ParamField body="name" type="str | None" default="None" > Server name for identification </ParamField>
><ParamField body="version" type="str | None" default="None" > Server version string </ParamField>
><ParamField body="instructions" type="str | None" default="None" > Instructions for the AI model using this server </ParamField>
><ParamField body="icons" type="list[Icon] | None" default="None" > Optional list of icons for the server implementation </ParamField>
><ParamField body="auth" type="BearerAuthProvider | None" default="None" > Parameter value </ParamField>
><ParamField body="middleware" type="list[Middleware] | None" default="None" > List of middleware to apply to requests </ParamField>
><ParamField body="debug" type="bool" default="False" > Enable debug mode (adds /docs, /inspector, /openmcp.json endpoints) </ParamField>
><ParamField body="mcp_path" type="str" default='/mcp' > Path for MCP endpoint (default: "/mcp") </ParamField>
><ParamField body="docs_path" type="str" default='/docs' > Path for documentation endpoint (default: "/docs") </ParamField>
><ParamField body="inspector_path" type="str" default='/' > Base path prefix for the inspector UI; final route is `<prefix>/inspector`. </ParamField>
><ParamField body="openmcp_path" type="str" default='/openmcp.json' > Path for OpenMCP metadata (default: "/openmcp.json") </ParamField>
><ParamField body="show_inspector_logs" type="bool" default="False" > Show inspector-related logs </ParamField>
><ParamField body="pretty_print_jsonrpc" type="bool" default="False" > Pretty print JSON-RPC messages in logs </ParamField>
><ParamField body="mcp_logs_only" type="bool" default="False" > Only show MCP protocol logs, suppress HTTP access logs (default: False) </ParamField>
><ParamField body="host" type="str" default='0.0.0.0' > Default host for server binding (default: "0.0.0.0"). Can be overridden in run(). </ParamField>
><ParamField body="port" type="int" default="8000" > Default port for server binding (default: 8000). Can be overridden in run(). </ParamField>
><ParamField body="dns_rebinding_protection" type="bool" default="False" > Enable DNS rebinding protection by validating Host/Origin </ParamField>
**Signature**
```python wrap
def __init__(name: str | None = None, version: str | None = None, instructions: str | None = None, icons: list[Icon] | None = None, auth: BearerAuthProvider | None = None, middleware: list[Middleware] | None = None, debug: bool = False, mcp_path: str = "/mcp", docs_path: str = "/docs", inspector_path: str = "/", openmcp_path: str = "/openmcp.json", show_inspector_logs: bool = False, pretty_print_jsonrpc: bool = False, mcp_logs_only: bool = False, host: str = "0.0.0.0", port: int = 8000, dns_rebinding_protection: bool = False):
```
</Card>
<Card type="info">
### `property` debug
Whether debug mode is enabled.
**Returns**
><ResponseField name="returns" type="bool" />
**Signature**
```python wrap
def debug():
```
</Card>
<Card type="info">
### `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:
```python
from mcp_use.server import MCPServer, MCPRouter
# In routes/math.py
router = MCPRouter()
@router.tool()
def add(a: int, b: int) -> int:
return a + b
# In main.py
server = MCPServer(name="my-server")
server.include_router(router, prefix="math") # Tool becomes "math_add"
server.include_router(other_router, enabled=False) # Skip this router
```
**Parameters**
><ParamField body="router" type="MCPRouter" required="True" > The MCPRouter instance to include </ParamField>
><ParamField body="prefix" type="str" default='' > Optional prefix to add to all tool names (e.g., "math" -> "math_add") </ParamField>
><ParamField body="enabled" type="bool" default="True" > Whether to enable this router (default True). Set to False to skip registration. </ParamField>
**Signature**
```python wrap
def include_router(router: MCPRouter, prefix: str = "", enabled: bool = True):
```
</Card>
<Card type="info">
### `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**
><ParamField body="uri" type="str" required="True" > The URI of the resource that was updated. </ParamField>
**Signature**
```python wrap
def notify_resource_updated(uri: str):
```
</Card>
</div>