Cover image
Try Now
2025-01-02

Der MCP -Test Client ist ein TypeScript -Test -Dienstprogramm für Model Context Protocol (MCP) -Server.

3 years

Works with Finder

3

Github Watches

1

Github Forks

9

Github Stars

MCP Test Client

A testing utility for Model Context Protocol (MCP) servers. This client helps you test MCP server implementations by providing a simple interface for making tool calls and validating responses.

Features

  • Easy-to-use testing interface for MCP servers
  • Built-in support for tool listing and tool calls
  • Type-safe implementation using TypeScript
  • Assertion utilities for validating server responses
  • Mock calculator server implementation for examples

Installation

bun install mcp-test-client

Usage

Basic Example

import { MCPTestClient } from 'mcp-test-client';

describe('MCP Server Tests', () => {
  let client: MCPTestClient;

  beforeAll(async () => {
    client = new MCPTestClient({
      serverCommand: 'bun',
      serverArgs: ['./path/to/your/server.ts'],
    });
    await client.init();
  });

  afterAll(async () => {
    await client.cleanup();
  });

  test('should list available tools', async () => {
    const tools = await client.listTools();
    expect(tools).toContainEqual(
      expect.objectContaining({
        name: 'your-tool-name',
        description: 'Your tool description',
      })
    );
  });

  test('should call a tool', async () => {
    await client.assertToolCall(
      'your-tool-name',
      { arg1: 'value1', arg2: 'value2' },
      (result) => {
        expect(result.content[0].text).toBe('expected result');
      }
    );
  });
});

Calculator Server Example

The package includes a mock calculator server for testing and learning purposes:

import { MCPTestClient } from 'mcp-test-client';

describe('Calculator Server Tests', () => {
  let client: MCPTestClient;

  beforeAll(async () => {
    client = new MCPTestClient({
      serverCommand: 'bun',
      serverArgs: ['./tests/mocks/calculator.ts'],
    });
    await client.init();
  });

  afterAll(async () => {
    await client.cleanup();
  });

  test('should perform addition', async () => {
    await client.assertToolCall(
      'calculate',
      { operation: 'add', a: 5, b: 3 },
      (result) => {
        expect(result.content[0].text).toBe('8');
      }
    );
  });
});

API Reference

MCPTestClient

Constructor

constructor(config: { serverCommand: string; serverArgs: string[] })

Methods

  • init(): Promise<void> - Initialize the client and connect to the server
  • listTools(): Promise<Tool[]> - Get a list of available tools from the server
  • callTool(toolName: string, args: Record<string, unknown>): Promise<ToolResult> - Call a specific tool
  • assertToolCall(toolName: string, args: Record<string, unknown>, assertion: (result: ToolResult) => void | Promise<void>): Promise<void> - Call a tool and run assertions on the result
  • cleanup(): Promise<void> - Clean up resources and disconnect from the server

Development

Prerequisites

  • Bun (v1.0.0 or higher)

Setup

  1. Clone the repository
git clone <repository-url>
cd mcp-test-client
  1. Install dependencies
bun install
  1. Run tests
bun test

License

MIT

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Khalid kalib
  • Write professional emails

  • XLwebDev.com
  • PR Professional: Guiding You to Get Media Placements and Publicity Quickly and Effectively

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • apappascs
  • Entdecken Sie die umfassendste und aktuellste Sammlung von MCP-Servern auf dem Markt. Dieses Repository dient als zentraler Hub und bietet einen umfangreichen Katalog von Open-Source- und Proprietary MCP-Servern mit Funktionen, Dokumentationslinks und Mitwirkenden.

  • OffchainLabs
  • GO -Umsetzung des Ethereum -Beweises des Anteils

  • huahuayu
  • Ein einheitliches API-Gateway zur Integration mehrerer Ethercan-ähnlicher Blockchain-Explorer-APIs mit Modellkontextprotokoll (MCP) für AI-Assistenten.

  • deemkeen
  • Steuern Sie Ihren MBOT2 mit einer Power Combo: MQTT+MCP+LLM

    Reviews

    3 (1)
    Avatar
    user_zaogvRkv
    2025-04-15

    The Stay AI API MCP Server by mattcoatsworth is a game changer for developers looking to integrate AI capabilities seamlessly. It’s incredibly user-friendly, robust, and handles large data sets efficiently. I highly recommend it for anyone in need of a reliable server for AI projects. Check it out!