# MCP Guide Doc-forge can export a machine-readable **MCP bundle** from a project's GSDFC docstrings and serve that bundle over the Model Context Protocol (MCP). The bundle is self-contained: readers can derive the full API reference โ€” signatures, docstrings, and structure โ€” for the documented project. --- ## ๐Ÿš€ Building the bundle ```bash doc-forge build --mcp --module docforge ``` This writes structured JSON into `docs/mcp/`: - `index.json` โ€” project metadata and module count - `nav.json` โ€” module list with `docs://modules/{module}` resource URIs - `modules/{dotted.path}.json` โ€” per-module serialized documentation --- ## ๐Ÿš€ Serving the bundle ```bash doc-forge serve --mcp --module docforge ``` The `MCPServer` (in `docforge/servers/mcp_server.py`) exposes: | Resource | Description | |----------------------|-----------------------------------| | `docs://index` | Project metadata | | `docs://nav` | Navigation structure | | `docs://modules/{module}` | Individual module documentation | The server also registers a single diagnostic tool, `ping`, and is read-only. Missing resources are returned as structured error dictionaries rather than exceptions. The default transport is `streamable-http`; `stdio` and `sse` are supported via `MCPServer.run`. --- ## ๐Ÿ“ฆ Bundle contents Each module resource contains: - `path` โ€” dotted module path - `docstring` โ€” the raw GSDFC module docstring - `objects` โ€” a recursive mapping of public symbols with `name`, `kind`, `path`, `signature`, and `docstring`, plus nested `members` Because the bundle is generated from docstrings, the quality of the bundle equals the quality of the project's GSDFC docstrings. For docforge itself, the GSDFC specification is carried in `modules/docforge.json` via the `docforge/__init__.py` package docstring, making the bundle self-documenting. --- ## Related - [03 โ€“ GSDFC Guide](03_gsdfc_guide.md) ยท [05 โ€“ MkDocs Configs](05_mkdocs_configs.md)