阿尔萨尼亚MCP🌐
具有动态代理、多传输支持和AI到AI通信功能的通用模型上下文协议(MCP)服务器
  
✨ 特性
- 🔄 通用MCP代理 -充当AI系统和MCP服务器之间的双向网关
- 🌍 多运输支持 -STDIO、HTTP/SSE和流式HTTP传输
- 🎯 动态工具注册表 -按需从多个服务器加载/卸载工具
- 🔌 HTTP网关 -RESTful API,带有用于流式传输的Server-Sent事件
- 🔐 安全 -JWT身份验证和BLAKE3哈希
- 🐳 Docker就绪 -使用Docker和Docker compose轻松部署
- 📦 NPX支持 -安装并运行
npx @alsania-io/mcp
🚀 快速开始
使用NPX(最简单)
npx -y @alsania-io/mcp start使用Docker
# Pull and run
docker run -p 8050:8050 alsania-io/mcp:latest
# Or with docker-compose
docker-compose up本地开发
# Install dependencies
npm install
# Start development server
npm run dev
# Build
npm run build
# Start production server
npm start📡 传输层
AlsaniMCP支持三种传输机制:
1.STDIO传输(本地MCP服务器)
通过stdin/stdout连接到本地MCP服务器:
# Server automatically uses STDIO for local communication2.HTTP/SSE网关(远程客户端)
通过HTTP REST API向远程客户端公开工具:
- 基础URL:
http://localhost:8050 - SSE流:
http://localhost:8050/sse - 健康检查:
http://localhost:8050/health
3.HTTP代理传输(远程MCP服务器)
使用Streamable HTTP连接到远程MCP服务器:
POST /proxy/connect
{
"id": "remote-server",
"transport": "http",
"endpoint": "http://remote-mcp-server.com/mcp"
}🛠️ API终点
核心终点
GET /health-健康检查GET /stream-通知的SSE流式端点POST /message-调用工具(需要:服务器ID、工具名称、参数)GET /tools-列出所有可用工具GET /resources-列出所有资源POST /resource-阅读特定资源GET /prompts-列出所有提示POST /prompt-获取带有参数的提示
代理管理
POST /proxy/connect-连接到外部MCP服务器POST /proxy/disconnect/:serverId-断开服务器连接GET /proxy/servers-列出活动代理连接GET /proxy/status/:serverId-获取服务器状态
📋 使用示例
连接到远程MCP服务器
curl -X POST http://localhost:8050/proxy/connect \
-H "Content-Type: application/json" \
-d '{
"id": "github-server",
"transport": "http",
"endpoint": "http://localhost:3000/mcp"
}'调用工具
curl -X POST http://localhost:8050/message \
-H "Content-Type: application/json" \
-d '{
"serverId": "core",
"toolName": "echo",
"args": {"message": "Hello AlsaniaMCP!"}
}'列出所有工具
curl http://localhost:8050/tools流通知(SSE)
curl -N http://localhost:8050/stream🏗️ 建筑
┌─────────────────────────────────────────┐
│ AlsaniaMCP │
│ ┌──────────────────────────────────┐ │
│ │ CoreMCPSerber │ │
│ │ - Tool Registry │ │
│ │ - Resource Registry │ │
│ │ - Prompt Registry │ │
│ └──────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────┐ │
│ │ MCPProxyManager │ │
│ │ - STDIO Transport │ │
│ │ - HTTP Transport │ │
│ │ - Dynamic Loading │ │
│ └──────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────┐ │
│ │ HTTPGateway │ │
│ │ - REST API │ │
│ │ - SSE Streaming │ │
│ │ - Proxy Endpoints │ │
│ └──────────────────────────────────┘ │
└─────────────────────────────────────────┘🔧 配置
环境变量
PORT-HTTP网关端口(默认:8050)SESSION_SECRET-用于身份验证的JWT密钥NODE_ENV-环境(开发/生产)
服务器配置示例
const config: MCPServerConfig = {
id: 'my-server',
transport: 'http',
endpoint: 'http://localhost:3000/mcp',
lifespan: 3600000, // 1 hour
permissions: {
tools: ['read', 'write'],
resources: ['read']
}
};🔒 安全
- JWT身份验证 -安全会话管理
- BLAKE3散列 -快速安全的加密哈希
- 环境秘密 -存储在环境变量中的API密钥
- 输入验证 -对所有输入进行Zod模式验证
📦 CLI命令
AlsaniMCP提供了一个全面的命令行界面,用于管理所有服务器操作、通信、语音功能和工具执行。
服务器管理
# Start the server
alsaniamcp server start [-p
] [-d] [-v] [-c ]
# Stop the server
alsaniamcp server stop [-p
] [-f]
# Check server status
alsaniamcp server status [-p
] [-d]
# View server logs
alsaniamcp server logs [-f] [-n
]
# Aliases: amcp server start, alsaniamcp/amcp语音控制
# Check voice API support
alsaniamcp voice check
# Show voice configuration
alsaniamcp voice configAI到AI通信
# List connected AI peers
alsaniamcp comm peers
# Send message to specific peer
alsaniamcp comm send
""
# Broadcast message to all peers
alsaniamcp comm broadcast ""动态服务器生成
# List available server configurations
alsaniamcp spawn list
# Start a predefined MCP server
alsaniamcp spawn start # type: filesystem|git|github
# Stop a spawned server
alsaniamcp spawn stop
# Show server status
alsaniamcp spawn status工具管理
# List available MCP tools
alsaniamcp tools list [-s ]
# Call an MCP tool
alsaniamcp tools call [-a ]配置
# Initialize configuration files
alsaniamcp config init [-f]
# Validate current configuration
alsaniamcp config validate传统命令(向后兼容)
# Deprecated - use "server start" instead
alsaniamcp start
# Deprecated - use "config init" instead
alsaniamcp init
# Deprecated - use "comm" commands instead
alsaniamcp proxy🐳 Docker部署
构建图像
docker build -t alsania-io/mcp:latest .运行容器
docker run -d \
-p 8050:8050 \
-e SESSION_SECRET=your-secret-here \
--name alsaniamcp \
alsania-io/mcp:latestDocker Compose
docker-compose up -d🧪 发展
项目结构
src/
├── cli/ # CLI command handlers
├── communication/ # AI-to-AI communication
│ └── a2a.ts # AI-to-AI communication logic
├── core/ # Core MCP server implementation
│ └── server.ts # Universal MCP server
├── proxy/ # MCP proxy manager
│ └── mcp-proxy.ts# MCP proxy implementation
├── security/ # Security utilities
├── spawner/ # Dynamic server spawning
├── transport/ # HTTP gateway and transports
│ └── http-gateway.ts # HTTP gateway implementation
├── types/ # TypeScript type definitions
│ └── index.ts # Type definitions
├── utils/ # Utility functions
│ └── hash.ts # BLAKE3 hashing utilities
├── voice/ # Voice activation and processing
├── cli.ts # CLI implementation
└── index.ts # Entry point脚本
npm run dev-以监视模式启动开发服务器npm run build-将TypeScript构建为JavaScriptnpm start-启动生产服务器(已验证工作正常)npm run cli-运行CLI命令npm test-运行测试(待实施的测试)
✅ 当前状态(更新于2025年10月12日)
✅ 已验证工作
- ✅ 已安装依赖项(199个软件包,0个漏洞)
- ✅ TypeScript构建成功
- ✅ 生产服务器启动并运行
- ✅ 已配置Docker设置(Docker 28.2.2,Docker compose 1.29.2)
- ✅ 多传输支持(STDIO、HTTP/SSE、流式HTTP)
- ✅ 实现JWT身份验证和BLAKE3哈希
- ✅ 带有用于流式传输的服务器端事件的REST API
🏗️ 架构组件
- ✅ 带有工具/资源/提示注册表的通用MCP服务器
- ✅ 具有动态加载/卸载功能的MCP代理管理器
- ✅ 具有REST API和SSE流的HTTP网关
- ✅ CLI界面(
alsaniamcp/amcp命令) - ✅ AI到AI通信框架(已实施)
- ✅ 语音激活和语音处理(已实现)
- ✅ 动态MCP服务器生成(已实现)
- 🔄 集成测试框架(开发中)
📊 代码度量
- 语言:TypeScript 5.x
- 运行时:带ES模块的Node.js
- 测试:当前未实施任何测试
- 依赖项:199个软件包,主要是MCP SDK和实用程序
🎯 路线图(更新)
- \[x\] 第一阶段-核心MVP ✅ 完成
- \[x\] 带JSON-RPC 2.0的核心MCP服务器 - \[x\] 动态代理/注册表系统 - \[x\] 多传输层(STDIO、HTTP/SSE) - \[x\] HTTP流网关 - \[x\] 流式HTTP代理传输
- \[x\] 第2阶段-高级功能 ✅ 完成
- \[x\] AI到AI通信框架(已实施) - \[x\] 语音激活和语音处理(已实现) - \[x\] 动态MCP服务器生成(已实现) - \[x\] 带有关键字检测的语音激活(已实现) - \[x\] 语音转文本和文本转语音(已实现) - \[x\] 集成语音命令处理(已实现)
- \[ \] 第3阶段-企业就绪
- \[\]高级安全层 - \[\]混沌测试框架 - \[\]性能监控 - \[\]单元和集成测试 - \[\]综合文件
📄 许可证
MIT许可证-有关详细信息,请参阅许可证文件
🤝 贡献
欢迎投稿!请随时提交拉取请求。
📞 支持
- 文档: MCP协议文件
- 问题:
- 讨论:
______________________________________________________________________
内置于❤️ 使用 模型上下文协议
