Skip to main content
Glama
th3nolo

OpenRouter MCP Server

by th3nolo

list_models

Retrieve available AI models from OpenRouter to select and compare options for your AI tasks.

Instructions

Get list of available OpenRouter models

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The listModels() method that implements the tool logic. It fetches available models from the OpenRouter API /models endpoint, formats the response to include id, name, description, context_length, and pricing for each model, and returns the formatted results as MCP content.
    private async listModels() {
      const response = await axios.get(`${OPENROUTER_CONFIG.baseURL}/models`, {
        headers: OPENROUTER_CONFIG.headers,
      });
    
      const models = response.data.data.map((model: any) => ({
        id: model.id,
        name: model.name,
        description: model.description,
        context_length: model.context_length,
        pricing: model.pricing,
      }));
    
      return {
        content: [
          {
            type: "text" as const,
            text: `Found ${models.length} available models:\n\n${JSON.stringify(models, null, 2)}`,
          },
        ],
      };
    }
  • src/server.ts:137-144 (registration)
    Tool registration definition that declares the list_models tool with its name, description, and empty input schema (no parameters required).
    {
      name: "list_models",
      description: "Get list of available OpenRouter models",
      inputSchema: {
        type: "object",
        properties: {},
      },
    },
  • src/server.ts:227-228 (registration)
    Handler routing that maps the 'list_models' tool name to the listModels() method when a tool call is received.
    case "list_models":
      return await this.listModels();

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

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