Skip to main content
Glama

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
NameRequiredDescriptionDefault
server_nameYes
server_descriptionYes
server_endpointYes
toolsYes

Implementation Reference

  • 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)
  • 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()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Maverick-LjXuan/mcp-router'

If you have feedback or need assistance with the MCP directory API, please join our Discord server