Files
doc-forge/docforge/renderers/mcp_renderer.pyi
Vishesh 'ironeagle' Bangotra 5370a7faa2 feat(mcp): add MCP JSON renderer and CLI support, update tests accordingly
- Add MCPRenderer to generate MCP-native JSON bundles (index.json, nav.json, modules/*.json)
- Expose MCPRenderer via public API and CLI (`generate-mcp` command)
- Replace Markdown-based MCP output with structured JSON resources
- Update MCP renderer type stubs to match new JSON-based implementation
- Refactor MCP tests to validate JSON content, bundle structure, and navigation
- Fix MCP module coverage test to use explicit project_root for reliable discovery
2026-01-21 16:43:21 +05:30

27 lines
875 B
Python

from pathlib import Path
from typing import Dict, List
from docforge.models import Project, Module, DocObject
class MCPRenderer:
"""Renderer that emits MCP-native JSON resources from docforge models."""
name: str
def generate_sources(self, project: Project, out_dir: Path) -> None:
"""Generate MCP-compatible JSON resources and navigation for the project."""
def _write_module(self, module: Module, modules_dir: Path) -> None:
"""Serialize a module into an MCP JSON resource."""
def _render_module(self, module: Module) -> Dict:
"""Render a Module into MCP-friendly structured data."""
def _render_object(self, obj: DocObject) -> Dict:
"""Recursively render a DocObject into structured MCP data."""
@staticmethod
def _json(data: Dict) -> str:
"""Serialize structured data to formatted JSON."""