> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mcp-use.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Server

> Server API Documentation

export const RandomGradientBackground = ({className, color, children, grayscaled = false}) => {
  const saturation = useMemo(() => {
    if (color) {
      const values = color.split("(")[1].split(")")[0].trim().split(/\s+/);
      return parseFloat(values[1] || "0");
    }
    return grayscaled ? 0 : 0.2;
  }, [color, grayscaled]);
  const lightness = useMemo(() => {
    if (color) {
      const values = color.split("(")[1].split(")")[0].trim().split(/\s+/);
      return parseFloat(values[0] || "0.5");
    }
    return grayscaled ? 0.3 : 0.4;
  }, [color, grayscaled]);
  const randomHue = useMemo(() => {
    if (color) {
      const values = color.split("(")[1].split(")")[0].trim().split(/\s+/);
      return parseFloat(values[2] || "0");
    }
    return Math.floor(Math.random() * 360);
  }, [color]);
  const randomColor = useMemo(() => {
    if (color) {
      return color;
    }
    return `oklch(${Math.min(lightness, 1)} ${saturation} ${randomHue})`;
  }, [randomHue, saturation, lightness]);
  const lightColor = useMemo(() => {
    return `oklch(${Math.min(lightness * 2, 1)} ${saturation} ${randomHue})`;
  }, [randomHue, saturation, lightness, color]);
  const direction = useMemo(() => {
    return Math.floor(Math.random() * 360);
  }, [randomHue]);
  const brightnessFilter = useMemo(() => {
    return "1000%";
  }, []);
  return <div className={`relative overflow-hidden ${className || ""}`} style={{
    background: `${lightColor}`,
    minHeight: '100%',
    width: '100%'
  }}>
      <div className="absolute inset-0 w-full h-full" style={{
    background: `linear-gradient(${direction}deg, ${randomColor}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,
    filter: `contrast(120%) brightness(${brightnessFilter})`,
    backgroundSize: 'cover',
    backgroundRepeat: 'no-repeat'
  }} />
      {children && <div className="relative z-10 w-full h-full">{children}</div>}
    </div>;
};

<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](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 theme={null}
  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 theme={null}
    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 theme={null}
    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 theme={null}
    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 theme={null}
    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 theme={null}
    def notify_resource_updated(uri: str):
    ```
  </Card>
</div>
