get_api_info
Retrieve essential details about an API, such as endpoints and data models, by providing the API name or URL. Streamlines API exploration without loading full schemas, enabling efficient analysis and discovery of its structure.
Instructions
Get general information about an API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api | Yes | API name or direct URL |
Implementation Reference
- MCP tool handler: validates API identifier, fetches API info via explorer, formats for display, handles errors.async def handle_call(self, arguments: Dict[str, Any]) -> List[TextContent]: try: self._validate_api_identifier(arguments["api"]) info = await self.explorer.get_api_info(arguments["api"]) result = info.format_display() return self._create_text_response(result) except Exception as e: return self._create_error_response(e)
- Input JSON schema requiring 'api' identifier string.def create_api_input_schema() -> Dict[str, Any]: """Create input schema for API identifier parameter.""" return { "type": "object", "properties": { "api": {"type": "string", "description": "API name or direct URL"} }, "required": ["api"], }
- Pydantic model defining output ApiInfo structure with display formatting.class ApiInfo(BaseModel): """General information about an API.""" title: str version: str description: str = "" base_url: str tags: List[str] = [] def format_display(self) -> str: """Format API info for display.""" result = f"API: {self.title} (v{self.version})\n" result += f"Description: {self.description}\n" result += f"Base URL: {self.base_url}\n" if self.tags: result += f"Tags: {', '.join(self.tags)}\n" return result
- openapi_mcp_proxy/services/tool_registry.py:45-45 (registration)Tool instantiation and addition to registry during _register_tools().GetApiInfoTool(self.config_manager, self.explorer),
- Service method that loads OpenAPI schema and extracts info into ApiInfo model.async def get_api_info(self, api_identifier: str) -> ApiInfo: """Get general information about an API.""" url, headers = self.config_manager.get_api_config(api_identifier) schema = await self.cache.get_schema(url, headers) info = schema.get("info", {}) base_url = self._get_base_url_from_schema(schema) return ApiInfo( title=info.get("title", "Unknown"), version=info.get("version", "Unknown"), description=info.get("description", ""), base_url=base_url, tags=[tag.get("name") for tag in schema.get("tags", [])], )