mcpField
M
mcp-therapy

mcp-therapy

Local
github.com/thoughtspotDeveloper Tools14Updated 77w ago

About mcp-therapy

mcp-testing-kit is a TypeScript library for testing MCP servers. It connects directly to server instances through a dummy transport, without relying on HTTP/SSE.

Key features

  1. 01Works with Vitest, Jest, and other frameworks
  2. 02Connects directly to MCP server instances
  3. 03Invokes tools, resources, and prompts
  4. 04Listens for notifications, errors, and progress
  5. 05Sends raw JSON-RPC requests

Use cases

  1. 01Check which tools and resources a server registers
  2. 02Verify tool calls and prompt results
  3. 03Test notification, error, and progress messages

MCP support

The library tests MCP servers by connecting to instances and invoking their tools, resources, and prompts. It also exposes callbacks for notifications, errors, and progress.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

mcp-testing-kit
Coverage Status NPM Version

The testing library you need to test your MCP servers.

Overview

mcp-testing-kit provides utilities to test Model Context Protocol (MCP) servers. It allows you to connect to an MCP server instance, send requests, receive notifications, and assert server behavior in your tests.

Features

  • Works with any testing framework (vitest, jest etc)
  • Lightweight, provides "just enough" utils to test an MCP server.
  • Typescript

Installation

$ npm i -D mcp-testing-kit

Example

Suppose you have an MCP server defined in example/basic/src/index.ts:

// mcp-server.ts
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";

const server = new McpServer({ name: 'simple-mcp-server', version: '1.0.0' });

server.tool(
  'add',
  'Add two numbers MCP style',
  { 
    a: z.number().describe('first number'), 
    b: z.number().describe('second number') 
  },
  async ({ name }) => ({
    messages: [
      { role: 'user', content: { type: 'text', text: String(a + b) } }
    ]
  })
);

export default server;

You can write a test using mcp-testing-kit like this:

// mcp-server.test.js
import server from "../src/index.js";
// Use your favorite testing framework.
import { describe, it, expect, afterEach } from "vitest";
import { connect, close } from "../../../index.js";

describe("Basic MCP server", () => {
  afterEach(async () => {
    await close(server);
  });

  it("Should return correct sum when `sum` is called", async () => {
    // Connect to the server and create a mock client.
    const client = await connect(server);
    const result = await client.callTool("greeting-template", { a: 10, b: 2 });
    expect(result.content[0].text).toEqual("12");
  });
});

How it works

  • Creates a dummy transport layer to connect to the MCP Server directly instead of relying on HTTP/SSE.
  • Provides abstractions for invoking the tools/resources/prompts directly on the server.

API

connect(server: Server)

Connects to an MCP server instance and returns a client with the following methods:

MethodSignatureDescription
listTools(): Promise<ListToolsResult>List all tools registered on the server.
callTool(tool: string, params?: any): Promise<any>Call a tool by name with optional parameters.
listResources(): Promise<ListResourcesResult>List all resources registered on the server.
listPrompts(): Promise<ListPromptsResult>List all prompts registered on the server.
getPrompt(prompt: string, params?: any): Promise<any>Get a prompt by name with optional parameters.
onNotification(cb: (message: JSONRPCMessage) => void): voidRegister a callback for notifications from the server.
onError(cb: (message: JSONRPCMessage) => void): voidRegister a callback for error messages from the server.
onProgress(cb: (message: JSONRPCMessage) => void): voidRegister a callback for progress notifications from the server.
sendToServer(message: Request): Promise<any>Send a raw JSON-RPC request to the server.
close(server: Server)

Closes the MCP server instance.

More Examples

See example/basic for a full-featured MCP server and corresponding tests.

License

MIT

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.