MCP路由器

一个安全的企业级MCP服务器聚合平台,用于集中管理多个MCP服务器并提供访问控制、审批工作流和审计日志等功能。

  • by justinpreston
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 justinpreston/mcp-router

使用说明

MCP路由器

使用Electron构建的安全的企业级模型上下文协议(MCP)服务器聚合平台。

概述

MCP路由器充当管理多个MCP服务器的集中式网关,提供:

  • 服务器聚合:从单个界面连接和管理多个MCP服务器
  • 基于策略的访问控制:对工具和资源访问进行细粒度控制
  • 令牌身份验证:具有作用域和过期的安全API令牌管理
  • 审批工作流:敏感操作的人工审批
  • 速率限制:通过可配置的速率限制防止滥用
  • 审计日志:完成所有业务的审计跟踪

建筑

┌─────────────────────────────────────────────────────────────────┐
│                        MCP Router                                │
├─────────────────────────────────────────────────────────────────┤
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐              │
│  │   Clients   │  │   Policy    │  │  Approval   │              │
│  │  (Claude,   │──│   Engine    │──│   Queue     │              │
│  │   etc.)     │  │             │  │             │              │
│  └─────────────┘  └─────────────┘  └─────────────┘              │
│         │                │                │                      │
│         ▼                ▼                ▼                      │
│  ┌─────────────────────────────────────────────────────────┐    │
│  │                   MCP Aggregator                         │    │
│  │  - Tool routing    - Resource proxying    - Audit log   │    │
│  └─────────────────────────────────────────────────────────┘    │
│         │                │                │                      │
│         ▼                ▼                ▼                      │
│  ┌───────────┐    ┌───────────┐    ┌───────────┐                │
│  │ MCP Server│    │ MCP Server│    │ MCP Server│                │
│  │     A     │    │     B     │    │     C     │                │
│  └───────────┘    └───────────┘    └───────────┘                │
└─────────────────────────────────────────────────────────────────┘

特性

服务器管理

  • 支持stdio和HTTP传输协议
  • 自动服务器健康监控
  • 工具和资源发现
  • 每台服务器配置

安全

  • 具有作用域的基于令牌的身份验证
  • 具有全局模式匹配的策略规则
  • 每个客户端/令牌的速率限制
  • 通过系统密钥链实现安全的凭证存储

策略引擎

  • 全局、特定于客户端和特定于服务器的策略
  • 允许、拒绝和要求批准操作
  • 基于优先级的规则评估
  • 通配符模式匹配

审批系统

  • 实时审批通知
  • 可配置的超时和过期
  • 所有决策的审计跟踪

快速开始

先决条件

  • Node.js 20+
  • pnpm 9+

安装

# Clone the repository
git clone https://github.com/your-org/mcp-router.git
cd mcp-router

# Install dependencies
pnpm install

# Start development server
pnpm dev

建筑

# Build for production
pnpm build

# Package for distribution
pnpm package

项目结构

mcp-router/
├── apps/
│   └── desktop/                 # Electron desktop application
│       ├── src/
│       │   ├── main/           # Main process (Node.js)
│       │   │   ├── core/       # DI container, types, interfaces
│       │   │   ├── services/   # Business logic services
│       │   │   ├── repositories/ # Data access layer
│       │   │   └── ipc/        # IPC handlers
│       │   ├── preload/        # Preload scripts (context bridge)
│       │   └── renderer/       # React UI
│       │       ├── components/ # Reusable UI components
│       │       ├── features/   # Feature modules
│       │       ├── hooks/      # Custom React hooks
│       │       └── stores/     # Zustand state stores
│       └── tests/              # Test files
├── docs/                       # Documentation
│   ├── adr/                   # Architecture Decision Records
│   ├── api/                   # API documentation
│   └── guides/                # User and developer guides
└── packages/                   # Shared packages (future)

技术栈

层 技术
框架 电子28
UI React 18+TypeScript
造型 顺风CSS+shadcn/ui
状态 状态
DI InversifyJS
数据库 SQLite(better-splite3)
构建 电子vite+vite
测试 Vitest+剧作家

文档

脚本

命令 描述
pnpm dev 启动开发服务器
pnpm build 为生产而建
pnpm test 运行单元测试
pnpm test:watch 在监视模式下运行测试
pnpm lint 运行ESLint
pnpm lint:fix 修复掉毛问题
pnpm typecheck 运行TypeScript类型检查

贡献

  1. 克隆该仓库
  2. 创建要素分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

许可证

MIT许可证-请参阅 许可证 了解详情。