Skip to main content
Glama

list_models

Retrieve and filter data models from an API specification to understand available structures and properties for integration planning.

Instructions

List all data models in an API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiYesAPI name or direct URL
pageNoPage number (1-based)
page_sizeNoItems per page (max 100)
typesNoFilter by model types (e.g., ['object', 'array', 'string'])
min_propertiesNoMinimum number of properties
max_propertiesNoMaximum number of properties
has_required_fieldsNoFilter by presence of required fields
tags_includeNoInclude models with these tags
tags_excludeNoExclude models with these tags
include_detailsNoInclude detailed information about models

Implementation Reference

  • ListModelsTool class implementing the 'list_models' MCP tool, including the handle_call handler, tool definition (schema), and formatting logic.
    class ListModelsTool(APITool, ToolDefinitionMixin):
        """Tool for listing API data models."""
    
        def __init__(self, config_manager, explorer):
            super().__init__(
                name="list_models",
                description="List all data models in an API",
                config_manager=config_manager,
                explorer=explorer,
            )
    
        def get_tool_definition(self) -> Tool:
            return Tool(
                name=self.name,
                description=self.description,
                inputSchema=self.create_paginated_model_input_schema(),
            )
    
        async def handle_call(self, arguments: Dict[str, Any]) -> List[TextContent]:
            try:
                self._validate_api_identifier(arguments["api"])
    
                pagination = self.extract_pagination_params(arguments)
                filters = self.extract_model_filter_params(arguments)
                include_details = arguments.get("include_details", False)
    
                paginated_result = await self.explorer.list_models_paginated(
                    arguments["api"], pagination, filters
                )
    
                result = self._format_paginated_model_response(
                    paginated_result, filters, include_details
                )
                return self._create_text_response(result)
            except Exception as e:
                return self._create_error_response(e)
    
        def _format_paginated_model_response(
            self, paginated_result, filters, include_details
        ) -> str:
            """Format paginated model response."""
            result = ""
    
            filter_display = filters.format_display()
            if filter_display:
                result += filter_display + "\n\n"
    
            if filters and any(
                [
                    filters.types,
                    filters.min_properties is not None,
                    filters.max_properties is not None,
                    filters.has_required_fields is not None,
                    filters.tags_include,
                    filters.tags_exclude,
                ]
            ):
                result += (
                    f"Total Results: {paginated_result.total_count} models (filtered)\n\n"
                )
            else:
                result += f"Total Results: {paginated_result.total_count} models\n\n"
    
            if paginated_result.items:
                for model in paginated_result.items:
                    result += model.format_display(detailed=include_details) + "\n"
            else:
                result += "No models found\n"
    
            result += "\n" + paginated_result.format_navigation()
    
            return result
  • ToolRegistry._register_tools method where ListModelsTool is instantiated and added to the tools dictionary for MCP server registration.
    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")
  • OpenAPIExplorer.list_models_paginated helper method that performs the core logic of listing and paginating models, invoked by the tool handler.
    async def list_models_paginated(
        self,
        api_identifier: str,
        pagination: PaginationParams,
        filters: Optional[ModelFilterParams] = None,
    ) -> PaginationResult[ModelInfo]:
        """List models with pagination and filtering."""
        all_models = await self.list_models(api_identifier)
    
        if filters:
            filtered_models = [
                model for model in all_models if model.matches_filters(filters)
            ]
        else:
            filtered_models = all_models
    
        total_count = len(filtered_models)
        start_idx = pagination.get_offset()
        end_idx = start_idx + pagination.get_limit()
        paginated_models = filtered_models[start_idx:end_idx]
    
        logger.info(
            f"Paginated models for API {api_identifier}: "
            f"page {pagination.page}, showing {len(paginated_models)} of {total_count}"
        )
    
        return PaginationResult.create(paginated_models, total_count, pagination)
  • OpenAPIExplorer.list_models helper method that extracts all models from the OpenAPI schema.
    async def list_models(self, api_identifier: str) -> List[ModelInfo]:
        """List all data models in an API."""
        url, headers = self.config_manager.get_api_config(api_identifier)
        schema = await self.cache.get_schema(url, headers)
    
        models = []
        components = schema.get("components", {})
        schemas = components.get("schemas", {})
    
        for name, model_schema in schemas.items():
            tags = []
            if "x-tags" in model_schema:
                tags = model_schema["x-tags"]
            elif "tags" in model_schema:
                tags = model_schema["tags"]
    
            model = ModelInfo(
                name=name,
                type=model_schema.get("type", "object"),
                properties=model_schema.get("properties", {}),
                required=model_schema.get("required", []),
                description=model_schema.get("description"),
                tags=tags,
            )
            models.append(model)
    
        logger.info(f"Found {len(models)} models for API {api_identifier}")
        return models
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('List all data models') but doesn't disclose critical behavioral traits such as whether this is a read-only operation, potential rate limits, authentication needs, pagination behavior (implied by parameters but not described), or what the output looks like. For a tool with 10 parameters and no annotations, this is a significant gap.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with zero waste. Every word earns its place by conveying the core action and resource.

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?

Given the complexity (10 parameters, no output schema, no annotations), the description is incomplete. It doesn't address behavioral aspects like pagination, filtering logic, or output format, which are crucial for a listing tool with many options. The schema covers parameters well, but the description fails to provide context on how to use the tool effectively or what to expect in return.

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 input schema has 100% description coverage, with each parameter well-documented (e.g., 'API name or direct URL', 'Page number (1-based)'). The description doesn't add any meaning beyond what the schema provides—it doesn't explain parameter interactions, default behaviors, or usage examples. With high schema coverage, the baseline is 3, as the schema does the heavy lifting.

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 ('List') and resource ('all data models in an API'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'get_model_schema' or 'list_endpoints', which might list related resources. The purpose is clear but lacks sibling distinction.

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. It doesn't mention sibling tools like 'get_model_schema' (for specific model details) or 'list_endpoints' (for listing endpoints instead of models), nor does it specify prerequisites or exclusions. Usage is implied by the name but not explicitly stated.

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