Skip to content

Mcp Server

docforge.servers.mcp_server

Summary

MCP server implementation.

This module defines the MCPServer class, which serves pre-generated documentation bundles through the Model Context Protocol (MCP).


Notes
  • The served bundle is generated offline by MCPRenderer.
  • Missing resources are reported as structured error dictionaries rather than raising exceptions.
  • The server exposes read-only resources and a single health-check tool.

Classes

MCPServer

MCPServer(mcp_root: Path, name: str)

MCP server for serving a pre-generated documentation bundle.

The server exposes documentation resources and diagnostic tools through MCP endpoints backed by JSON files generated by the MCP renderer.

Attributes:

Name Type Description
mcp_root Path

Directory containing the generated MCP documentation bundle.

app FastMCP

Underlying FastMCP application instance that registers resources and tools.

Initialize the MCP server.

Parameters:

Name Type Description Default
mcp_root Path

Directory containing the generated MCP documentation bundle (for example index.json, nav.json, and modules/).

required
name str

Identifier used for the MCP server instance.

required
Functions
run
1
2
3
4
5
run(
    transport: Literal[
        "stdio", "sse", "streamable-http"
    ] = "streamable-http",
) -> None

Start the MCP server.

Parameters:

Name Type Description Default
transport Literal['stdio', 'sse', 'streamable-http']

Transport mechanism used by the MCP server. Supported options include stdio, sse, and streamable-http.

'streamable-http'