doc changes
This commit is contained in:
@@ -13,6 +13,13 @@ class MCPServer:
|
||||
"""
|
||||
|
||||
def __init__(self, mcp_root: Path, name: str) -> None:
|
||||
"""
|
||||
Initialize the MCPServer.
|
||||
|
||||
Args:
|
||||
mcp_root: Path to the directory containing pre-built MCP JSON resources.
|
||||
name: Name of the MCP server.
|
||||
"""
|
||||
self.mcp_root = mcp_root
|
||||
self.app = FastMCP(name)
|
||||
|
||||
@@ -24,6 +31,15 @@ class MCPServer:
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def _read_json(self, path: Path) -> Any:
|
||||
"""
|
||||
Read and parse a JSON file, returning diagnostic errors if missing.
|
||||
|
||||
Args:
|
||||
path: Path to the JSON file.
|
||||
|
||||
Returns:
|
||||
The parsed JSON data or an error dictionary.
|
||||
"""
|
||||
if not path.exists():
|
||||
return {
|
||||
"error": "not_found",
|
||||
@@ -36,6 +52,9 @@ class MCPServer:
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def _register_resources(self) -> None:
|
||||
"""
|
||||
Register MCP resources for index, nav, and individual modules.
|
||||
"""
|
||||
@self.app.resource("docs://index")
|
||||
def index():
|
||||
return self._read_json(self.mcp_root / "index.json")
|
||||
@@ -55,6 +74,9 @@ class MCPServer:
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def _register_tools(self) -> None:
|
||||
"""
|
||||
Register high-level MCP tools for diagnostics.
|
||||
"""
|
||||
@self.app.tool()
|
||||
def ping() -> str:
|
||||
return "pong"
|
||||
|
||||
Reference in New Issue
Block a user