Skip to main content
Glama
hoangdn3
by hoangdn3

validate_model

Verify if a model ID is compatible with OpenRouter's multimodal AI ecosystem before use.

Instructions

Check if a model ID is valid

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelYesThe model ID to validate

Implementation Reference

  • The core handler function that implements the validate_model tool logic: checks if the model cache is valid, verifies if the specified model exists using modelCache.hasModel, and returns JSON {valid: boolean} or an error response.
    export async function handleValidateModel( request: { params: { arguments: ValidateModelToolRequest } }, modelCache: ModelCache ) { const args = request.params.arguments; try { if (!modelCache.isCacheValid()) { return { content: [ { type: 'text', text: 'Model cache is empty or expired. Please call search_models first to populate the cache.', }, ], isError: true, }; } const isValid = modelCache.hasModel(args.model); return { content: [ { type: 'text', text: JSON.stringify({ valid: isValid }), }, ], }; } catch (error) { if (error instanceof Error) { return { content: [ { type: 'text', text: `Error validating model: ${error.message}`, }, ], isError: true, }; } throw error; } }
  • Tool registration in the ListToolsRequest handler, defining the tool name, description, and input schema for MCP clients.
    { name: 'validate_model', description: 'Check if a model ID is valid', inputSchema: { type: 'object', properties: { model: { type: 'string', description: 'The model ID to validate', }, }, required: ['model'], }, },
  • Dispatch logic in the CallToolRequest switch statement that invokes the validate_model handler with the request arguments and modelCache instance.
    case 'validate_model': return handleValidateModel({ params: { arguments: request.params.arguments as unknown as ValidateModelToolRequest } }, this.modelCache);
  • TypeScript type definition for the tool's input parameters, matching the JSON schema in registration.
    export interface ValidateModelToolRequest { model: string; }
  • JSON Schema for input validation in the MCP tool specification.
    inputSchema: { type: 'object', properties: { model: { type: 'string', description: 'The model ID to validate', }, }, required: ['model'], },

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/hoangdn3/mcp-ocr-fallback'

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