GitHub 0
Skip to content

Check tools in your tests

Run is-mcp-ok's checks in an end-to-end test on what your MCP server returns, including each tools/call result.

The checks come from the is-mcp-ok package, so an end-to-end test can run them on what your server returns. That includes each tools/call result, which the CLI never calls on its own.

pnpm add -D is-mcp-ok

The package has no runtime dependencies and runs in Node, the browser and a Cloudflare Worker.

Connect with the MCP SDK, call each tool, and check the list and every result:

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
import { checkMcpClientLimits, checkMcpToolResult, formatMcpFindings } from "is-mcp-ok";
import { expect, test } from "vitest";
import { sampleArguments } from "./mcp-arguments";

test("every client gets every tool intact", async () => {
  const client = new Client({ name: "e2e", version: "1.0.0" });
  await client.connect(new StreamableHTTPClientTransport(new URL("http://localhost:3000/mcp")));
  const tools = [];
  let cursor: string | undefined;

  do {
    const page = await client.listTools(cursor === undefined ? undefined : { cursor });
    tools.push(...page.tools);
    for (const tool of page.tools) {
      const result = await client.callTool({
        name: tool.name,
        arguments: sampleArguments[tool.name],
      });
      expect(formatMcpFindings(checkMcpToolResult(result, { tool }))).toBe("");
    }
    cursor = page.nextCursor;
  } while (cursor !== undefined);

  expect(formatMcpFindings(checkMcpClientLimits({ tools }, { serverName: "shop" }))).toBe("");
});
tests/e2e/mcp.spec.ts

Call each page's tools before listing the next page: listTools replaces the SDK's cached outputSchema validators. Keep the full list for the checks that depend on the total tool count.

formatMcpFindings prints every finding at warn or error as text, the worst first, and an empty string when there is none. A failing test shows each finding's rule, tool, message and fix instead of a JSON diff:

warn codex/structured-content-replaces-text search_orders at /structuredContent
  When Codex calls MCP tools directly (…), it sends the model only `structuredContent` as JSON, …
  fix: Put everything the model needs in `structuredContent`, or make the text content the same JSON.
  source: https://github.com/openai/codex/…
text

Fail on warn, not only on error. No check of an answer is an error, because the client still gets the answer, so a test that fails only on errors checks no answer at all. Pass { severity: "info" } to print info too.

FunctionReturns
checkMcpToolList(list)The Diagnostic Codes, one per code and tool.
checkMcpClientLimits(list)The client findings behind them, each with the client, the rule, a message, a fix and its source.
checkMcpToolResult(result, { tool })What each client does with one tools/call result.
checkMcpAnswer(call, { tool, tools })One entry of a report's answers: size, causes, advice and client findings.
mcpReport(session)What is-mcp-ok --json prints, without source and endpoint.
fetchMcpToolList(url)initialize and every page of tools/list over Streamable HTTP.
mcpDocsUrl(code)The link to a code on the reference page.

Pass clients: ["claude-code", "vscode"] to check only the clients you support, and codes to checkMcpToolList to report only some codes. formatMcpFindings also takes what checkMcpToolList returns, one checkMcpAnswer, or a whole mcpReport.