Skip to main content
Glama
akiojin

Model Hub MCP

by akiojin

list_models

Retrieve available AI models from OpenAI, Anthropic, or Google providers to identify suitable options for your project needs.

Instructions

List all available models from a specific provider

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
providerYesThe AI provider to list models from

Implementation Reference

  • src/index.ts:36-50 (registration)
    Tool registration for 'list_models' including name, description, and input schema.
    {
      name: 'list_models',
      description: 'List all available models from a specific provider',
      inputSchema: {
        type: 'object',
        properties: {
          provider: {
            type: 'string',
            enum: ['openai', 'anthropic', 'google'],
            description: 'The AI provider to list models from',
          },
        },
        required: ['provider'],
      },
    },
  • Input schema for the list_models tool, specifying the required 'provider' parameter.
    inputSchema: {
      type: 'object',
      properties: {
        provider: {
          type: 'string',
          enum: ['openai', 'anthropic', 'google'],
          description: 'The AI provider to list models from',
        },
      },
      required: ['provider'],
    },
  • Handler logic for the list_models tool: validates provider, calls the corresponding provider's listModels method, and returns the models as JSON text content.
    case 'list_models': {
      const { provider } = args as { provider: string };
      
      switch (provider) {
        case 'openai':
          if (!openaiProvider) {
            throw new McpError(ErrorCode.InvalidRequest, 'OpenAI API key not configured');
          }
          const openaiModels = await openaiProvider.listModels();
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(openaiModels, null, 2),
              },
            ],
          };
          
        case 'anthropic':
          if (!anthropicProvider) {
            throw new McpError(ErrorCode.InvalidRequest, 'Anthropic API key not configured');
          }
          const anthropicModels = await anthropicProvider.listModels();
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(anthropicModels, null, 2),
              },
            ],
          };
          
        case 'google':
          if (!googleProvider) {
            throw new McpError(ErrorCode.InvalidRequest, 'Google API key not configured');
          }
          const googleModels = await googleProvider.listModels();
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(googleModels, null, 2),
              },
            ],
          };
          
        default:
          throw new McpError(ErrorCode.InvalidRequest, `Unknown provider: ${provider}`);
      }
    }
  • OpenAI provider's listModels helper: fetches models from OpenAI API using axios.
    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;
      }
  • Anthropic provider's listModels helper: fetches models from Anthropic API using axios.
    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;
      }
  • Google provider's listModels helper: fetches models from Google AI API using axios.
    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;
      }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the action ('list') but doesn't disclose behavioral traits such as whether this is a read-only operation, potential rate limits, authentication needs, or what the output format looks like. For a tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with zero waste. It's front-loaded and efficiently conveys the core purpose without unnecessary details, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'list' entails (e.g., format, pagination, or data returned), and with sibling tools present, it fails to provide context for differentiation. This leaves significant gaps for an agent to use the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'provider' fully documented in the schema (including enum values). The description adds no additional meaning beyond implying the provider is 'specific', which is already covered. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'list' and the resource 'all available models from a specific provider', which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'list_all_models' or 'get_model', which likely have different scopes or functions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'list_all_models' or 'get_model'. It lacks context about use cases, prerequisites, or exclusions, leaving the agent to infer usage from the tool name and schema alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/akiojin/model-hub-mcp'

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