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

MCP Eval

MCP Server

mcp-eval

一个基于Node.js的包和GitHub Action,用于通过LLM评分评估MCP工具实现,具有内置的可观察性支持,确保MCP服务器的工具正确运行、性能良好且完全可观察。

工具数

0

提示词数

0

GitHub Stars

128

资源数

0
TypeScriptClaude开发工具Claude

安装说明

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

作者 / 组织

mclenhard

提供方

mclenhard

最后核验

2026/5/17 20:20

运行时

Node.js

快速接入

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

命令预览

npx mcp-eval path/to/your/evals.ts path/to/your/server.ts

详细介绍

MCP评估

一个Node.js包和GitHub Action,用于使用基于LLM的评分来评估MCP(模型上下文协议)工具实现, 内置可观测性支持这有助于确保您的MCP服务器的工具正常工作,性能良好,并且可以通过集成监控和指标完全观察到。

安装

作为Node.js包

npm install mcp-evals

作为GitHub行动

将以下内容添加到工作流文件中:

name: Run MCP Evaluations
on:
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  evaluate:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
      
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          
      - name: Install dependencies
        run: npm install
        
      - name: Run MCP Evaluations
        uses: mclenhard/mcp-evals@v1.0.9
        with:
          evals_path: 'src/evals/evals.ts'    # Can also use .yaml files
          server_path: 'src/index.ts'
          openai_api_key: ${{ secrets.OPENAI_API_KEY }}
          model: 'gpt-4'  # Optional, defaults to gpt-4

用法--评估

1.创建评估文件

您可以使用TypeScript或YAML格式创建评估配置。

选项A:TypeScript配置

创建文件(例如。, evals.ts)导出您的评估配置:

import { EvalConfig } from 'mcp-evals';
import { openai } from "@ai-sdk/openai";
import { grade, EvalFunction} from "mcp-evals";

const weatherEval: EvalFunction = {
    name: 'Weather Tool Evaluation',
    description: 'Evaluates the accuracy and completeness of weather information retrieval',
    run: async () => {
      const result = await grade(openai("gpt-4"), "What is the weather in New York?");
      return JSON.parse(result);
    }
};
const config: EvalConfig = {
    model: openai("gpt-4"),
    evals: [weatherEval]
  };
  
  export default config;
  
  export const evals = [
    weatherEval,
    // add other evals here
]; 

选项B:YAML配置

为了更简单的配置,您可以使用YAML格式(例如。, evals.yaml):

# Model configuration
model:
  provider: openai     # 'openai' or 'anthropic'
  name: gpt-4o        # Model name
  # api_key: sk-...   # Optional, uses OPENAI_API_KEY env var by default

# List of evaluations to run
evals:
  - name: weather_query_basic
    description: Test basic weather information retrieval
    prompt: "What is the current weather in San Francisco?"
    expected_result: "Should return current weather data for San Francisco including temperature, conditions, etc."

  - name: weather_forecast
    description: Test weather forecast functionality
    prompt: "Can you give me the 3-day weather forecast for Seattle?"
    expected_result: "Should return a multi-day forecast for Seattle"

  - name: invalid_location
    description: Test handling of invalid location requests
    prompt: "What's the weather in Atlantis?"
    expected_result: "Should handle invalid location gracefully with appropriate error message"

2.运行评估

作为Node.js包

您可以使用带有TypeScript或YAML文件的CLI运行评估:

# Using TypeScript configuration
npx mcp-eval path/to/your/evals.ts path/to/your/server.ts

# Using YAML configuration
npx mcp-eval path/to/your/evals.yaml path/to/your/server.ts

作为GitHub行动

该操作将自动:

  1. 运行您的评估
  2. 将结果作为评论发布在PR上
  3. 如果PR更新,请更新评论

评估结果

每次评估都会返回一个具有以下结构的对象:

interface EvalResult {
  accuracy: number;        // Score from 1-5
  completeness: number;    // Score from 1-5
  relevance: number;       // Score from 1-5
  clarity: number;         // Score from 1-5
  reasoning: number;       // Score from 1-5
  overall_comments: string; // Summary of strengths and weaknesses
}

配置

环境变量

  • OPENAI_API_KEY:您的OpenAI API密钥(对于OpenAI模型是必需的)
  • ANTHROPIC_API_KEY:您的Anthropic API密钥(Anthroptic模型需要)
\[!注意\] 如果您将此GitHub Action与开源软件一起使用,请在OpenAI计费仪表板中启用数据共享,每天免费领取250万个GPT-40迷你代币,使此Action有效地免费使用。

评估配置

TypeScript配置

EvalConfig 接口要求:

  • model:用于评估的语言模型(例如GPT-4)
  • evals:要运行的评估函数数组

每个评估功能都必须实现:

  • name:评估名称
  • description:评估测试内容的描述
  • run:异步函数,接受模型并返回 EvalResult

YAML配置

YAML配置文件支持:

型号配置:

  • provider:要么是“openai”,要么是“anthropic”
  • name:型号名称(例如,“gpt-4o”、“claude-3-opus-20240229”)
  • api_key:可选API键(默认情况下使用环境变量)

评估配置:

  • name:评估名称(必填)
  • description:评估测试的描述(必填)
  • prompt:发送到MCP服务器的提示(必填)
  • expected_result:预期行为的可选描述

支持的文件扩展名: .yaml, .yml

用途--监控

注: 度量功能仍处于alpha阶段。功能和API可能会发生变化,也可能发生重大变化。
  1. 在启动MCP服务器之前,将以下内容添加到您的应用程序中。
import { metrics } from 'mcp-evals';
metrics.initialize(9090, { enableTracing: true, otelEndpoint: 'http://localhost:4318/v1/traces' });
  1. 启动监控堆栈:
docker-compose up -d
  1. 运行MCP服务器,它将自动连接到监控堆栈。

访问仪表板

  • 普罗米修斯: http://localhost:9090
  • 格拉法纳: http://localhost:3000(用户名:admin,密码:admin)
  • Jaeger用户界面: http://localhost:16686

可用指标

  • 工具调用:按工具名称列出的工具调用次数
  • 工具错误:按工具名称列出的错误数
  • 工具延迟:按工具名称列出的延迟时间分布

许可证

麻省理工学院

目录标签

目录标签

TypeScriptClaude开发工具MCP评估本地部署LLM评分可观察性GitHubActionNode.js包

支持客户端

Claude

接入字段

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

stdio

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

none

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

mcp-eval

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

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

0

权限和风险

stdionone部署方式未说明

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

安装前确认

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

来源信息

继续浏览同类 MCP