Skip to main content
Glama
stabgan

OpenRouter MCP Multimodal Server

by stabgan

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
NameRequiredDescriptionDefault
queryNo
providerNo
capabilitiesNo
limitNo

Implementation Reference

  • 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;
    }
  • 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 },
        },
      },
    },
  • The tool execution dispatcher that calls handleSearchModels.
    case 'search_models':
      return handleSearchModels(
        wrapToolArgs(args as SearchModelsArgs | undefined),
        this.apiClient,
        this.modelCache,
      );

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/stabgan/openrouter-mcp-multimodal'

If you have feedback or need assistance with the MCP directory API, please join our Discord server