llm_get_models
Retrieves available language models from OpenAI-compatible LLM servers to identify options for testing, benchmarking, and chat operations.
Instructions
Obtiene la lista de modelos disponibles en el servidor LLM (compatible con OpenAI API: LM Studio, Ollama, vLLM, OpenAI, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| baseURL | No | URL del servidor OpenAI-compatible (ej: http://localhost:1234/v1, http://localhost:11434/v1) | |
| apiKey | No | API Key (requerida para OpenAI/Azure, opcional para servidores locales) |
Implementation Reference
- src/tools.ts:211-229 (handler)The core handler function for the 'llm_get_models' tool. It creates an LLMClient instance, lists available models from the server, and returns a JSON-formatted response with model IDs, owners, count, and baseURL.async llm_get_models(args: z.infer<typeof GetModelsSchema> = {}) { const client = getClient(args); const models = await client.listModels(); return { content: [ { type: "text" as const, text: JSON.stringify({ models: models.map(m => ({ id: m.id, owned_by: m.owned_by, })), count: models.length, baseURL: args.baseURL || defaultConfig.baseURL, }, null, 2), }, ], }; },
- src/tools.ts:72-82 (schema)MCP tool registration entry defining the name, description, and input schema (connection properties like baseURL and apiKey) for 'llm_get_models'.{ name: "llm_get_models", description: "Obtiene la lista de modelos disponibles en el servidor LLM (compatible con OpenAI API: LM Studio, Ollama, vLLM, OpenAI, etc.)", inputSchema: { type: "object" as const, properties: { ...connectionProperties, }, required: [], }, },
- src/tools.ts:11-12 (schema)Zod schema for input validation of llm_get_models arguments, extending the base ConnectionConfigSchema.export const GetModelsSchema = ConnectionConfigSchema.extend({});
- src/index.ts:52-53 (registration)Registration in the MCP server's CallToolRequest handler that dispatches to the llm_get_models tool handler based on the tool name.case "llm_get_models": return await toolHandlers.llm_get_models(args as any);
- src/index.ts:42-44 (registration)MCP server handler for listing tools, which returns the tools array including 'llm_get_models'.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });