Skip to main content
Glama

bench

Benchmark response latency for all configured MCP servers to identify performance issues.

Instructions

Benchmark response latency for all configured MCP servers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/server.ts:77-114 (registration)
    Registers the 'bench' MCP tool with the server using server.tool(). The tool is named 'bench' and benchmarks response latency for all configured MCP servers.
    server.tool(
      "bench",
      "Benchmark response latency for all configured MCP servers",
      {},
      async () => {
        const servers = await scanConfigs();
        if (servers.length === 0) {
          return {
            content: [{ type: "text", text: "No MCP servers found in any configuration." }],
          };
        }
    
        const results: ScanResult[] = [];
        for (const s of servers) {
          results.push(await testServer(s));
        }
    
        const responding = results
          .filter((r) => r.status === "ok" && r.latencyMs !== undefined)
          .sort((a, b) => (a.latencyMs ?? 0) - (b.latencyMs ?? 0));
    
        if (responding.length === 0) {
          return {
            content: [{ type: "text", text: "No servers responded for benchmarking." }],
          };
        }
    
        const lines = responding.map((r, i) => {
          const ms = r.latencyMs!;
          const rating = ms < 500 ? "Fast" : ms < 2000 ? "OK" : "Slow";
          return `${i + 1}. ${r.server.name} — ${ms}ms (${rating})`;
        });
    
        return {
          content: [{ type: "text", text: lines.join("\n") }],
        };
      }
    );
  • The handler function for the 'bench' tool. It scans configs, tests each server, filters OK responses with latency, sorts by latency, and returns a ranked list with ratings (Fast/OK/Slow).
    async () => {
      const servers = await scanConfigs();
      if (servers.length === 0) {
        return {
          content: [{ type: "text", text: "No MCP servers found in any configuration." }],
        };
      }
    
      const results: ScanResult[] = [];
      for (const s of servers) {
        results.push(await testServer(s));
      }
    
      const responding = results
        .filter((r) => r.status === "ok" && r.latencyMs !== undefined)
        .sort((a, b) => (a.latencyMs ?? 0) - (b.latencyMs ?? 0));
    
      if (responding.length === 0) {
        return {
          content: [{ type: "text", text: "No servers responded for benchmarking." }],
        };
      }
    
      const lines = responding.map((r, i) => {
        const ms = r.latencyMs!;
        const rating = ms < 500 ? "Fast" : ms < 2000 ? "OK" : "Slow";
        return `${i + 1}. ${r.server.name} — ${ms}ms (${rating})`;
      });
    
      return {
        content: [{ type: "text", text: lines.join("\n") }],
      };
    }
  • src/index.ts:68-86 (registration)
    CLI command registration for 'bench' using Commander. Defines the CLI interface for the bench subcommand with --json option.
    program
      .command("bench")
      .description("Benchmark MCP server response times")
      .option("--json", "Output results as JSON")
      .action(async (opts) => {
        const servers = await discoverServers(opts.json);
        if (servers.length === 0) return;
    
        const results = await testAllServers(servers, opts.json, "Benchmarking servers...", "Benchmark complete");
    
        if (opts.json) {
          const sorted = results
            .filter((r) => r.status === "ok" && r.latencyMs !== undefined)
            .sort((a, b) => (a.latencyMs ?? 0) - (b.latencyMs ?? 0));
          console.log(JSON.stringify(sorted.map(formatScanResult), null, 2));
        } else {
          printBenchResults(results);
        }
      });
  • CLI action handler for the 'bench' command. Discovers servers, tests all, optionally formats as JSON, or prints results using printBenchResults.
    .action(async (opts) => {
      const servers = await discoverServers(opts.json);
      if (servers.length === 0) return;
    
      const results = await testAllServers(servers, opts.json, "Benchmarking servers...", "Benchmark complete");
    
      if (opts.json) {
        const sorted = results
          .filter((r) => r.status === "ok" && r.latencyMs !== undefined)
          .sort((a, b) => (a.latencyMs ?? 0) - (b.latencyMs ?? 0));
        console.log(JSON.stringify(sorted.map(formatScanResult), null, 2));
      } else {
        printBenchResults(results);
      }
    });
  • printBenchResults - UI helper that formats and prints benchmark results as a table with rank, server name, latency, and rating (Fast/OK/Slow).
    export function printBenchResults(results: ScanResult[]): void {
      const sorted = results
        .filter((r) => r.status === "ok" && r.latencyMs !== undefined)
        .sort((a, b) => (a.latencyMs ?? 0) - (b.latencyMs ?? 0));
    
      if (sorted.length === 0) {
        console.log(chalk.yellow("  No servers responded for benchmarking.\n"));
        return;
      }
    
      const table = new Table({
        head: [
          chalk.white("#"),
          chalk.white("Server"),
          chalk.white("Latency"),
          chalk.white("Rating"),
        ],
        style: { head: [], border: ["dim"] },
      });
    
      sorted.forEach((r, i) => {
        const ms = r.latencyMs!;
        const rating =
          ms < 500
            ? chalk.green("⚡ Fast")
            : ms < 2000
              ? chalk.yellow("⏳ OK")
              : chalk.red("🐌 Slow");
    
        table.push([String(i + 1), chalk.cyan(r.server.name), `${ms}ms`, rating]);
      });
    
      console.log(table.toString());
      console.log();
    }
Behavior2/5

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

Without annotations, the description carries full behavioral burden. It only states the action but does not disclose if it is read-only, sends requests, or impacts server performance.

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?

One efficient sentence, front-loaded with the verb 'benchmark', and no wasted words.

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 parameterless tool, the description is mostly complete. It clearly states what it does and its scope, though it could mention output format or side effects.

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

Parameters4/5

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

The tool has 0 parameters and 100% schema coverage, so the description does not need to add parameter info. Baseline 4 is appropriate.

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 tool benchmarks response latency for all configured MCP servers. It distinguishes from siblings like 'doctor', 'scan', 'security' by focusing on latency measurement.

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

Usage Guidelines3/5

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

The description implies usage for latency benchmarking but provides no guidance on when to use this tool vs alternatives, nor does it mention any prerequisites or exclusions.

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/realwigu/mcp-doctor'

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