consult_ollama
Get alternative reasoning viewpoints by consulting Ollama models with prompts. Automatically switches to available cloud or local models if your requested model isn't available locally.
Instructions
Consult an Ollama model with a prompt and get its response for reasoning from another viewpoint. If the requested model is unavailable locally, automatically falls back to: cloud models (deepseek-v3.1:671b-cloud, kimi-k2-thinking:cloud) or local alternatives (mistral, llama2). Never fails on model availability.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | ||
| prompt | Yes | ||
| system_prompt | No |
Implementation Reference
- Core handler class implementing the execution logic for 'consult_ollama' tool: validates inputs, auto-selects models based on consultation_type, checks model availability with fallbacks, calls OllamaService.consult(), and formats MCP response.export class ConsultOllamaHandler extends BaseHandler { private modelValidator: ModelValidator; constructor( private ollamaService: OllamaService, modelValidator?: ModelValidator ) { super(); this.modelValidator = modelValidator || new ModelValidator(this.ollamaService.getConfig()); } async handle(params: unknown): Promise<MCPResponse> { // Validate and cast parameters const typedParams = params as Record<string, unknown>; try { // Validate required parameters this.validateRequired(typedParams, ['prompt']); let model = (typedParams.model as string) || ''; const consultationType = typedParams.consultation_type as string | undefined; // Auto-select model based on consultation type if (consultationType === 'thinking') { model = 'kimi-k2-thinking:cloud'; } else if (consultationType === 'instruction') { model = 'qwen3-vl:235b-instruct-cloud'; } else if (!model) { // If no model specified and no consultation type, use default model = await this.modelValidator.getDefaultModel(); } // Validate model availability if (model) { const isAvailable = await this.modelValidator.isModelAvailable(model); if (!isAvailable) { const suggestions = await this.modelValidator.getSuggestions(3); const typeInfo = consultationType ? ` (auto-selected for ${consultationType} consultation)` : ''; return { content: [ { type: 'text', text: `Model '${model}'${typeInfo} is not available. Available models: ${suggestions.join(', ')}. Please install the model or choose an available one.`, }, ], isError: true, }; } } // Build consult request const request: ConsultRequest = { model, prompt: typedParams.prompt as string, stream: false, }; // Include system prompt if provided if (typedParams.system_prompt) { request.systemPrompt = typedParams.system_prompt as string; } // Include temperature if provided if (typeof typedParams.temperature === 'number') { request.temperature = typedParams.temperature; } // Include timeout if provided if (typeof typedParams.timeout_ms === 'number') { request.timeout = typedParams.timeout_ms; } // Call Ollama service const response = await this.ollamaService.consult(request); // Return formatted response return { content: [ { type: 'text', text: response.response, }, ], }; } catch (error) { // Handle errors with consistent formatting const message = error instanceof Error ? error.message : 'Unknown error'; return { content: [ { type: 'text', text: `Error consulting Ollama: ${message}`, }, ], isError: true, }; } }
- src/handlers/callToolHandler.ts:34-37 (registration)Tool registration/dispatch within CallToolHandler.handle(): instantiates ConsultOllamaHandler and delegates the call for 'consult_ollama'.case 'consult_ollama': { const handler = new ConsultOllamaHandler(this.ollamaService, this.modelValidator); return await handler.handle(args); }
- Input schema and description for 'consult_ollama' tool as returned by ListToolsHandler, defining parameters like consultation_type, model, prompt, system_prompt, context, temperature, timeout_ms.name: 'consult_ollama', description: 'Consult with Ollama AI models for architectural decisions, code reviews, and design discussions. Supports sequential chaining of consultations for complex multi-step reasoning.', inputSchema: { type: 'object', properties: { consultation_type: { type: 'string', enum: ['thinking', 'instruction', 'general'], description: 'Type of consultation: "thinking" (uses kimi-k2-thinking:cloud for reasoning tasks), "instruction" (uses qwen3-vl:235b-instruct-cloud for instruction-following), or "general" (uses specified model or default). If specified, overrides the model parameter.', }, model: { type: 'string', description: 'Model to use (e.g., "qwen2.5-coder:7b-cloud"). If not specified and no consultation_type, uses the first available model. Must be a cloud model (ends with :cloud or -cloud) or locally installed.', }, prompt: { type: 'string', description: 'Your question or prompt for the AI model. Can reference previous consultation results.', }, system_prompt: { type: 'string', description: 'Optional system prompt to guide model behavior', }, context: { type: 'object', description: 'Optional context including code, previous results, and metadata', properties: { code: { type: 'string', description: 'Code snippet or file content for analysis', }, language: { type: 'string', description: 'Programming language of the code', }, previous_results: { type: 'array', description: 'Results from previous consultations in the chain', items: { type: 'string' }, }, metadata: { type: 'object', description: 'Additional contextual information', }, }, }, temperature: { type: 'number', description: 'Sampling temperature (0.0-2.0, default: 0.7)', }, timeout_ms: { type: 'number', description: 'Request timeout in milliseconds (default: 60000). Increase for complex prompts with system prompts (e.g., 120000-300000 for complex reasoning)', }, }, required: ['prompt'], }, },