Skip to main content
Glama
akiojin

Model Hub MCP

by akiojin

get_model

Retrieve detailed specifications for AI models from OpenAI, Anthropic, or Google using a unified interface to access model information.

Instructions

Get details of a specific model from a provider

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
providerYesThe AI provider
model_idYesThe model ID to fetch details for

Implementation Reference

  • src/index.ts:51-69 (registration)
    Registers the 'get_model' tool with name, description, and input schema in the list_tools response.
    {
      name: 'get_model',
      description: 'Get details of a specific model from a provider',
      inputSchema: {
        type: 'object',
        properties: {
          provider: {
            type: 'string',
            enum: ['openai', 'anthropic', 'google'],
            description: 'The AI provider',
          },
          model_id: {
            type: 'string',
            description: 'The model ID to fetch details for',
          },
        },
        required: ['provider', 'model_id'],
      },
    },
  • Executes the 'get_model' tool by dispatching to the provider-specific getModel method based on the provider input, checks API key configuration, and returns JSON stringified model details.
    case 'get_model': {
      const { provider, model_id } = args as { provider: string; model_id: string };
      
      switch (provider) {
        case 'openai':
          if (!openaiProvider) {
            throw new McpError(ErrorCode.InvalidRequest, 'OpenAI API key not configured');
          }
          const openaiModel = await openaiProvider.getModel(model_id);
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(openaiModel, null, 2),
              },
            ],
          };
          
        case 'anthropic':
          if (!anthropicProvider) {
            throw new McpError(ErrorCode.InvalidRequest, 'Anthropic API key not configured');
          }
          const anthropicModel = await anthropicProvider.getModel(model_id);
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(anthropicModel, null, 2),
              },
            ],
          };
          
        case 'google':
          if (!googleProvider) {
            throw new McpError(ErrorCode.InvalidRequest, 'Google API key not configured');
          }
          const googleModel = await googleProvider.getModel(model_id);
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(googleModel, null, 2),
              },
            ],
          };
          
        default:
          throw new McpError(ErrorCode.InvalidRequest, `Unknown provider: ${provider}`);
      }
    }
  • OpenAI provider helper function that retrieves specific model details by making an API request to OpenAI's models endpoint.
    async getModel(modelId: string): Promise<OpenAIModel> {
      try {
        const response = await axios.get(`${this.baseURL}/models/${modelId}`, {
          headers: {
            'Authorization': `Bearer ${this.apiKey}`,
            'Content-Type': 'application/json'
          }
        });
    
        return response.data;
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new Error(`OpenAI API error: ${error.response?.data?.error?.message || error.message}`);
        }
        throw error;
      }
    }
  • Anthropic provider helper function that retrieves specific model details by making an API request to Anthropic's models endpoint.
    async getModel(modelId: string): Promise<AnthropicModel> {
      try {
        const response = await axios.get(`${this.baseURL}/models/${modelId}`, {
          headers: {
            'x-api-key': this.apiKey,
            'anthropic-version': '2023-06-01',
            'Content-Type': 'application/json'
          }
        });
    
        return response.data;
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new Error(`Anthropic API error: ${error.response?.data?.error?.message || error.message}`);
        }
        throw error;
      }
    }
  • Google provider helper function that retrieves specific model details by making an API request to Google's Generative Language API models endpoint.
    async getModel(modelId: string): Promise<GoogleModel> {
      try {
        const response = await axios.get(`${this.baseURL}/models/${modelId}`, {
          params: {
            key: this.apiKey
          }
        });
    
        return response.data;
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new Error(`Google AI API error: ${error.response?.data?.error?.message || error.message}`);
        }
        throw error;
      }
    }
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