Web Analytics

mcp-rest-api

⭐ 94 stars Simplified Chinese by dkmaker

MCP REST API 测试工具

许可证: MIT NPM 包

一个基于 TypeScript 的 MCP 服务器,支持通过 Claude、Cline 及其他 MCP 客户端测试 REST API。该工具允许您直接从开发环境测试和交互任何 REST API 端点。

安装

全局安装该包:

npm install -g dkmaker-mcp-rest-api

配置

Cline 自定义指令

为了确保 Cline 理解如何有效使用此工具,请将以下内容添加到您的 Cline 自定义指令中(设置 > 自定义指令):

# REST API Testing Instructions

The test_request tool enables testing, debugging, and interacting with REST API endpoints. The tool provides comprehensive request/response information and handles authentication automatically.

When to Use

  • Testing specific API endpoints
  • Debugging API responses
  • Verifying API functionality
  • Checking response times
  • Validating request/response formats
  • Testing local development servers
  • Testing API sequences
  • Verifying error handling

Key Features

  • Supports GET, POST, PUT, DELETE, PATCH methods
  • Handles authentication (Basic, Bearer, API Key)
  • Normalizes endpoints automatically
  • Provides detailed response information
  • Configurable SSL verification and response limits

Resources

The following resources provide detailed documentation:

  • examples: Usage examples and common patterns
  • response-format: Response structure and fields
  • config: Configuration options and setup guide
Access these resources to understand usage, response formats, and configuration options.

Important Notes

  • Review API implementation for expected behavior
  • Handle sensitive data appropriately
  • Consider rate limits and API constraints
  • Restart server after configuration changes

MCP 服务器配置

虽然这些说明针对的是 Cline,但该服务器应适用于任何 MCP 实现。请根据您的操作系统进行配置:

Windows

⚠️ 重要:由于 Windows 路径解析的已知问题(问题 #40),您必须使用完整路径,而不是 %APPDATA%。

添加到 C:\Users\\AppData\Roaming\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json

{
  "mcpServers": {
    "rest-api": {
      "command": "node",
      "args": [
        "C:/Users//AppData/Roaming/npm/node_modules/dkmaker-mcp-rest-api/build/index.js"
      ],
      "env": {
        "REST_BASE_URL": "https://api.example.com",
        // Basic Auth
        "AUTH_BASIC_USERNAME": "your-username",
        "AUTH_BASIC_PASSWORD": "your-password",
        // OR Bearer Token
        "AUTH_BEARER": "your-token",
        // OR API Key
        "AUTH_APIKEY_HEADER_NAME": "X-API-Key",
        "AUTH_APIKEY_VALUE": "your-api-key",
        // SSL Verification (enabled by default)
        "REST_ENABLE_SSL_VERIFY": "false", // Set to false to disable SSL verification for self-signed certificates
        // Response Size Limit (optional, defaults to 10000 bytes)
        "REST_RESPONSE_SIZE_LIMIT": "10000", // Maximum response size in bytes
        // Custom Headers (optional)
        "HEADER_X-API-Version": "2.0",
        "HEADER_Custom-Client": "my-client",
        "HEADER_Accept": "application/json"
      }
    }
  }
}

macOS

添加到 ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
{
  "mcpServers": {
    "rest-api": {
      "command": "npx",
      "args": [
        "-y",
        "dkmaker-mcp-rest-api"
      ],
      "env": {
        "REST_BASE_URL": "https://api.example.com",
        // Basic Auth
        "AUTH_BASIC_USERNAME": "your-username",
        "AUTH_BASIC_PASSWORD": "your-password",
        // OR Bearer Token
        "AUTH_BEARER": "your-token",
        // OR API Key
        "AUTH_APIKEY_HEADER_NAME": "X-API-Key",
        "AUTH_APIKEY_VALUE": "your-api-key",
        // SSL Verification (enabled by default)
        "REST_ENABLE_SSL_VERIFY": "false", // Set to false to disable SSL verification for self-signed certificates
        // Custom Headers (optional)
        "HEADER_X-API-Version": "2.0",
        "HEADER_Custom-Client": "my-client",
        "HEADER_Accept": "application/json"
      }
    }
  }
}
注意:请将环境变量替换为您的实际值。一次只配置一种认证方式:

功能

使用示例

安装并配置完成后,您可以通过Cline使用REST API测试器测试您的API端点:

// Test a GET endpoint
use_mcp_tool('rest-api', 'test_request', {
  "method": "GET",
  "endpoint": "/users"
});

// Test a POST endpoint with body use_mcp_tool('rest-api', 'test_request', { "method": "POST", "endpoint": "/users", "body": { "name": "John Doe", "email": "john@example.com" } });

// Test with custom headers use_mcp_tool('rest-api', 'test_request', { "method": "GET", "endpoint": "/products", "headers": { "Accept-Language": "en-US", "X-Custom-Header": "custom-value" } });

开发

git clone https://github.com/zenturacp/mcp-rest-api.git
cd mcp-rest-api
npm install

npm run build
用于自动重建的开发:

npm run watch

许可证

本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件。

--- Tranlated By Open Ai Tx | Last indexed: 2026-05-06 ---