Skip to main content
Glama
stabgan

OpenRouter MCP Multimodal Server

by stabgan

validate_model

Verify model availability by checking if a specific model ID exists within the OpenRouter MCP Multimodal Server's ecosystem before use.

Instructions

Check if a model ID exists

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelYes

Implementation Reference

  • The implementation of the 'validate_model' tool, which checks if a model ID exists using the model cache.
    export async function handleValidateModel(
      request: { params: { arguments: { model: string } } },
      modelCache: ModelCache,
      apiClient?: OpenRouterAPIClient,
    ) {
      if (!modelCache.isValid() && apiClient) {
        modelCache.setModels(await apiClient.getModels());
      }
    
      if (!modelCache.isValid()) {
        return { content: [{ type: 'text', text: 'No model data available.' }], isError: true };
      }
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({ valid: modelCache.has(request.params.arguments.model) }),
          },
        ],
      };
    }
  • The definition/schema registration for the 'validate_model' tool.
    {
      name: 'validate_model',
      description: 'Check if a model ID exists',
      inputSchema: {
        type: 'object',
        properties: { model: { type: 'string' } },
        required: ['model'],
      },
    },
  • The handler dispatch logic for 'validate_model' inside the main request handler switch statement.
    case 'validate_model':
      return handleValidateModel(
        wrapToolArgs(args as { model: string } | undefined),
        this.modelCache,
        this.apiClient,
      );

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

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