list_endpoints
Retrieve and filter API endpoints by methods, tags, deprecation, or authentication status using OpenAPI specs. Ideal for exploring and analyzing large API schemas efficiently.
Instructions
List all endpoints in an API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api | Yes | API name or direct URL | |
| deprecated | No | Filter by deprecation status | |
| has_authentication | No | Filter by authentication requirement | |
| methods | No | Filter by HTTP methods (e.g., ['GET', 'POST']) | |
| page | No | Page number (1-based) | |
| page_size | No | Items per page (max 100) | |
| tags_exclude | No | Exclude endpoints with these tags | |
| tags_include | No | Include endpoints with these tags |
Implementation Reference
- The handle_call method is the main handler that executes the list_endpoints tool logic. It validates the API identifier, extracts pagination and filter parameters, calls the explorer's paginated list method, formats the response, and returns it as TextContent.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_endpoint_filter_params(arguments) paginated_result = await self.explorer.list_endpoints_paginated( arguments["api"], pagination, filters ) result = self._format_paginated_endpoint_response(paginated_result, filters) return self._create_text_response(result) except Exception as e: return self._create_error_response(e)
- Defines the input schema for the list_endpoints tool, including API identifier, pagination (page, page_size), and endpoint filters (methods, tags_include/exclude, has_authentication, deprecated). Composes from base schemas.def create_paginated_endpoint_input_schema() -> Dict[str, Any]: """Create input schema for paginated endpoint operations.""" schema = ToolDefinitionMixin.create_api_input_schema() schema["properties"].update(ToolDefinitionMixin.create_pagination_properties()) schema["properties"].update( ToolDefinitionMixin.create_endpoint_filter_properties() ) return schema
- openapi_mcp_proxy/services/tool_registry.py:44-50 (registration)Registers the ListEndpointsTool instance in the tool registry's _register_tools method, adding it to the list of available tools.# 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),
- Core helper method that parses the OpenAPI schema to extract and return a list of all EndpointInfo objects for the given API.async def list_endpoints(self, api_identifier: str) -> List[EndpointInfo]: """List all endpoints in an API.""" url, headers = self.config_manager.get_api_config(api_identifier) schema = await self.cache.get_schema(url, headers) endpoints = [] paths = schema.get("paths", {}) for path, path_info in paths.items(): for method, operation in path_info.items(): if self._is_valid_http_method(method): deprecated = operation.get("deprecated", False) has_auth = bool(operation.get("security", [])) or bool( schema.get("security", []) ) endpoint = EndpointInfo( path=path, method=method.upper(), summary=operation.get("summary"), description=operation.get("description"), tags=operation.get("tags", []), operation_id=operation.get("operationId"), deprecated=deprecated, has_authentication=has_auth, ) endpoints.append(endpoint) logger.info(f"Found {len(endpoints)} endpoints for API {api_identifier}") return endpoints
- Supporting paginated and filtered version of list_endpoints, called by the tool handler. Applies filters, paginates the results, and returns PaginationResult.async def list_endpoints_paginated( self, api_identifier: str, pagination: PaginationParams, filters: Optional[EndpointFilterParams] = None, ) -> PaginationResult[EndpointInfo]: """List endpoints with pagination and filtering.""" all_endpoints = await self.list_endpoints(api_identifier) if filters: filtered_endpoints = [ ep for ep in all_endpoints if ep.matches_filters(filters) ] else: filtered_endpoints = all_endpoints total_count = len(filtered_endpoints) start_idx = pagination.get_offset() end_idx = start_idx + pagination.get_limit() paginated_endpoints = filtered_endpoints[start_idx:end_idx] logger.info( f"Paginated endpoints for API {api_identifier}: " f"page {pagination.page}, showing {len(paginated_endpoints)} of {total_count}" ) return PaginationResult.create(paginated_endpoints, total_count, pagination)