MCP服务器测试工具

一款用于测试MCP服务器的客户端工具,提供命令行界面和交互式Web UI。

  • by agentic-forge
  • HTML
  • 本地部署
  • 更新于
在 GitHub 查看 agentic-forge/forge-anvil

使用说明

锻造铁砧

用于测试MCP服务器的MCP客户端工具。

特性

  • CLI接口 -从命令行测试MCP服务器
  • 网页用户界面 -基于浏览器的交互式检查器
  • 无构建步骤 -Web UI是一个使用Vue.js的HTML文件

安装

# Clone the repository
git clone https://github.com/agentic-forge/forge-anvil.git
cd forge-anvil

# Install dependencies
uv sync

CLI使用情况

# Show server info
anvil info --server http://localhost:8000/mcp

# List available tools
anvil list-tools

# Call a tool
anvil call get_current_weather --arg city=Berlin

# Call with JSON arguments
anvil call get_forecast --json-args '{"city": "Tokyo", "days": 3}'

# Output as JSON
anvil list-tools --json

# List resources and prompts
anvil list-resources
anvil list-prompts

# Check if server is responsive
anvil ping

环境变量

集 ANVIL_SERVER 避免超车 --server 每一次:

export ANVIL_SERVER=http://localhost:8000/mcp
anvil list-tools

自定义头

一些MCP服务器需要自定义HTTP头(例如,API密钥、数据库ID)。使用 --header / -H 选项:

# Single header
anvil call get_user --header "x-database-id: db_123" --arg user_id=USER_001

# Multiple headers
anvil list-tools -H "x-api-key: secret" -H "x-org-id: org_456"

# Combined with other options
anvil call my_tool \
  --server https://example.com/mcp \
  --header "Authorization: Bearer token123" \
  --json-args '{"query": "test"}'

这 --header 选项在所有命令上都可用: info, list-tools, call, list-resources, list-prompts,以及 ping.

网页用户界面

启动交互式检查器:

anvil ui --port 5000

打开http://localhost:5000在您的浏览器中。

Web UI功能

  • 服务器连接 -连接到任何MCP服务器URL
  • 自定义头 -展开“自定义头”部分以添加头(对API键、数据库ID等有用)
  • 工具选项卡 -浏览工具,用动态表单填写参数,并调用工具
  • 资源/提示选项卡 -查看可用资源和提示
  • 服务器信息选项卡 -查看服务器功能和元数据
  • 调试面板 -检查原始JSON请求和响应

与Forge MCP服务器一起使用

Anvil旨在与任何MCP服务器配合使用,但与使用FastMCP构建的Forge MCP服务器无缝集成。

示例:测试mcp天气

终端1-启动MCP服务器:

cd /path/to/agentic-forge/mcp-servers/mcp-weather
uv sync
uv run python -m forge_mcp_weather
# Server starts at http://localhost:8000/mcp

终端2-使用Anvil进行测试:

cd /path/to/agentic-forge/forge-anvil

# Set the server URL (optional, this is the default)
export ANVIL_SERVER=http://localhost:8000/mcp

# Check server info
anvil info

# List available tools
anvil list-tools

# Get current weather
anvil call get_current_weather --arg city=Berlin

# Get weather with imperial units
anvil call get_current_weather --arg city="New York" --arg units=imperial

# Get 5-day forecast
anvil call get_forecast --json-args '{"city": "Tokyo", "days": 5}'

# Get air quality
anvil call get_air_quality --arg city=Beijing

# Geocode a city
anvil call geocode --arg city=London --arg country=UK

在Forge服务器上使用Web UI

# Start the MCP server (Terminal 1)
cd /path/to/mcp-weather
uv run python -m forge_mcp_weather

# Launch Anvil UI (Terminal 2)
cd /path/to/forge-anvil
anvil ui

# Browser opens automatically at http://localhost:5000
# The UI connects to http://localhost:8000/mcp by default

其他Forge MCP服务器

Anvil可以按照相同的模式与任何Forge MCP服务器一起工作:

# Start any Forge MCP server
uv run python -m forge_mcp_<server_name>

# Test with Anvil
anvil list-tools --server http://localhost:8000/mcp

发展

# Install dev dependencies
uv sync --group dev

# Run tests
uv run pytest

# Run tests with coverage
uv run pytest --cov

# Type checking
uv run basedpyright

# Linting
uv run ruff check .

# Install pre-commit hooks
uv run pre-commit install

许可证

麻省理工学院