Skip to main content
Glama

consult_ai

Consult AI models via OpenRouter for tasks like coding, analysis, or questions. Auto-selects the best model or specify multiple models for sequential consultation with conversation history support.

Instructions

Consult with an AI model via OpenRouter. You can either specify a model or let the system auto-select based on your task. For sequential multi-model consultation, use the 'models' parameter to specify multiple models.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clear_historyNoOptional: Set to true to clear the conversation history for the given conversation_id before processing this request.
conversation_idNoOptional: Conversation ID to maintain context across multiple consultations. Use the same ID for follow-up questions.
modelNoOptional: Specific model to use (e.g., 'gemini-2.5-pro', 'gpt-5-codex', 'grok-code-fast-1'). If not specified, the best model will be automatically selected based on the task.
modelsNoOptional: Array of models to consult sequentially (e.g., ["gemini-2.5-pro", "gpt-5-codex"]). When specified, the prompt will be sent to each model in order and responses will be aggregated. This parameter takes precedence over 'model'.
promptYesThe question or task to send to the AI model
task_descriptionNoOptional: Brief description of the task type to help auto-select the best model (e.g., 'coding task', 'complex analysis', 'quick question')

Implementation Reference

  • Implements the consult_ai tool handler: validates input, executes consultation via service, logs verbose details, and returns formatted JSON response.
    private async handleConsultAI(args: ConsultArgs): Promise<ToolResponse> {
      // Validate required arguments
      if (!args.prompt) {
        if (this.config.verboseLogging) {
          console.error("[MCP] Error: prompt is required but not provided");
        }
        throw new Error("prompt is required");
      }
    
      if (this.config.verboseLogging) {
        console.error("[MCP] Starting AI consultation");
        console.error(`[MCP] Prompt length: ${args.prompt.length} characters`);
        console.error(`[MCP] Requested model: ${args.model || "auto-select"}`);
        console.error(`[MCP] Requested models: ${args.models ? args.models.join(", ") : "none"}`);
        console.error(`[MCP] Task description: ${args.task_description || "none"}`);
        console.error(`[MCP] Conversation ID: ${args.conversation_id || "none"}`);
        console.error(`[MCP] Clear history: ${args.clear_history || false}`);
      }
    
      // Execute consultation
      const startTime = Date.now();
      const result = await this.consultationService.consult(args);
      const duration = Date.now() - startTime;
    
      // Log AI response if verbose logging is enabled
      if (this.config.verboseLogging) {
        console.error("=== AI Consultant Response ===");
        console.error(`Model: ${result.model}`);
        console.error(`Prompt: ${args.prompt.substring(0, 200)}${args.prompt.length > 200 ? "..." : ""}`);
        console.error(`Response length: ${result.response.length} characters`);
        console.error(`Response preview: ${result.response.substring(0, 200)}${result.response.length > 200 ? "..." : ""}`);
        console.error(`Tokens Used: ${JSON.stringify(result.usage, null, 2)}`);
        console.error(`Conversation ID: ${args.conversation_id || "N/A"}`);
        console.error(`Cached: ${result.model.includes("(cached)")}`);
        console.error(`Duration: ${duration}ms`);
        console.error("==============================");
      }
    
      // Format response
      const response: ConsultResponse = {
        model_used: result.model,
        response: result.response,
        tokens_used: result.usage,
        conversation_id: args.conversation_id || null,
        cached: result.model.includes("(cached)"),
      };
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify(response, null, 2),
          },
        ],
      };
    }
  • Defines the input schema, description, and parameters for the consult_ai tool, returned by getToolDefinitions.
    {
      name: "consult_ai",
      description:
        "Consult with an AI model via OpenRouter. You can either specify a model or let the system auto-select based on your task. For sequential multi-model consultation, use the 'models' parameter to specify multiple models.",
      inputSchema: {
        type: "object",
        properties: {
          prompt: {
            type: "string",
            description: "The question or task to send to the AI model",
          },
          model: {
            type: "string",
            description: `Optional: Specific model to use (e.g., ${modelNames.map((m) => `'${m}'`).join(", ")}). If not specified, the best model will be automatically selected based on the task.`,
            enum: modelNames,
          },
          models: {
            type: "array",
            description: `Optional: Array of models to consult sequentially (e.g., ["gemini-2.5-pro", "gpt-5-codex"]). When specified, the prompt will be sent to each model in order and responses will be aggregated. This parameter takes precedence over 'model'.`,
            items: {
              type: "string",
              enum: modelNames,
            },
          },
          task_description: {
            type: "string",
            description:
              "Optional: Brief description of the task type to help auto-select the best model (e.g., 'coding task', 'complex analysis', 'quick question')",
          },
          conversation_id: {
            type: "string",
            description:
              "Optional: Conversation ID to maintain context across multiple consultations. Use the same ID for follow-up questions.",
          },
          clear_history: {
            type: "boolean",
            description:
              "Optional: Set to true to clear the conversation history for the given conversation_id before processing this request.",
          },
        },
        required: ["prompt"],
      },
    },
  • Registers the consult_ai tool by providing its definition via ListTools MCP handler using getToolDefinitions.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      if (this.config.verboseLogging) {
        console.error("[MCP Server] Received ListTools request");
      }
    
      const modelNames = this.consultationService.listModels().map((m) => m.name);
      const tools = getToolDefinitions(modelNames);
    
      if (this.config.verboseLogging) {
        console.error(`[MCP Server] Returning ${tools.length} tool definitions`);
      }
    
      return { tools };
    });
  • Registers the tool execution handler by delegating CallTool requests to ToolHandler.handleToolCall.
    this.server.setRequestHandler(
      CallToolRequestSchema,
      async (request: CallToolRequest) => {
        if (this.config.verboseLogging) {
          console.error("[MCP Server] Received CallTool request");
        }
    
        const result = await this.toolHandler.handleToolCall(request);
        return result as any; // MCP SDK type compatibility
      },
    );
  • Type definition for the input arguments of the consult_ai tool.
    export interface ConsultArgs {
      prompt: string;
      model?: string;
      models?: string[]; // For sequential multi-model consultation
      task_description?: string;
      conversation_id?: string;
      clear_history?: boolean;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses key behavioral traits: the ability to auto-select models, sequential multi-model consultation, and that 'models' parameter takes precedence over 'model'. However, it lacks details on rate limits, authentication needs, response format, or error handling. For a complex AI consultation tool with no annotations, this is adequate but leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise and front-loaded: two sentences that efficiently cover the core functionality and key usage patterns. Every sentence earns its place by providing essential information without redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (AI consultation with multiple parameters and no output schema), the description is minimally complete. It covers the basic purpose and usage but lacks details on response format, error conditions, or practical constraints. With no annotations and no output schema, the description should do more to compensate, but it provides just enough to be functional.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 6 parameters thoroughly. The description adds marginal value by explaining the auto-selection logic and precedence of 'models' over 'model', but doesn't provide additional semantic context beyond what's in the schema. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Consult with an AI model via OpenRouter.' It specifies the action ('consult') and resource ('AI model'), though it doesn't explicitly differentiate from the sibling tool 'list_models' (which presumably lists available models rather than consulting them). The description is specific but lacks sibling differentiation for a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear usage context: 'You can either specify a model or let the system auto-select based on your task.' It also mentions an alternative approach: 'For sequential multi-model consultation, use the 'models' parameter to specify multiple models.' However, it doesn't explicitly state when NOT to use this tool or compare it to the sibling 'list_models', preventing a score of 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/goldenpath-ai/ai-consultant-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server