用途
MCP Inspector Integration 用于为 MCP 服务器搭建 MCP Inspector 调试与测试环境。当需要调试 MCP 服务器通信、测试工具与资源处理器、检查协议消息或验证 MCP 实现时,可以调用该技能。
主要能力
- 配置 MCP Inspector 连接
- 设置请求/响应日志
- 实现协议调试
- 创建测试场景
- 生成检查报告
- 配置开发工作流
使用方式
该技能接受以下输入参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| serverPath | string | 是 | MCP 服务器入口路径 |
| transport | string | 否 | 传输类型(stdio、sse) |
| logging | boolean | 否 | 启用详细日志 |
工作流程为:安装 Inspector、配置连接(服务器路径与参数)、启用日志、创建测试场景、运行检查、生成报告。
生成模式
技能会生成以下类型的配置与代码:
Inspector 配置
{
"mcpServers": {
"my-server": {
"command": "node",
"args": ["dist/index.js"],
"env": {
"DEBUG": "mcp:*",
"NODE_ENV": "development"
}
}
}
}
调试包装脚本
#!/usr/bin/env node
import { createServer } from './server';
// Enable debug logging
process.env.DEBUG = 'mcp:*';
// Log all stdin/stdout for debugging
const originalWrite = process.stdout.write.bind(process.stdout);
process.stdout.write = (chunk: any, ...args: any[]) => {
if (process.env.MCP_DEBUG_LOG) {
const fs = require('fs');
fs.appendFileSync(
process.env.MCP_DEBUG_LOG,
`[OUT] ${new Date().toISOString()} ${chunk}\n`
);
}
return originalWrite(chunk, ...args);
};
process.stdin.on('data', (chunk) => {
if (process.env.MCP_DEBUG_LOG) {
const fs = require('fs');
fs.appendFileSync(
process.env.MCP_DEBUG_LOG,
`[IN] ${new Date().toISOString()} ${chunk}\n`
);
}
});
// Start server
createServer();
NPM 开发脚本
{
"scripts": {
"dev": "tsx watch src/index.ts",
"debug": "MCP_DEBUG_LOG=./debug.log tsx src/index.ts",
"inspect": "npx @anthropic/mcp-inspector node dist/index.js",
"test:mcp": "npx @anthropic/mcp-inspector --test node dist/index.js"
}
}
测试场景
// tests/mcp-scenarios.ts
export const testScenarios = [
{
name: 'List Tools',
request: {
jsonrpc: '2.0',
method: 'tools/list',
id: 1,
},
validate: (response: any) => {
return response.result?.tools?.length > 0;
},
},
{
name: 'Call Tool - search_files',
request: {
jsonrpc: '2.0',
method: 'tools/call',
params: {
name: 'search_files',
arguments: { pattern: '*.ts', path: './src' },
},
id: 2,
},
validate: (response: any) => {
return !response.error && response.result?.content;
},
},
{
name: 'List Resources',
request: {
jsonrpc: '2.0',
method: 'resources/list',
id: 3,
},
validate: (response: any) => {
return Array.isArray(response.result?.resources);
},
},
];
// Run test scenarios
export async function runScenarios(
send: (msg: any) => Promise<any>
): Promise<void> {
for (const scenario of testScenarios) {
console.log(`Testing: ${scenario.name}`);
const response = await send(scenario.request);
const passed = scenario.validate(response);
console.log(` ${passed ? '✓ PASS' : '✗ FAIL'}`);
if (!passed) {
console.log(' Response:', JSON.stringify(response, null, 2));
}
}
}
适用场景
- 调试 MCP 服务器通信
- 测试工具与资源处理器
- 检查协议消息
- 验证 MCP 实现
目标流程
- mcp-server-monitoring-debugging
- mcp-server-testing-suite
- mcp-tool-implementation
限制
资料未提供该技能的收费、价格、平台支持范围、性能效果等具体信息。