ollama_show
Retrieve detailed information about a local Ollama model, including its modelfile, parameters, and architecture. Choose output as JSON or Markdown.
Instructions
Show detailed information about a specific model including modelfile, parameters, and architecture details.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Name of the model to show | |
| format | No | Output format (default: json) | json |
Implementation Reference
- src/tools/show.ts:20-44 (handler)This is the main tool definition and handler for 'ollama_show'. It defines the tool name, description, input schema, and the handler function that parses args with ShowModelInputSchema and calls showModel().
export const toolDefinition: ToolDefinition = { name: 'ollama_show', description: 'Show detailed information about a specific model including modelfile, parameters, and architecture details.', inputSchema: { type: 'object', properties: { model: { type: 'string', description: 'Name of the model to show', }, format: { type: 'string', enum: ['json', 'markdown'], description: 'Output format (default: json)', default: 'json', }, }, required: ['model'], }, handler: async (ollama: Ollama, args: Record<string, unknown>, format: ResponseFormat) => { const validated = ShowModelInputSchema.parse(args); return showModel(ollama, validated.model, format); }, }; - src/tools/show.ts:10-18 (helper)Core business logic: calls ollama.show({model}) and formats the response via formatResponse().
export async function showModel( ollama: Ollama, model: string, format: ResponseFormat ): Promise<string> { const response = await ollama.show({ model }); return formatResponse(JSON.stringify(response), format); } - src/schemas.ts:64-67 (schema)Zod schema for ollama_show input validation: model (required string) and format (optional, defaults to 'json').
export const ShowModelInputSchema = z.object({ model: z.string().min(1), format: ResponseFormatSchema.default('json'), }); - src/server.ts:48-123 (registration)Server-side registration: discoverTools() loads all toolDefinitions (including ollama_show) and registers them via server.setRequestHandler().
// 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, })), }; }); // Register tool call handler server.setRequestHandler(CallToolRequestSchema, async (request) => { try { const { name, arguments: args } = request.params; // Discover all tools const tools = await discoverTools(); // Find the matching tool const tool = tools.find((t) => t.name === name); if (!tool) { throw new Error(`Unknown tool: ${name}`); } // Determine format from args const formatArg = (args as Record<string, unknown>).format; const format = formatArg === 'markdown' ? ResponseFormat.MARKDOWN : ResponseFormat.JSON; // Call the tool handler const result = await tool.handler( ollama, args as Record<string, unknown>, format ); // Parse the result to extract structured data let structuredData: unknown = undefined; try { // Attempt to parse the result as JSON structuredData = JSON.parse(result); } catch { // If parsing fails, leave structuredData as undefined // This handles cases where the result is markdown or plain text } return { structuredContent: structuredData, content: [ { type: 'text', text: result, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: 'text', text: `Error: ${errorMessage}`, }, ], isError: true, }; } }); return server; } - src/utils/response-formatter.ts:7-34 (helper)Utility used by showModel to format response output as JSON or markdown.
export function formatResponse( content: string, format: ResponseFormat ): string { if (format === ResponseFormat.JSON) { // For JSON format, validate and potentially wrap errors try { // Try to parse to validate it's valid JSON JSON.parse(content); return content; } catch { // If not valid JSON, wrap in error object return JSON.stringify({ error: 'Invalid JSON content', raw_content: content, }); } } // Format as markdown try { const data = JSON.parse(content); return jsonToMarkdown(data); } catch { // If not valid JSON, return as-is return content; } }