MCP网关服务

Goblin是一个生产就绪的模型上下文协议(MCP)网关,用于聚合多个MCP服务器,提供统一的接口、热重载和多传输支持,适用于AI代理系统。

  • by TalkingThreads
  • TypeScript
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 TalkingThreads/goblin

使用说明

地精MCP网关

开发人员第一个MCP网关,将多个MCP服务器聚合在一个统一的端点后面

[][许可证url]

极速性能•热装•企业就绪


关于

Goblin已准备好生产 模型上下文协议(MCP)网关 这解决了代理人工智能系统中的工具蔓延、上下文膨胀和脆弱的集成问题。Goblin使用Bun、TypeScript、Hono和MCP SDK构建,提供低于50ms的延迟目标和开发人员优先体验,包括实时TUI仪表板、结构化日志记录和全面的可观察性。

为什么是妖精?

  • 统一接口:来自多个MCP后端的单端点聚合工具、提示和资源
  • 热重新加载:配置更改以原子方式应用,无需重新启动
  • 多运输:STDIO、HTTP、SSE和带自动连接池的流式HTTP
  • 企业就绪:1000多项测试、CI烟雾测试、性能基准测试

特性

核心网关 管理 安全性 可观察性
🔌 统一聚合 🎛️ TUI仪表板 ✅ 默认安全 📊 结构化日志记录
🛣️ 智能路由 ⚡ 热重新加载 🔐 API密钥授权 📈 自定义指标
🚀 多运输 🔧 CLI命令 🛡️ RBAC就绪 🔍 实时TUI
📦 虚拟工具 🖥️ 交互式TUI 📋 审核日志记录 🚨 健康检查

核心能力

  • 🔌 统一聚合 --来自多个MCP服务器的工具、提示和资源的单一端点
  • 🛣️ 智能路由 --带超时强制和错误映射的命名空间工具调用
  • 🚀 多运输 --STDIO、HTTP、SSE和带自动连接池的流式HTTP
  • ⚡ 热重新加载 --配置更改以原子方式应用,无需重新启动(HTTP模式)或通过SIGHUP(STDIO模式)
  • 📊 完全可观察性 --结构化日志记录、自定义指标和实时TUI仪表板
  • ✅ 企业就绪 --1000多项测试,CI烟雾测试,性能基准测试

快速开始

1.安装

git clone https://github.com/TalkingThreads/goblin.git
cd goblin
bun install

2.配置

创建一个 config.json 文件:

{
  "servers": [
    {
      "name": "filesystem",
      "transport": "stdio",
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
      "enabled": true
    }
  ],
  "gateway": {
    "port": 3000,
    "host": "127.0.0.1"
  }
}

3.跑步

# Development mode (with hot reload)
bun run dev

# Production mode
bun run build
bun run start

# With TUI dashboard
goblin start --tui

# STDIO mode (for Claude CLI integration)
goblin stdio

就是这样!地精现在正在奔跑 http://127.0.0.1:3000.

  • 超文本传输协议: http://127.0.0.1:3000/mcp
  • 上海证券交易所: http://127.0.0.1:3000/sse

安装

来源

git clone https://github.com/TalkingThreads/goblin.git
cd goblin
bun install
bun run build

先决条件

工具 版本 必填
包子 >= 1.3.8 ✅ 是的
Node.js >=20.0.0 仅适用于CLI

文档

主题 描述
📚 入门指南 逐步安装和配置
🏗️ 建筑 系统设计和组件概述
💻 CLI参考 完整的CLI命令文档
🌐 API 参考 HTTP端点和API文档
⚙️ 配置 完整的配置参考
🔧 故障排除 常见问题和解决方案

CLI命令

网关管理

goblin start              # Start the gateway (default: HTTP mode)
goblin start --tui       # Start with TUI dashboard
goblin start --port 8080 # Custom port
goblin restart           # Graceful restart
goblin stop              # Graceful shutdown

服务器管理

goblin servers                    # List all servers
goblin servers add <name> <type>  # Add a new server
goblin servers remove <name>      # Remove a server
goblin servers enable <name>      # Enable a disabled server
goblin servers disable <name>     # Disable a server

工具操作

goblin tools list                 # List all available tools
goblin tools invoke <name> --args '{"path": "/tmp"}'
goblin tools describe <name>      # Show tool schema

配置

goblin config validate            # Validate configuration
goblin config show                # Display current config
goblin config reload              # Hot reload config

监控

goblin status                     # Gateway status
goblin health                     # Health check
goblin logs                       # Show logs
goblin logs -f                    # Follow logs
goblin metrics                    # Performance metrics

壳牌完井

# Bash
goblin completion bash >> ~/.bashrc

# Zsh
goblin completion zsh >> ~/.zshrc

# Fish
goblin completion fish > ~/.config/fish/completions/goblin.fish

看 CLI参考 以获取完整的文档。


建筑

┌─────────────────────────────────────────────────────────────┐
│                      Goblin MCP Gateway                       │
│                                                              │
│  ┌──────────┐   ┌──────────┐   ┌──────────┐   ┌──────────┐ │
│  │  Client  │──▶│  HTTP    │──▶│  Router  │──▶│ Registry │ │
│  │  (MCP)   │   │ Gateway  │   │          │   │          │ │
│  └──────────┘   └──────────┘   └──────────┘   └──────────┘ │
│                                      │              │        │
│                                      ▼              ▼        │
│  ┌──────────┐   ┌──────────┐   ┌──────────┐   ┌──────────┐ │
│  │  Client  │◀──│   TUI    │◀──│ Metrics  │◀──│ Transport│ │
│  │  (MCP)   │   │Dashboard │   │          │   │   Pool   │ │
│  └──────────┘   └──────────┘   └──────────┘   └──────────┘ │
│                                                              │
└─────────────────────────────────────────────────────────────┘
         │                    │                    │
         ▼                    ▼                    ▼
  ┌──────────────┐     ┌──────────────┐     ┌──────────────┐
  │ MCP Server 1 │     │ MCP Server 2 │     │ MCP Server N │
  │ (Filesystem) │     │ (Git)        │     │ (Custom)     │
  └──────────────┘     └──────────────┘     └──────────────┘

看 建筑 获取详细的组件文档。


客户端传输类型

STDIO传输

用于将MCP服务器作为子进程运行的基于本地子进程的传输:

{
  "name": "filesystem",
  "transport": "stdio",
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
  "enabled": true
}

HTTP传输

用于连接到基于HTTP的MCP服务器的简单HTTP传输:

{
  "name": "remote-server",
  "transport": "http",
  "url": "http://localhost:3001/mcp",
  "enabled": true
}

苏格兰和南方能源公司运输

服务器推送通知的服务器发送事件传输:

{
  "name": "sse-server",
  "transport": "sse",
  "url": "http://localhost:3002/sse",
  "enabled": true
}

可流式HTTP传输

具有会话管理、自动重新连接和自定义标头的有状态HTTP传输:

{
  "name": "streamable-server",
  "transport": "streamablehttp",
  "url": "http://localhost:3003/mcp",
  "headers": {
    "Authorization": "Bearer your-token-here"
  },
  "reconnect": {
    "enabled": true,
    "delay": 1000,
    "maxRetries": 5,
    "backoffMultiplier": 2
  },
  "enabled": true
}

服务器生命周期模式

Goblin支持后端MCP服务器的三种连接生命周期模式:

模式 描述 用例
stateful (默认) 连接无限期保持活动状态,跨请求重用 高频工具调用,持久会话
smart 连接保持活动状态,在空闲60秒后被驱逐 响应性和资源效率之间的平衡
stateless 根据请求创建连接,使用后快速删除 低频呼叫,资源受限的环境

模式配置

添加 mode 属性到服务器配置:

{
  "name": "filesystem",
  "transport": "stdio",
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
  "mode": "smart",
  "enabled": true
}
  • 有状态的 (默认):最适合频繁调用的服务器
  • 聪明的:推荐默认值-闲置60秒后自动清理
  • 无状态:最适合在偶尔调用时最大限度地减少内存使用

技术栈

组件 技术 目的
运行时间 包子 快速JavaScript运行时
MCP核心 @模型上下文协议/sdk 协议实施
HTTP服务器 荣誉 轻量级web框架
验证 佐德 运行时类型验证
日志记录 皮诺 结构化JSON日志记录
度量 自定义(零dep) 内存中度量
CLI 指挥官.js 命令行界面
推 墨水 +React 终端用户界面

贡献

我们欢迎捐款!请参阅 贡献.md 作为指导方针。

开发工作流程

  1. 阅读 代理商.md 用于规范驱动的开发过程
  2. 为新功能创建更改建议
  3. 为您的更改编写测试
  4. 确保所有测试通过: bun test
  5. 提交拉取请求

预提交钩子

此项目使用 哈士奇 对于预提交钩子:

# Install hooks (runs automatically after bun install)
bun run prepare

挂钩检查:

  • ✅ TypeScript类型检查(bun run typecheck)
  • ✅ 生物植绒(bun run lint)
  • ✅ 单元测试(bun test tests/unit/)

支持


许可证

麻省理工学院 © TalkingThreads


相关文件

文档 描述
更改日志.md 版本历史和发行说明
维护.md 项目维护人员
代码_OF_CONDUCT.md 社区指南
openspec/project.md 项目背景和设计

建于❤️ TalkingThreads团队