26 lines
897 B
Python
26 lines
897 B
Python
from pathlib import Path
|
|
from typing import Any
|
|
|
|
from docforge.models import DocObject, Module, Project
|
|
|
|
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[str, Any]:
|
|
"""Render a Module into MCP-friendly structured data."""
|
|
|
|
def _render_object(self, obj: DocObject) -> dict[str, Any]:
|
|
"""Recursively render a DocObject into structured MCP data."""
|
|
|
|
@staticmethod
|
|
def _json(data: dict[str, Any]) -> str:
|
|
"""Serialize structured data to formatted JSON."""
|