add_mcp_server
Register a new MCP server with the discovery service by providing server name, description, endpoint, and tools list. Enables integration into MCP Router for efficient service 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_description | Yes | ||
| server_endpoint | Yes | ||
| server_name | Yes | ||
| tools | Yes |
Implementation Reference
- mcp_router.py:82-112 (handler)The main handler function for the 'add_mcp_server' tool. It serializes the tools list to JSON and calls discovery_service.add_server to register the server, returning the result as JSON. The @mcp.tool() decorator registers it as an MCP tool.@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)