list_models
Retrieve available AI models from OpenRouter to select and compare options for your AI tasks.
Instructions
Get list of available OpenRouter models
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_models"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:307-328 (handler)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();