vac_mcp_server_fastmcp.py
Source: src/sunholo/mcp/vac_mcp_server_fastmcp.py
Classes
VACMCPServer
FastMCP Server that exposes VAC functionality as tools. Now built on top of ExtensibleMCPServer for better customization.
- init(self, server_name: str = 'sunholo-vac-server', include_vac_tools: bool = True, custom_registry: sunholo.mcp.extensible_mcp_server.MCPToolRegistry = None)
- Initialize the VAC MCP Server using FastMCP.
Args: server_name: Name for the MCP server include_vac_tools: Whether to include built-in VAC tools custom_registry: Optional custom tool registry
- add_resource(self, func: Callable, name: str = None, description: str = None)
- Add a custom resource function to the MCP server.
Args:
func: The resource function
name: Optional custom name
description: Optional description
- add_tool(self, func: Callable, name: str = None, description: str = None)
- Add a custom tool function to the MCP server.
Args: func: The tool function name: Optional custom name description: Optional description
- get_http_app(self)
- Get the HTTP app for mounting in FastAPI.
IMPORTANT: This returns an app with path="" configured. The VACRoutesFastAPI class mounts this at "/mcp/mcp" to create the /mcp/mcp endpoint.
DO NOT change this to path="/mcp" as that would create double nesting when mounted. DO NOT mount at root "" as that would intercept all other FastAPI routes.
The correct configuration is:
- This method: path=""
- VACRoutesFastAPI: mount at "/mcp/mcp"
- Result: MCP endpoint at /mcp/mcp without breaking other routes
-
get_registry(self) -> sunholo.mcp.extensible_mcp_server.MCPToolRegistry
- Get the tool registry for advanced customization.
-
get_server(self) -> fastmcp.server.server.FastMCP
- Get the underlying FastMCP server instance.
-
list_resources(self) -> List[str]
- List all registered resources.
-
list_tools(self) -> List[str]
- List all registered tools.
-
run(self, transport: str = 'stdio', **kwargs)
- Run the MCP server.
Args: transport: Transport type ("stdio" or "http") **kwargs: Additional arguments for the transport
- run_async(self, transport: str = 'stdio', **kwargs)
- Run the MCP server asynchronously.
Args: transport: Transport type ("stdio" or "http") **kwargs: Additional arguments for the transport