list_all_models
Retrieve and display all available AI models from configured providers like OpenAI, Anthropic, and Google through a unified interface for easy access and comparison.
Instructions
List all available models from all configured providers
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/index.ts:70-77 (registration)Registration of the 'list_all_models' tool in the ListTools response, defining its name, description, and input schema (no parameters required).{ name: 'list_all_models', description: 'List all available models from all configured providers', inputSchema: { type: 'object', properties: {}, }, },
- src/index.ts:189-224 (handler)The handler logic for 'list_all_models' tool. Aggregates model lists from all configured providers (OpenAI, Anthropic, Google) by calling their respective listModels methods, handles individual provider errors, and returns the combined results as a JSON string in the tool response format.case 'list_all_models': { const results: any = {}; if (openaiProvider) { try { results.openai = await openaiProvider.listModels(); } catch (error) { results.openai = { error: error instanceof Error ? error.message : 'Failed to fetch OpenAI models' }; } } if (anthropicProvider) { try { results.anthropic = await anthropicProvider.listModels(); } catch (error) { results.anthropic = { error: error instanceof Error ? error.message : 'Failed to fetch Anthropic models' }; } } if (googleProvider) { try { results.google = await googleProvider.listModels(); } catch (error) { results.google = { error: error instanceof Error ? error.message : 'Failed to fetch Google models' }; } } return { content: [ { type: 'text', text: JSON.stringify(results, null, 2), }, ], }; }
- src/providers/openai.ts:18-33 (helper)Helper method listModels() in OpenAIProvider class that queries the OpenAI API to retrieve the list of available models.async listModels(): Promise<OpenAIModel[]> { try { const response = await axios.get(`${this.baseURL}/models`, { headers: { 'Authorization': `Bearer ${this.apiKey}`, 'Content-Type': 'application/json' } }); return response.data.data; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`OpenAI API error: ${error.response?.data?.error?.message || error.message}`); } throw error; }
- src/providers/anthropic.ts:18-34 (helper)Helper method listModels() in AnthropicProvider class that queries the Anthropic API to retrieve the list of available models.async listModels(): Promise<AnthropicModel[]> { try { const response = await axios.get(`${this.baseURL}/models`, { headers: { 'x-api-key': this.apiKey, 'anthropic-version': '2023-06-01', 'Content-Type': 'application/json' } }); return response.data.data; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Anthropic API error: ${error.response?.data?.error?.message || error.message}`); } throw error; }
- src/providers/google.ts:22-36 (helper)Helper method listModels() in GoogleProvider class that queries the Google Generative AI API to retrieve the list of available models.async listModels(): Promise<GoogleModel[]> { try { const response = await axios.get(`${this.baseURL}/models`, { params: { key: this.apiKey } }); return response.data.models || []; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Google AI API error: ${error.response?.data?.error?.message || error.message}`); } throw error; }