Token导航 LogoToken导航TokenDH.com
MCP Test Client logo
开发工具未说明官方级别未说明来源级核验

MCP Test Client

MCP Server

MCP Test Client is a TypeScript testing utility for Model Context Protocol (MCP) servers.

工具数

0

提示词数

0

GitHub Stars

13

资源数

0
服务器测试开发工具TypeScript

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

crazyrabbitLTC

提供方

crazyrabbitLTC

最后核验

2026/5/18 02:15

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

MCP测试客户端

模型上下文协议(MCP)服务器的测试实用程序。此客户端通过提供用于进行工具调用和验证响应的简单接口来帮助您测试MCP服务器实现。

特性

  • MCP服务器易于使用的测试界面
  • 内置对工具列表和工具调用的支持
  • 使用TypeScript实现类型安全
  • 用于验证服务器响应的断言实用程序
  • 模拟计算器服务器实现示例

安装

bun install mcp-test-client

用法

基础示例

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');
      }
    );
  });
});

计算器服务器示例

该软件包包括一个用于测试和学习目的的模拟计算器服务器:

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参考

MCPTestClient

构造函数

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

方法

  • init(): Promise -初始化客户端并连接到服务器
  • listTools(): Promise -从服务器获取可用工具列表
  • callTool(toolName: string, args: Record): Promise -调用特定工具
  • assertToolCall(toolName: string, args: Record, assertion: (result: ToolResult) => void | Promise): Promise -调用工具并对结果运行断言
  • cleanup(): Promise -清理资源并断开与服务器的连接

发展

先决条件

  • 包子 (v1.0.0或更高版本)

设置

  1. 克隆存储库
git clone 
cd mcp-test-client
  1. 安装依赖项
bun install
  1. 运行测试
bun test

许可证

麻省理工学院

贡献

  1. 分叉存储库
  2. 创建功能分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add some amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

目录标签

目录标签

服务器测试开发工具TypeScriptdeveloper-toolsmcp-test-clienttesting-utilityMCP协议测试本地部署TypeScript工具

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP