MCP服务器检查工具

Syrin是一个用于MCP服务器的静态分析和测试工具,帮助开发者发现和修复工具定义中的问题。

  • by syrin-labs
  • TypeScript
  • 本地部署
  • 48 星标
  • 更新于
在 GitHub 查看 ankan-labs/syrin

使用说明

叙利亚

MCP服务器的linter+测试运行器。


问题

MCP(模型上下文协议) AI代理如何调用外部工具——读取文件、查询数据库、点击API。如果你正在构建或使用MCP服务器,你的AI代理取决于这些工具定义是否正确。

他们通常不是。

  • 工具描述过于模糊,LLM无法选择正确的工具
  • 两个工具看起来如此相似,以至于模型随机选择了一个
  • 参数模式缺失或错误——LLM产生幻觉值
  • 一个工具返回12MB的JSON并弹出上下文窗口
  • 另一个工具在不应该写入磁盘时会自动写入磁盘
  • 你的原木看起来很好。代理人坏了。

Syrin在生产前捕获了所有这些。

$ syrin analyse --transport http --url http://localhost:8000/mcp

 E110  Tool Ambiguity           get_user ↔ fetch_user
 E101  Missing Tool Description process_data has no description
 E102  Underspecified Input     user_id: no format, no example, no enum
 E105  Free Text Propagation    get_status → update_user (unconstrained string)
 W104  Generic Description      "Get data" — too vague for tool selection

 5 issues found (4 errors, 1 warning)

在行动中看到它


马上试试

一个命令。没有安装,没有配置,没有API密钥:

npx @syrin/cli analyse --transport http --url https://docs.syrin.dev/mcp

您自己的MCP服务器正在运行吗?指向Syrin:

npx @syrin/cli analyse --transport http --url http://localhost:8000/mcp

如果您的服务器使用stdio而不是HTTP:

npx @syrin/cli analyse --transport stdio --script "python server.py"

想对本地示例服务器尝试更多命令吗?

git clone https://github.com/Syrin-Labs/cli.git
cd cli/examples/demo-mcp-py
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python server.py --mode http --port 8000 &

npx @syrin/cli list tools --transport http --url http://localhost:8000/mcp
npx @syrin/cli analyse --transport http --url http://localhost:8000/mcp

要求: Node.js>=20.12,npm>=9


Syrin捕获了什么

代码 问题 没有Syrin会发生什么
E110 刀具歧义 LLM随机选择错误的刀具
E101 缺少描述 LLM不知道该工具的功能
E102 未指定的输入 LLM产生参数值幻觉
E105 自由文本传播 LLM传递需要数据的句子
E103 类型不匹配 工具链无声断裂
E107 循环依赖 代理永远循环,燃烧令牌
E301 输出爆炸 12MB响应吹出上下文窗口
E500 检测到副作用 工具在不应写入磁盘时写入磁盘

查看完整列表: 错误参考 · 警告参考


命令

命令 它做什么
syrin list 显示服务器公开的工具、资源和提示
syrin analyse 静态分析——在不执行工具的情况下捕获合约问题
syrin test 在沙箱中运行工具,并根据合同验证行为
syrin dev 交互式会话——观看LLM与您的工具实时交互
syrin doctor 验证您的配置、环境和连接

零配置命令: list, analyse,以及 test --connection 与just合作 --url 或 --script。不需要配置文件。

需要配置: dev 模式需要LLM API密钥。跑 syrin init --global 设置一次。


所有Demos

syrin analyse
Catch contract issues
syrin dev
Interactive development
syrin test
Sandboxed tool testing
syrin init
Project setup
syrin list
Inspect tools
syrin test --connection
Connection test

安装

# Run without installing
npx @syrin/cli analyse --transport http --url http://localhost:8000/mcp

# Or install globally
npm install -g @syrin/cli
syrin --version

为项目设置

syrin init                 # Creates syrin.yaml + tools/ directory
syrin doctor               # Validates config and connections
syrin analyse              # Analyse your MCP server
syrin test                 # Run contract tests
syrin dev --exec           # Interactive LLM-MCP session

工具合同

为您的工具定义行为保证 tools/<tool-name>.yaml:

version: 1
tool: fetch_user

contract:
  input_schema: FetchUserRequest
  output_schema: User

guarantees:
  side_effects: none
  max_output_size: 10kb

tests:
  - name: 'valid user'
    input:
      user_id: '123'
    expect:
      output_schema: User

  - name: 'invalid input'
    input:
      user_id: 123
    expect:
      error:
        type: input_validation

运行测试: syrin test 或 syrin test --tool fetch_user

文档: 编写测试用例 · 测试您的MCP工具


CI集成

# .github/workflows/syrin.yml
name: MCP Validation
on: [push, pull_request]
jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm install -g @syrin/cli
      - run: syrin analyse --ci
      - run: syrin test --ci --strict

查看完整的CI文档: 将Syrin添加到CI


文档

完整文档请访问 docs.syrin.dev

主题 链接
入门指南 docs.syrin.dev/getting开始
安装指南 docs.syrin.dev/setup
配置 docs.syrin.dev/configuration
所有命令 docs.syrin.dev/commands
错误参考 docs.syrin.dev/testing-error-reference

社区


贡献

欢迎捐款。看 贡献指南 和 行为准则.

关于安全问题: 安全策略.

许可证

ISC许可证。看 许可证.

由……制造 Syrin实验室.