ollama_list
List all locally installed Ollama models with names, sizes, and modification dates.
Instructions
List all available Ollama models installed locally. Returns model names, sizes, and modification dates.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Output format (default: json) | json |
Implementation Reference
- src/tools/list.ts:9-16 (handler)The core handler function 'listModels' that executes the tool logic by calling ollama.list() and formatting the response.
export async function listModels( ollama: Ollama, format: ResponseFormat ): Promise<string> { const response = await ollama.list(); return formatResponse(JSON.stringify(response), format); } - src/tools/list.ts:21-39 (registration)The tool definition object with name 'ollama_list', description, inputSchema, and a handler wrapper that delegates to listModels.
export const toolDefinition: ToolDefinition = { name: 'ollama_list', description: 'List all available Ollama models installed locally. Returns model names, sizes, and modification dates.', inputSchema: { type: 'object', properties: { format: { type: 'string', enum: ['json', 'markdown'], description: 'Output format (default: json)', default: 'json', }, }, }, handler: async (ollama: Ollama, args: Record<string, unknown>, format: ResponseFormat) => { return listModels(ollama, format); }, }; - src/schemas.ts:55-59 (schema)The Zod schema 'ListModelsInputSchema' for validating ollama_list tool input, accepting an optional 'format' parameter.
* Schema for ollama_list tool */ export const ListModelsInputSchema = z.object({ format: ResponseFormatSchema.default('json'), }); - src/server.ts:48-59 (registration)The MCP server registration of all tools (including ollama_list) via ListToolsRequestSchema handler, which calls discoverTools() to auto-load tool definitions from the tools directory.
// Register tool list handler server.setRequestHandler(ListToolsRequestSchema, async () => { const tools = await discoverTools(); return { tools: tools.map((tool) => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema, })), }; }); - src/types.ts:105-112 (helper)ModelNotFoundError class that references 'ollama_list' in its error message, guiding users to use the list tool.
export class ModelNotFoundError extends OllamaError { constructor(modelName: string) { super( `Model not found: ${modelName}. Use ollama_list to see available models.` ); this.name = 'ModelNotFoundError'; } }