add_mcp_server
Register a new MCP server with the discovery service to enable tool discovery and execution routing.
Instructions
Register a new MCP server with the discovery service.
Args:
server_name: Unique name of the server
server_description: Description of the server
server_endpoint: Endpoint URL of the server
tools: List of tools provided by the server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server_name | Yes | ||
| server_description | Yes | ||
| server_endpoint | Yes | ||
| tools | Yes |
Implementation Reference
- mcp_router.py:82-112 (handler)The main handler function for the 'add_mcp_server' tool. It serializes the provided tools to JSON and calls the discovery_service.add_server method to register the new MCP server, returning the result as JSON.@mcp.tool() async def add_mcp_server( server_name: str, server_description: str, server_endpoint: str, tools: List[Dict[str, Any]] ) -> str: """ Register a new MCP server with the discovery service. Args: server_name: Unique name of the server server_description: Description of the server server_endpoint: Endpoint URL of the server tools: List of tools provided by the server """ try: # Serialize tools list to JSON string tools_json = json.dumps(tools, ensure_ascii=False) # Add server to discovery service result = discovery_service.add_server( server_name, server_description, server_endpoint, tools_json ) return json.dumps(result, ensure_ascii=False) except Exception as e: return json.dumps({"error": str(e)}, ensure_ascii=False)
- mcp_router.py:47-51 (schema)Pydantic model defining the input schema for the add_mcp_server tool, matching the function parameters exactly.class AddServerRequest(BaseModel): server_name: str server_description: str server_endpoint: str tools: List[Dict[str, Any]]
- mcp_router.py:82-82 (registration)The @mcp.tool() decorator registers the add_mcp_server function as an MCP tool on the FastMCP server instance.@mcp.tool()