list_supported_models
Retrieve a list of Gemini models compatible with the 'generateContent' method for processing YouTube videos via the Youtube Vision MCP server.
Instructions
Lists available Gemini models that support the 'generateContent' method.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:184-249 (handler)The handler function for the 'list_supported_models' tool. It fetches the list of available Gemini models using the REST API, filters for those supporting 'generateContent', formats the list, and returns it as text content. Includes comprehensive error handling for API responses.case "list_supported_models": { try { console.error(`[INFO] Received request to list supported models.`); // Call the Gemini REST API to list models const listModelsUrl = `https://generativelanguage.googleapis.com/v1beta/models?key=${apiKey}`; const response = await fetch(listModelsUrl); if (!response.ok) { let errorDetail = await response.text(); let errorMessage = `Failed to fetch models from API (${response.status} ${response.statusText}).`; switch (response.status) { case 401: case 403: errorMessage = `Invalid API Key or permission denied for model listing.`; break; case 404: errorMessage = `Model listing API endpoint not found.`; break; case 429: errorMessage = `API quota exceeded for model listing.`; break; default: if (response.status >= 400 && response.status < 500) { errorMessage = `Invalid request to model listing API (${response.status}).`; } else if (response.status >= 500) { errorMessage = `Gemini API server error during model listing (${response.status}).`; } } throw new Error(`${errorMessage} Details: ${errorDetail}`); } const data = await response.json(); // Ensure data.models is an array before filtering const allModels: any[] = Array.isArray(data?.models) ? data.models : []; const supportedModels = allModels .filter(model => model.supportedGenerationMethods?.includes('generateContent')) .map(model => model.name); console.error(`[INFO] Found ${supportedModels.length} models supporting generateContent via REST API.`); if (supportedModels.length === 0) { return { content: [{ type: "text", text: "No models found supporting 'generateContent' via REST API." }], }; } return { content: [{ type: "text", text: `Models supporting 'generateContent' (fetched via REST API):\n- ${supportedModels.join('\n- ')}` }], }; } catch (error: any) { // Catch errors from fetch itself or the re-thrown error from response check console.error(`[ERROR] Failed during list_supported_models tool execution:`, error); let errorMessage = `Failed to list supported models.`; // Default message if (error.message) { errorMessage += ` Details: ${error.message}`; } return { content: [{ type: "text", text: errorMessage }], isError: true, }; } }
- src/index.ts:86-90 (registration)Registration of the 'list_supported_models' tool in the ListToolsRequestSchema handler. Specifies the tool name, description, and input schema (empty object).{ name: "list_supported_models", description: "Lists available Gemini models that support the 'generateContent' method.", inputSchema: zodToJsonSchema(z.object({})), // No input needed },
- src/index.ts:89-89 (schema)Input schema definition for the tool: an empty Zod object schema (no required parameters), converted to JSON schema for MCP protocol.inputSchema: zodToJsonSchema(z.object({})), // No input needed