From cb68b0b93ff8bae3c3c6885ee29315d3b69ee226 Mon Sep 17 00:00:00 2001 From: Vishesh 'ironeagle' Bangotra Date: Thu, 22 Jan 2026 17:43:34 +0530 Subject: [PATCH] passing module for mcp server name --- docforge/cli/commands.py | 7 ++++++- docforge/cli/commands.pyi | 1 + docforge/cli/mcp_utils.py | 5 +++-- docforge/cli/mcp_utils.pyi | 2 +- tests/cli/test_serve_mcp.py | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docforge/cli/commands.py b/docforge/cli/commands.py index 9937cfd..3dd65d2 100644 --- a/docforge/cli/commands.py +++ b/docforge/cli/commands.py @@ -92,11 +92,13 @@ def build( @cli.command() @click.option("--mcp", is_flag=True, help="Serve MCP documentation") @click.option("--mkdocs", is_flag=True, help="Serve MkDocs site") +@click.option("--module", help="Python module to serve") @click.option("--mkdocs-yml", type=click.Path(path_type=Path), default=Path("mkdocs.yml"), help="MkDocs config path") @click.option("--out-dir", type=click.Path(path_type=Path), default=Path("mcp_docs"), help="MCP root directory") def serve( mcp: bool, mkdocs: bool, + module: Optional[str], mkdocs_yml: Path, out_dir: Path, ) -> None: @@ -106,6 +108,7 @@ def serve( Args: mcp: Serve MCP resources via an MCP server. mkdocs: Serve the MkDocs site using the built-in development server. + module: The dotted path of the module to serve. mkdocs_yml: (MkDocs) Path to the mkdocs.yml configuration. out_dir: (MCP) Path to the mcp_docs/ directory. """ @@ -113,11 +116,13 @@ def serve( raise click.UsageError("Cannot specify both --mcp and --mkdocs") if not mcp and not mkdocs: raise click.UsageError("Must specify either --mcp or --mkdocs") + if mcp and not module: + raise click.UsageError("--module is required for MCP serve") if mkdocs: mkdocs_utils.serve(mkdocs_yml) elif mcp: - mcp_utils.serve(out_dir) + mcp_utils.serve(module, out_dir) @cli.command() diff --git a/docforge/cli/commands.pyi b/docforge/cli/commands.pyi index 16b1c62..f32426b 100644 --- a/docforge/cli/commands.pyi +++ b/docforge/cli/commands.pyi @@ -20,6 +20,7 @@ def build( def serve( mcp: bool, mkdocs: bool, + module: Optional[str], mkdocs_yml: Path, out_dir: Path, ) -> None: ... diff --git a/docforge/cli/mcp_utils.py b/docforge/cli/mcp_utils.py index 1838adc..add7dcb 100644 --- a/docforge/cli/mcp_utils.py +++ b/docforge/cli/mcp_utils.py @@ -20,11 +20,12 @@ def generate_resources(module: str, project_name: str | None, out_dir: Path) -> renderer = MCPRenderer() renderer.generate_sources(project, out_dir) -def serve(mcp_root: Path) -> None: +def serve(module: str, mcp_root: Path) -> None: """ Serve MCP documentation from a pre-built bundle. Args: + module: The dotted path of the primary module to serve. mcp_root: Path to the directory containing index.json, nav.json, and modules/. """ if not mcp_root.exists(): @@ -42,6 +43,6 @@ def serve(mcp_root: Path) -> None: server = MCPServer( mcp_root=mcp_root, - name="doc-forge-mcp", + name=f"{module}-mcp", ) server.run() diff --git a/docforge/cli/mcp_utils.pyi b/docforge/cli/mcp_utils.pyi index 47b9eab..5e9ac4d 100644 --- a/docforge/cli/mcp_utils.pyi +++ b/docforge/cli/mcp_utils.pyi @@ -1,4 +1,4 @@ from pathlib import Path def generate_resources(module: str, project_name: str | None, out_dir: Path) -> None: ... -def serve(mcp_root: Path) -> None: ... +def serve(module: str, mcp_root: Path) -> None: ... diff --git a/tests/cli/test_serve_mcp.py b/tests/cli/test_serve_mcp.py index 27e6f6f..4e0db66 100644 --- a/tests/cli/test_serve_mcp.py +++ b/tests/cli/test_serve_mcp.py @@ -10,7 +10,7 @@ def test_mcp_serve( result = cli_runner.invoke( cli, - ["serve", "--mcp", "--out-dir", str(fake_mcp_docs)], + ["serve", "--mcp", "--module", "fake_module", "--out-dir", str(fake_mcp_docs)], ) assert result.exit_code == 0