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}")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It implies a write operation ('Add a new API configuration') but doesn't specify whether this requires authentication, what happens on duplicate names, if the configuration is persisted, or any error conditions. This leaves significant behavioral gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point without any unnecessary words. It's appropriately sized for the tool's complexity and front-loads the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after adding (e.g., success confirmation, error handling, or how to verify with 'list_saved_apis'), nor does it address authentication requirements or potential side effects, leaving the agent with incomplete operational context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so all parameters are documented in the input schema. The description mentions 'name, URL and optional description' which aligns with three of the four parameters but omits 'headers'. Since the schema already provides full documentation, the description adds minimal value beyond confirming some parameter purposes.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Add a new API configuration') and the resources involved ('with name, URL and optional description'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its sibling 'remove_api' or explain how it relates to 'list_saved_apis' for context about existing configurations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'remove_api' or 'list_saved_apis', nor does it mention prerequisites such as checking for existing APIs before adding. It simply states what the tool does without contextual usage information.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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