MCP 审计员
](https://www.npmjs.com/package/mcp-auditor) ](https://www.npmjs.com/package/mcp-auditor) 
一个用于审计与MCP(模型上下文协议)服务器所有交互的TypeScript工具。它通过透明代理方法拦截并记录来自MCP服务器的所有输入/输出操作,生成全面的审计日志,以帮助开发人员调试、监控MCP应用程序并确保其合规性。
快速链接
特点/特性
- ✅ 包装MCP服务器 - 作为客户端连接到现有的MCP服务器
- ✅ 展示所有功能 - 暴露封装服务器中的所有工具、资源和提示
- ✅ 代理功能 - 透明地转发所有MCP操作
- ✅ 全面日志记录 - 记录所有输入/输出交互(工具、资源、提示)
- ✅ 多种日志格式 - 结构化(详细)或JSON-RPC(协议消息)
- ✅ Stdio 传输(或“标准I/O传输”,具体翻译可能根据上下文有所调整) - 作为一个独立的MCP服务器运行,支持stdio通信
快速入门
安装
作为库(推荐):
npm install mcp-auditor来源:
git clone https://github.com/algovate/mcp-auditor.git
cd mcp-auditor
npm install
npm run build作为一个全球性的命令行界面(CLI):
npm install -g mcp-auditor作为服务器运行
使用全局CLI(在...之后 npm install -g mcp-auditor):
# Set environment variables
export MCP_WRAPPED_SERVER_COMMAND=npx
export MCP_WRAPPED_SERVER_ARGS="-y,@modelcontextprotocol/server-filesystem,/tmp"
export MCP_LOG_FILE=./logs/mcp-server.log
# Run the server
mcp-auditor使用配置文件:
# Create config.json
cat > config.json << EOF
{
"name": "mcp-auditor-server",
"version": "1.0.0",
"wrappedServer": {
"serverCommand": "npx",
"serverArgs": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
"logFilePath": "./logs/mcp-server.log"
}
}
EOF
# Run with config
export MCP_CONFIG_FILE=./config.json
mcp-auditor来源:
# Configure environment variables
export MCP_WRAPPED_SERVER_COMMAND=npx
export MCP_WRAPPED_SERVER_ARGS="-y,@modelcontextprotocol/server-filesystem,/tmp"
export MCP_LOG_FILE=./logs/mcp-server.log
# Start the server
npm start作为库使用
import { MCPWrapper } from 'mcp-auditor';
const wrapper = new MCPWrapper({
serverCommand: 'npx',
serverArgs: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp'],
logFilePath: './logs/mcp-wrapper.log'
});
await wrapper.connect();
const tools = wrapper.getTools();
const result = await wrapper.callTool('read_file', { path: '/tmp/example.txt' });
await wrapper.disconnect();文档
如需全面的文档,请参阅:
项目结构
mcp-auditor/
├── src/
│ ├── core/ # Core wrapper functionality
│ │ ├── wrapper.ts # Main MCPWrapper class
│ │ ├── logger.ts # Logger implementation
│ │ └── types.ts # TypeScript types
│ ├── server/ # Server-specific code
│ │ ├── server.ts # MCP server implementation
│ │ └── config.ts # Configuration loader
│ └── index.ts # Main entry point
├── examples/
│ ├── library/ # Library usage examples
│ └── server/ # Server usage examples
├── docs/ # Documentation
├── dist/ # Compiled output
└── logs/ # Log files许可证
麻省理工学院(MIT)
______________________________________________________________________
如需详细的使用说明、API文档和示例,请参阅 完整的文档。
