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

Server Tester

MCP Server

一个用于Model Context Protocol(MCP)服务器的测试和评估框架,支持Playwright测试和数据驱动的评估数据集。

工具数

0

提示词数

0

GitHub Stars

16

资源数

0
测试框架浏览器自动化TypeScriptClaude自动化测试ClaudeCursorWindsurf

安装说明

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

作者 / 组织

gleanwork

提供方

gleanwork

最后核验

2026/5/17 20:22

快速接入

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

详细介绍

@gleanwork/mcp服务器测试仪

![GA](https://github.com/gleanwork/.github/blob/main/docs/repository-stability.md#ga) ](https://www.npmjs.com/package/@gleanwork/mcp-server-tester) ![CI](https://github.com/gleanwork/mcp-server-tester/actions/workflows/ci.yml) ![License: MIT](https://opensource.org/licenses/MIT)

测试和评估框架 模型上下文协议(MCP) 服务器。针对MCP工具编写确定性Playwright测试,或运行数据驱动的eval数据集,包括基于LLM的工具可发现性评估。

剧作家测试

mcp Playwright fixture连接到MCP服务器(stdio或HTTP),并公开高级API用于调用工具和断言响应。自定义匹配器使断言可读。

import { test, expect } from '@gleanwork/mcp-server-tester/fixtures/mcp';

test('read_file returns file contents', async ({ mcp }) => {
  const result = await mcp.callTool('read_file', { path: '/tmp/test.txt' });
  expect(result).toContainToolText('Hello, world');
  expect(result).not.toBeToolError();
});

test('server exposes required tools', async ({ mcp }) => {
  const tools = await mcp.listTools();
  expect(tools.map((t) => t.name)).toContain('read_file');
});

Playwright测试快速、确定,专为CI设计。将其用于回归测试、模式验证和协议一致性。该框架包括MCP规范的内置一致性检查。

可用匹配:

匹配器描述
toMatchToolResponse响应与预期值完全匹配(深度相等)
toContainToolText响应包含预期的子字符串
toMatchToolSchema响应根据Zod模式进行验证
toMatchToolPattern响应与正则表达式模式匹配
toMatchToolSnapshot响应与保存的基线匹配
toBeToolError响应是(或不是)错误
toHaveToolResponseSize响应大小在范围内
toSatisfyToolPredicate响应满足自定义函数
toHaveToolCallsLLM调用了预期的工具
toHaveToolCallCountLLM进行了N次工具调用
toPassToolJudgeLLM根据量规评估响应质量

评估数据集

Eval数据集允许您将测试用例定义为JSON文件,并使用 runEvalDataset()每个案例都指定了一个工具调用和一个或多个断言。

{
  "name": "file-ops",
  "cases": [
    {
      "id": "read-config",
      "toolName": "read_file",
      "args": { "path": "/tmp/config.json" },
      "expect": {
        "schema": "file-content",
        "containsText": ["version", "name"]
      }
    },
    {
      "id": "read-readme",
      "toolName": "read_file",
      "args": { "path": "/tmp/README.md" },
      "expect": {
        "snapshot": "readme-snapshot"
      }
    }
  ]
}
import { test, expect } from '@gleanwork/mcp-server-tester/fixtures/mcp';
import { loadEvalDataset, runEvalDataset } from '@gleanwork/mcp-server-tester';
import { z } from 'zod';

test('file operations eval', async ({ mcp }, testInfo) => {
  const dataset = await loadEvalDataset('./data/evals.json', {
    schemas: { 'file-content': z.object({ content: z.string() }) },
  });
  const result = await runEvalDataset({ dataset }, { mcp, testInfo });
  expect(result.passed).toBe(result.total);
});

支持的断言类型:

类型描述
containsText响应包括预期的子字符串
schema响应根据Zod模式进行验证
regex响应与模式匹配
snapshot响应与保存的基线匹配
judgeLLM根据量规评估响应质量
toolsTriggeredLLM调用了预期的工具(LLM主机模式)

LLM主机模式

在LLM主机模式下,真正的LLM会收到服务器的工具列表和自然语言提示,然后决定调用哪些工具。这测试你的工具名称、描述和输入模式是否足够清晰,可以自主使用——这与工具是否返回正确的输出是一个不同的问题。

{
  "id": "find-config",
  "mode": "mcp_host",
  "scenario": "Find the application config file and return its contents",
  "mcpHostConfig": {
    "provider": "anthropic",
    "model": "claude-opus-4-20250514"
  },
  "expect": {
    "toolsTriggered": {
      "calls": [{ "name": "read_file", "required": true }]
    }
  }
}

LLM主机模式进行真正的API调用并产生不确定的结果。使用 iterations 多次运行案例并测量通过率,而不是期望单次运行100%。请参阅 LLM主持人指南 用于配置和成本管理。

安装

需要Node.js 22+。

npm install --save-dev @gleanwork/mcp-server-tester @playwright/test

Anthropic SDK仅用于LLM作为判断断言或使用Anthropics提供程序的LLM主机模式:

npm install --save-dev @anthropic-ai/sdk

快速开始

npx mcp-server-tester init

CLI向导创建 playwright.config.ts,示例测试,以及为您的服务器配置的示例eval数据集。请参阅 CLI指南 对于所有选项。

配置

将框架指向MCP服务器 playwright.config.ts:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  testDir: './tests',
  reporter: [['list'], ['@gleanwork/mcp-server-tester/reporters/mcpReporter']],
  projects: [
    {
      name: 'my-server',
      use: {
        mcpConfig: {
          transport: 'stdio',
          command: 'node',
          args: ['server.js'],
        },
      },
    },
  ],
});

对于HTTP服务器,设置 transport: 'http'serverUrl。对于需要OAuth的服务器,请参阅 交通指南CLI指南 用于身份验证设置,包括CI/CD令牌管理。

文档

人工智能技能

安装人工智能技能,帮助您的编码助手生成测试、评估数据集和MCP主机评估:

npx skills add -g gleanwork/mcp-server-tester

这将在全球范围内安装技能,以便在您的所有项目中都可以使用。包括四项技能:

技能描述
mcp-tester-guide框架参考——匹配器、配置、身份验证、反模式
write-mcp-test生成直接模式剧作家测试
write-mcp-eval生成数据驱动的评估数据集
write-mcp-host-eval生成LLM主机模拟评估

与Claude Code、Cursor、Windsurf、Copilot和 40+其他AI代理.

示例

examples/ 目录包含完整的工作示例:

已知限制

目前不支持这些MCP协议功能。这些是经过深思熟虑的范围决策,而不是bug:

  • MCP资源(listResources, readResource)
  • MCP提示(listPrompts, getPrompt)
  • 服务器到客户端通知
  • 流媒体工具响应(callTool 等待完整的响应)

如果其中任何一个影响您的用例,请打开一个问题。

许可证

麻省理工学院

目录标签

目录标签

测试框架浏览器自动化TypeScriptClaude自动化测试本地部署MCP协议PlaywrightLLM评估

支持客户端

ClaudeCursorWindsurf

接入字段

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

未说明

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

oauth

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

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

0

权限和风险

未说明oauth部署方式未说明

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

安装前确认

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

仍需确认:installCommand

来源信息

继续浏览同类 MCP