Skip to main content
Glama

add_api

Add a new API configuration by specifying its name, base URL, and optional details like description and authentication headers to integrate with the OpenAPI proxy server.

Instructions

Add a new API configuration with name, URL and optional description

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesShort name for the API
urlYesBase URL of the FastAPI service
descriptionNoOptional description
headersNoOptional HTTP headers for authentication (e.g., {'Authorization': 'Bearer token', 'X-API-Key': 'key'})

Implementation Reference

  • The handle_call method implements the core logic of the 'add_api' tool, extracting arguments and delegating to ConfigManager.add_api.
    async def handle_call(self, arguments: Dict[str, Any]) -> List[TextContent]: try: result = await self.config_manager.add_api( arguments["name"], arguments["url"], arguments.get("description"), arguments.get("headers"), ) return self._create_text_response(result) except Exception as e: return self._create_error_response(e)
  • Static method defining the JSON schema for 'add_api' tool inputs, used by AddApiTool.get_tool_definition().
    @staticmethod def create_add_api_input_schema() -> Dict[str, Any]: """Create input schema for adding API.""" return { "type": "object", "properties": { "name": {"type": "string", "description": "Short name for the API"}, "url": { "type": "string", "description": "Base URL of the FastAPI service", }, "description": { "type": "string", "description": "Optional description", }, "headers": { "type": "object", "description": "Optional HTTP headers for authentication (e.g., {'Authorization': 'Bearer token', 'X-API-Key': 'key'})", "additionalProperties": {"type": "string"}, }, }, "required": ["name", "url"], }
  • Registers AddApiTool instance in the ToolRegistry during _register_tools().
    tools = [ # API Management Tools AddApiTool(self.config_manager), ListSavedApisTool(self.config_manager), RemoveApiTool(self.config_manager), # API Exploration Tools GetApiInfoTool(self.config_manager, self.explorer), ListEndpointsTool(self.config_manager, self.explorer), SearchEndpointsTool(self.config_manager, self.explorer), GetEndpointDetailsTool(self.config_manager, self.explorer), ListModelsTool(self.config_manager, self.explorer), GetModelSchemaTool(self.config_manager, self.explorer), ] for tool in tools: self._tools[tool.name] = tool logger.debug(f"Registered tool: {tool.name}")
  • ConfigManager method called by the tool handler to persist the new API configuration.
    async def add_api( self, name: str, url: str, description: Optional[str] = None, headers: Optional[Dict[str, str]] = None, ) -> str: """Add a new API configuration.""" try: api_config = ApiConfig( name=name, url=url, description=description, headers=headers or {} ) self._storage.add_api(api_config) await self.save_config() logger.info(f"Added API configuration: {name}") return f"Added API '{name}' with URL {url}" except ValidationError as e: raise ValueError(f"Invalid URL or configuration: {e}")

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/nyudenkov/openapi-mcp-proxy'

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