Skip to main content
Glama
metrxbots

Metrx MCP Server

by metrxbots

Get Experiment Results

metrx_get_experiment_results
Read-onlyIdempotent

Retrieve current results for model routing experiments, including sample counts, metric comparisons, statistical significance, and winning models.

Instructions

Get the current results of a model routing experiment. Shows sample counts, metric comparisons, statistical significance, and the current winner (if determined). Do NOT use for starting experiments — use create_model_experiment.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idNoFilter experiments by agent
statusNoFilter by experiment status

Implementation Reference

  • The main handler implementation for 'get_experiment_results' tool. This function fetches experiment results from the API with optional filters (agent_id, status), formats the output using formatExperiment helper, and returns structured MCP responses with proper error handling.
    server.registerTool(
      'get_experiment_results',
      {
        title: 'Get Experiment Results',
        description:
          'Get the current results of a model routing experiment. ' +
          'Shows sample counts, metric comparisons, statistical significance, ' +
          'and the current winner (if determined). ' +
          'Do NOT use for starting experiments — use create_model_experiment.',
        inputSchema: {
          agent_id: z.string().uuid().optional().describe('Filter experiments by agent'),
          status: z
            .enum(['running', 'paused', 'completed', 'cancelled'])
            .optional()
            .describe('Filter by experiment status'),
        },
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async ({ agent_id, status }) => {
        const params: Record<string, string> = {};
        if (agent_id) params.agent_id = agent_id;
        if (status) params.status = status;
    
        const result = await client.get<{ experiments: ModelRoutingExperiment[] }>(
          '/experiments',
          params
        );
    
        if (result.error) {
          return {
            content: [{ type: 'text', text: `Error fetching experiments: ${result.error}` }],
            isError: true,
          };
        }
    
        const experiments = result.data?.experiments || [];
        if (experiments.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: 'No experiments found. Use create_model_experiment to start an A/B test.',
              },
            ],
          };
        }
    
        const texts = experiments.map(formatExperiment);
    
        return {
          content: [{ type: 'text', text: texts.join('\n\n---\n\n') }],
        };
      }
    );
  • Input schema definition for the get_experiment_results tool. Defines optional agent_id (UUID) and status (enum: running, paused, completed, cancelled) parameters for filtering experiments.
    inputSchema: {
      agent_id: z.string().uuid().optional().describe('Filter experiments by agent'),
      status: z
        .enum(['running', 'paused', 'completed', 'cancelled'])
        .optional()
        .describe('Filter by experiment status'),
    },
  • Registration wrapper that adds 'metrx_' prefix to all tool names. This mechanism transforms 'get_experiment_results' into 'metrx_get_experiment_results' when registered with the MCP server. Also includes rate limiting middleware.
    // Add rate limiting middleware + metrx_ namespace prefix
    const METRX_PREFIX = 'metrx_';
    const originalRegisterTool = server.registerTool.bind(server);
    (server as any).registerTool = function (
      name: string,
      config: any,
      handler: (...handlerArgs: any[]) => Promise<any>
    ) {
      const wrappedHandler = async (...handlerArgs: any[]) => {
        if (!rateLimiter.isAllowed(name)) {
          return {
            content: [
              {
                type: 'text' as const,
                text: `Rate limit exceeded for tool '${name}'. Maximum 60 requests per minute allowed.`,
              },
            ],
            isError: true,
          };
        }
        return handler(...handlerArgs);
      };
    
      // Register with metrx_ prefix (primary name only — no deprecated aliases)
      const prefixedName = name.startsWith(METRX_PREFIX) ? name : `${METRX_PREFIX}${name}`;
      originalRegisterTool(prefixedName, config, wrappedHandler);
    };
  • Type definition for ModelRoutingExperiment which defines the shape of experiment data including id, name, agent_id, control/treatment models, traffic split, status, sample counts, significance, and winner fields.
    export interface ModelRoutingExperiment {
      id: string;
      name: string;
      agent_id: string;
      control_model: string;
      treatment_model: string;
      traffic_pct: number;
      status: string;
      primary_metric: string;
      control_samples: number;
      treatment_samples: number;
      is_significant: boolean;
      winner?: string;
    }
  • Helper function formatExperiment that converts ModelRoutingExperiment data into human-readable text output, showing experiment status, models, sample counts, traffic split, primary metric, significance, and winner information.
    export function formatExperiment(exp: ModelRoutingExperiment): string {
      const lines: string[] = [
        `## Experiment: ${exp.name}`,
        '',
        `**Status**: ${exp.status}`,
        `**Control**: ${exp.control_model} (${exp.control_samples} samples)`,
        `**Treatment**: ${exp.treatment_model} (${exp.treatment_samples} samples)`,
        `**Traffic Split**: ${exp.traffic_pct}% to treatment`,
        `**Primary Metric**: ${exp.primary_metric}`,
        `**Significant**: ${exp.is_significant ? 'Yes' : 'Not yet'}`,
      ];
    
      if (exp.winner) {
        lines.push(`**Winner**: ${exp.winner}`);
      }
    
      return lines.join('\n');
    }
Behavior4/5

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

The annotations already provide comprehensive behavioral information (read-only, idempotent, non-destructive, closed-world). The description adds valuable context about what information is returned (sample counts, metric comparisons, statistical significance, winner determination) that goes beyond the annotations. However, it doesn't mention potential limitations like rate limits or authentication requirements.

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 with just two sentences. The first sentence states the purpose and what's returned, while the second provides crucial usage guidance. Every word earns its place with no redundancy or unnecessary elaboration.

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

Completeness4/5

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

For a read-only query tool with comprehensive annotations and full schema coverage, the description provides excellent context about what information is returned and clear usage boundaries. The only minor gap is the lack of output schema, but the description compensates by detailing the return content. A perfect score would require output format specification.

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?

With 100% schema description coverage, the schema fully documents both parameters. The description doesn't add any parameter-specific information beyond what's already in the schema descriptions. The baseline score of 3 is appropriate when the schema does all the parameter documentation work.

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

Purpose5/5

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

The description clearly states the specific action ('Get the current results') and resource ('model routing experiment'), and distinguishes it from the sibling tool 'create_model_experiment' by explicitly stating what it does not do. It provides concrete details about what information is returned (sample counts, metric comparisons, statistical significance, current winner).

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

Usage Guidelines5/5

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

The description explicitly states when NOT to use this tool ('Do NOT use for starting experiments') and provides a clear alternative ('use create_model_experiment'). This gives the agent precise guidance on appropriate vs. inappropriate contexts for tool selection.

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/metrxbots/metrx-mcp-server'

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