Skip to main content
Glama
th3nolo

OpenRouter MCP Server

by th3nolo

compare_models

Compare AI model responses side-by-side by sending the same prompt to multiple models for evaluation and analysis.

Instructions

Compare responses from multiple models

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelsYesArray of model IDs to compare
messageYesMessage to send to all models
max_tokensNoMaximum tokens per response

Implementation Reference

  • The main implementation of compareModels tool that sends the same message to multiple models in parallel and formats the comparison results
    private async compareModels(params: z.infer<typeof CompareModelsSchema>) {
      const { models, message, max_tokens } = params;
    
      const promises = models.map(async (model) => {
        try {
          const response = await axios.post(
            `${OPENROUTER_CONFIG.baseURL}/chat/completions`,
            {
              model,
              messages: [{ role: "user", content: message }],
              max_tokens,
            },
            { headers: OPENROUTER_CONFIG.headers }
          );
    
          return {
            model,
            response: response.data.choices[0].message.content,
            usage: response.data.usage,
            success: true,
          };
        } catch (error) {
          return {
            model,
            error: error instanceof Error ? error.message : "Unknown error",
            success: false,
          };
        }
      });
    
      const results = await Promise.all(promises);
    
      const formattedResults = results
        .map((result) => {
          if (result.success) {
            return `**${result.model}:**\n${result.response}\n*Tokens: ${result.usage.total_tokens}*`;
          } else {
            return `**${result.model}:** ❌ Error - ${result.error}`;
          }
        })
        .join("\n\n---\n\n");
    
      return {
        content: [
          {
            type: "text" as const,
            text: `Comparison of ${models.length} models:\n\n${formattedResults}`,
          },
        ],
      };
    }
  • Zod schema defining the input validation for compare_models tool (models array, message, and optional max_tokens)
    const CompareModelsSchema = z.object({
      models: z.array(z.string()).describe("Array of model IDs to compare"),
      message: z.string().describe("Message to send to all models"),
      max_tokens: z.number().optional().default(500).describe("Maximum tokens per response"),
    });
  • src/server.ts:177-202 (registration)
    Tool registration in the MCP tools list with name 'compare_models', description, and input schema
    {
      name: "compare_models",
      description: "Compare responses from multiple models",
      inputSchema: {
        type: "object",
        properties: {
          models: {
            type: "array",
            items: {
              type: "string",
            },
            description: "Array of model IDs to compare",
          },
          message: {
            type: "string",
            description: "Message to send to all models",
          },
          max_tokens: {
            type: "number",
            description: "Maximum tokens per response",
            default: 500,
          },
        },
        required: ["models", "message"],
      },
    },
  • src/server.ts:231-232 (registration)
    Switch case handler that routes compare_models tool calls to the compareModels method
    case "compare_models":
      return await this.compareModels(CompareModelsSchema.parse(args));

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.6/5.0
Behavior1/5

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

No annotations provided; description only says 'compare responses' without disclosing behavioral traits such as whether it is read-only, how errors are handled, or the format of the output (e.g., does it return all responses or a summary?). This is a critical gap.

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

Conciseness3/5

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

The description is a single short sentence, which is concise but lacks necessary detail. It is not verbose, but the under-specification reduces informativeness, balancing to a mediocre score.

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

Completeness2/5

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

For a tool that compares models, agents need return format, ordering, and error handling information. The description provides none of this, and with no output schema or annotations, the completeness is poor.

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?

Input schema coverage is 100% with descriptions for all three parameters (models, message, max_tokens). The tool description adds no additional meaning beyond what the schema already provides, so baseline 3 is appropriate.

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 it compares responses from multiple models, distinguishing it from sibling tools like chat_with_model (single model) and list_models (model listing). However, it lacks specificity about the comparison mechanism (e.g., side-by-side display).

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives like chat_with_model. Does not mention scenarios where comparing responses is beneficial or when a different tool would be more appropriate.

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