Panorgan
Panorgan 是一个用Go编写的智能MCP(模型上下文协议)编排服务器,它充当多个下游MCP服务器的智能目录和调度器。
特性
- 多运输支持:stdio和流式HTTP传输
- 智能工具发现:自动发现和缓存来自下游服务器的工具
- 智能工具搜索:基于任务描述的LLM电动工具选择
- 灵活的服务器管理:下游服务器的按需和保持活动模式
- 数据库缓存:基于SQLite的缓存,用于快速查找工具
- 结构化日志记录:提供轮换支持的全面测井
- Lua过滤器:拦截和修改安全、隐私和审计工具调用
安装
先决条件
- Go 1.24+(由Go.mod自动管理)
- Make(可选,用于构建自动化)
从源头构建
# Clone the repository
git clone https://github.com/sevir/panorganon
cd panorganon
# Build
make build
# Or build manually
go build -o bin/panorganon ./cmd/panorganon安装
make install配置
创建 config.yaml 文件(参见 examples/config.example.yaml):
server:
stdio:
enabled: true
http:
enabled: true
port: 8080
endpoint: "/mcp"
logging:
level: info
file: "./logs/panorganon.log"
database:
path: "./panorganon.db"
sampling:
provider: "anthropic"
api_key: "${ANTHROPIC_API_KEY}"
model: "claude-3-5-sonnet-20241022"
downstream_servers:
- name: "remembrances-mcp"
type: "stdio"
command: "remembrances-mcp-beta"
args:
- "--config"
- "/path/to/config.yaml"
env: {}
keepalive: false
- name: "remote-server"
type: "streamable-http"
url: "http://example.com/mcp"
keepalive: true用法
启动服务器
# Using stdio transport (for MCP clients)
panorganon --config config.yaml
# With custom log level
panorganon --config config.yaml --log-level debugMCP工具暴露
Panorgan展示了4种MCP工具:
1. search_tools
根据任务描述搜索合适的工具。
参数:
task_description(string,必填):任务的自然语言描述max_results(数量,可选):要返回的最大工具数量(默认值:10)
退货: 包含名称、服务器、描述和输入模式的工具对象数组。
2. exec_tool
从下游MCP服务器执行工具。
参数:
tool_name(string,必填):要执行的工具的名称parameters(object,必填):带工具参数的JSON对象server_name(字符串,可选):如果不明确,则显式服务器名称
退货: 工具执行结果。
3. list_servers
列出所有已配置的下游MCP服务器及其状态。
退货: 具有名称、类型、运行状态和保活标志的服务器对象数组。
4. refresh_tools
强制刷新工具元数据缓存。
参数:
server_name(字符串,可选):仅刷新特定服务器
退货: 成功状态和刷新的工具数量。
Lua过滤器
Panorgan包括一个强大的基于Lua的过滤系统,允许您拦截和修改对下游MCP服务器的工具调用。这使得:
- 安全:Redact API密钥、令牌和敏感数据
- 隐私:过滤系统路径和个人信息
- 审计:使用自定义元数据记录所有工具调用
- 验证:执行业务规则和约束
- 转变:动态修改数据
快速开始
- 启用筛选器 在你的
config.yaml:
filters:
enabled: true
script_path: "./filters/panorganon-filters.lua"
timeout: 5s
strict_mode: false- 创建筛选器脚本 (
filters/panorganon-filters.lua):
-- Block sensitive searches
_G["remembrances-mcp-input"] = function(context)
local params = context.parameters
if params.query and string.match(params.query, "password") then
error("Search for passwords blocked")
end
return params
end
-- Redact API keys in responses
_G["hyper-mcp-output"] = function(context)
local result = context.result
if result.content then
for i, item in ipairs(result.content) do
if item.type == "text" and item.text then
item.text = string.gsub(item.text, "sk%-[a-zA-Z0-9]+", "sk-[REDACTED]")
end
end
end
return result
end- 重新启动Panorgan 过滤器将自动应用。
了解更多
有关Lua过滤器的全面文档,包括:
- 过滤器函数命名约定
- 可用的Lua模块
- 安全最佳实践
- 常见用例的示例过滤器
- 调试和故障排除
查看完整 Lua过滤器文档.
建筑
panorganon/
├── cmd/
│ └── panorganon/ # Main entry point
├── internal/
│ ├── config/ # Configuration management
│ ├── server/ # MCP server transports
│ ├── downstream/ # Downstream server management
│ ├── tools/ # Tool discovery and execution
│ ├── database/ # SQLite database layer
│ ├── luafilters/ # Lua filter system
│ └── logging/ # Structured logging
├── pkg/
│ └── version/ # Version information
├── docs/ # Documentation
└── examples/ # Example configurations and filters
├── config.example.yaml
└── filters/
└── panorganon-filters.lua发展
构建
make build运行测试
make test棉绒
make lint清洁
make clean版本信息
版本信息在构建时注入:
panorganon version许可证
\[在此处添加您的许可证\]
贡献
\[在此处添加贡献指南\]
状态
开发状态: 测试版(已完成95%)
完整的:
- ✅ 项目基础和建设体系
- ✅ 具有YAML和环境变量的配置系统
- ✅ MCP传输层(stdio,流式HTTP)
- ✅ 下游服务器管理(stdio、HTTP、SSE存根)
- ✅ 使用SQLite的数据库层
- ✅ 旋转式测井系统
- ✅ 使用自动缓存进行工具发现
- ✅ 使用LLM采样进行工具搜索(Anthropic/OpenAI)
- ✅ 通过重试和验证执行工具
- ✅ 完成stdio/HTTP的JSON-RPC通信
- ✅ 测试框架和示例测试
- ✅ 综合文档(API、配置、开发)
- ✅ Docker支持Dockerfile和Docker compose
准备投入生产使用:
- 所有4个MCP工具功能齐全(搜索工具、执行工具、列表服务器、刷新工具)
- 强大的错误处理和日志记录
- 参数验证
- 自动服务器生命周期管理
- LLM动力智能刀具选型
TODO(很高兴有):
- 附加单元和集成测试
- SSE运输实施
- WebSocket支持
- 工具结果缓存
- 用于管理的Web UI
- 性能优化
任务
构建
编译panorganon二进制文件。
# Get version from git tags or use dev
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
go build -ldflags "-X 'github.com/sevir/panorganon/pkg/version.Version=$VERSION' -X 'github.com/sevir/panorganon/pkg/version.Commit=$COMMIT' -X 'github.com/sevir/panorganon/pkg/version.BuildTime=$BUILD_TIME'" -o bin/panorganon ./cmd/panorganon构建和复制
编译panorganon二进制文件并将其复制到~/bin文件夹。
# Get version from git tags or use dev
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
go build -ldflags "-X 'github.com/sevir/panorganon/pkg/version.Version=$VERSION' -X 'github.com/sevir/panorganon/pkg/version.Commit=$COMMIT' -X 'github.com/sevir/panorganon/pkg/version.BuildTime=$BUILD_TIME'" -o bin/panorganon ./cmd/panorganon
rm -f ~/bin/panorganon
cp bin/panorganon ~/bin/panorganon发布
编译多个平台(Linux x64、Windows x64、macOS aarch64)的二进制文件,并在 dist 文件夹。
# Create dist folder
mkdir -p dist
# Get version from git tags or use dev
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Function to build and zip
build_and_zip() {
local os=$1
local arch=$2
local suffix=$3
local ext=$4
echo "Building for $os-$arch..."
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -ldflags "-X 'github.com/sevir/panorganon/pkg/version.Version=$VERSION' -X 'github.com/sevir/panorganon/pkg/version.Commit=$COMMIT' -X 'github.com/sevir/panorganon/pkg/version.BuildTime=$BUILD_TIME' -s -w" -o dist/panorganon-$suffix$ext ./cmd/panorganon
echo "Zipping panorganon-$suffix$ext..."
cd dist
zip panorganon-$suffix.zip panorganon-$suffix$ext
rm panorganon-$suffix$ext
cd ..
}
# Linux x64
build_and_zip linux amd64 linux-x64 ""
# Windows x64
build_and_zip windows amd64 windows-x64 ".exe"
# macOS aarch64
build_and_zip darwin arm64 darwin-arm64 ""
echo "Release builds completed in dist/"