Skip to main content
Glama

get_model_schema

Retrieve the detailed schema of a specific model from OpenAPI specifications, enabling efficient analysis of data structures and endpoints without loading entire schemas.

Instructions

Get detailed schema for a specific model

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiYesAPI name or direct URL
model_nameYesName of the model

Implementation Reference

  • MCP tool implementation for 'get_model_schema'. The handle_call method validates arguments, fetches the model schema using the explorer service, formats it, and returns the result as TextContent.
    class GetModelSchemaTool(APITool, ToolDefinitionMixin): """Tool for getting detailed model schema.""" def __init__(self, config_manager, explorer): super().__init__( name="get_model_schema", description="Get detailed schema for a specific model", config_manager=config_manager, explorer=explorer, ) def get_tool_definition(self) -> Tool: return Tool( name=self.name, description=self.description, inputSchema=self.create_model_schema_input_schema(), ) async def handle_call(self, arguments: Dict[str, Any]) -> List[TextContent]: try: self._validate_api_identifier(arguments["api"]) schema = await self.explorer.get_model_schema( arguments["api"], arguments["model_name"] ) result = self.explorer.format_model_schema(schema) return self._create_text_response(result) except Exception as e: return self._create_error_response(e)
  • Input JSON schema definition for the get_model_schema tool, specifying required 'api' and 'model_name' parameters.
    def create_model_schema_input_schema() -> Dict[str, Any]: """Create input schema for model schema operations.""" return { "type": "object", "properties": { "api": {"type": "string", "description": "API name or direct URL"}, "model_name": { "type": "string", "description": "Name of the model", }, }, "required": ["api", "model_name"], }
  • Registers an instance of GetModelSchemaTool in the central tool registry during initialization.
    def _register_tools(self) -> None: """Register all available 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}") logger.info(f"Registered {len(self._tools)} tools")
  • Helper method invoked by the tool to fetch the specific model's schema from the OpenAPI document's components.schemas and return it structured.
    async def get_model_schema( self, api_identifier: str, model_name: str ) -> Dict[str, Any]: """Get detailed schema for a specific model.""" url, headers = self.config_manager.get_api_config(api_identifier) schema = await self.cache.get_schema(url, headers) components = schema.get("components", {}) schemas = components.get("schemas", {}) if model_name not in schemas: raise ValueError(f"Model '{model_name}' not found") logger.info(f"Retrieved schema for model {model_name}") return {"name": model_name, "schema": schemas[model_name]}

Other Tools

Related 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