MCP 审计员
英语 | 中文
一个用于审计与MCP(模型上下文协议)服务器所有交互的TypeScript工具。它通过透明代理方法拦截并记录来自MCP服务器的所有输入/输出操作,生成全面的审计日志,以帮助开发人员调试、监控MCP应用程序并确保其合规性。
快速链接
- 📚 书籍 完整文档
- 🌏(地球) 中文文档
- 🖥️(电脑) 服务器文档
- 📝(记录/笔记) 示例
特点/特性
- ✅ 包装MCP服务器 - 作为客户端连接到现有的MCP服务器
- ✅ 展示所有功能 - 暴露封装服务器中的所有工具、资源和提示
- ✅ 代理功能 - 透明地转发所有MCP操作
- ✅ 全面日志记录 - 记录所有输入/输出交互(工具、资源、提示)
- ✅ 多种日志格式 - 结构化(详细)或JSON-RPC(协议消息)
快速入门
安装
作为库(推荐):```bash
npm install mcp-auditor
**来源:**```bash
git clone https://github.com/algovate/mcp-auditor.git
cd mcp-auditor
npm install
npm run build
作为一个全球性的命令行界面(CLI):```bash
npm install -g mcp-auditor
### 作为服务器运行
**使用全局CLI(在...之后 `npm install -g mcp-auditor`):**```bash
# 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
使用配置文件:```bash
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
**来源:**```bash
# 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
作为库使用```typescript
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文档和示例,请参阅 完整的文档。
