search_models
Find AI models by query, provider, or capabilities like vision support to select the right model for your task.
Instructions
Search available OpenRouter models
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | ||
| provider | No | ||
| capabilities | No | ||
| limit | No |
Implementation Reference
- src/tool-handlers/search-models.ts:11-26 (handler)The handler function that executes the search_models tool logic by checking the cache and querying the OpenRouter API.
export async function handleSearchModels( request: { params: { arguments: SearchModelsArgs } }, apiClient: OpenRouterAPIClient, modelCache: ModelCache, ) { try { if (!modelCache.isValid()) { modelCache.setModels(await apiClient.getModels()); } const results = modelCache.search(request.params.arguments); return { content: [{ type: 'text', text: JSON.stringify(results, null, 2) }] }; } catch (error: unknown) { const msg = error instanceof Error ? error.message : String(error); return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true }; } } - The input argument interface for the search_models tool.
export interface SearchModelsArgs { query?: string; provider?: string; capabilities?: { vision?: boolean }; limit?: number; } - src/tool-handlers.ts:87-98 (registration)The MCP tool registration schema for search_models.
name: 'search_models', description: 'Search available OpenRouter models', inputSchema: { type: 'object', properties: { query: { type: 'string' }, provider: { type: 'string' }, capabilities: { type: 'object', properties: { vision: { type: 'boolean' } } }, limit: { type: 'number', minimum: 1, maximum: 50 }, }, }, }, - src/tool-handlers.ts:148-153 (handler)The tool execution dispatcher that calls handleSearchModels.
case 'search_models': return handleSearchModels( wrapToolArgs(args as SearchModelsArgs | undefined), this.apiClient, this.modelCache, );