Z.AI MCP代理服务器
Z.AI Web Search Prime API的完整MCP代理服务器,可与Forge集成为通过stdio运行的标准MCP服务器。
🚀 快速开始
1.安装
# Clone repository
git clone https://github.com/dariuszkowalski-com/zai-mcp-proxy-server.git
cd zai-mcp-proxy-server
# Install dependencies
npm install
# Set API key
export ZAI_API_KEY="your_zai_api_key"
# Run server
node zai-mcp-proxy.js2.锻造配置
添加到您的Forge配置中:
{
"mcpServers": {
"zai-search": {
"command": "node",
"args": ["/path/to/zai-mcp-proxy.js", "--api-key", "$ZAI_API_KEY"]
}
}
}📋 需求
- Node.js 16+
- Z.AI Web搜索主要API密钥
- 互联网接入
🔧 工具
webSearchPrime
Z.AI网络搜索Prime搜索引擎。
参数:
search_query(字符串,必填):搜索查询content_size(字符串,可选):结果的内容大小(small,medium,large)-默认值mediumlocation(字符串,可选):搜索位置-默认值us
使用示例:
webSearchPrime("rust programming language", { content_size: "medium", location: "us" })🛠️ 技术
- Node.js -运行时环境
- @模型上下文协议/sdk -官方MCP SDK
- 萨德 -参数验证
- 超文本传输安全协议 -与Z.AI API通信
📁 文件结构
zai-mcp-proxy-server/
├── zai-mcp-proxy.js # Main MCP server
├── package.json # Project dependencies
├── test-zai-mcp-proxy.js # Unit tests
├── install-proxy.sh # Installation script
└── README.md # Documentation🧪 测试
# Run tests
npm test
# Tests check:
# - MCP connection initialization
# - Available tools listing
# - Search execution
# - Result formatting correctness🔒 安全
- 通过安全HTTPS连接传输API密钥
- 验证所有输入参数
- 错误处理和超时
- 不记录敏感数据
📈 特性
- ✅ 与MCP协议v2024-11-05完全兼容
- ✅ 通过stdio进行通信
- ✅ 自动Z.AI会话管理
- ✅ 搜索结果格式
- ✅ 错误处理和超时
- ✅ 可配置的搜索参数
- ✅ 结果元数据(计数、来源、查询)
🔄 在其他计算机上安装
方法1:安装脚本
# Download and run script
curl -sSL https://raw.githubusercontent.com/dariuszkowalski-com/zai-mcp-proxy-server/main/install-proxy.sh | bash
# Set API key
export ZAI_API_KEY="your_api_key"方法2:手动安装
# 1. Clone repository
git clone https://github.com/dariuszkowalski-com/zai-mcp-proxy-server.git
cd zai-mcp-proxy-server
# 2. Install Node.js (if not installed)
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
# 3. Install dependencies
npm install
# 4. Set API key in environment variable or .env file
echo 'export ZAI_API_KEY="your_api_key"' >> ~/.bashrc
source ~/.bashrc
# 5. Test functionality
npm test方法三:Docker
# Build image
docker build -t zai-mcp-proxy .
# Run container
docker run -d --name zai-mcp-proxy \
-e ZAI_API_KEY="your_api_key" \
-v /path/to/config:/config \
zai-mcp-proxy🐛 故障排除
没有搜索结果
- 检查API密钥:
echo $ZAI_API_KEY - 验证互联网连接
- 检查Z.AI API限值
连接错误
- 确保Node.js的版本为16+
- 检查防火墙和代理
- 验证Z.AI API URL
锻造集成问题
- 检查路径
zai-mcp-proxy.js文件 - 确保
ZAI_API_KEY变量已设置 - 检查文件权限
📄 许可证
MIT许可证
🤝 支持
对于问题:
- 检查错误日志
- 跑
npm test - 查看Z.AI API文件
- 打开GitHub问题
______________________________________________________________________
已准备好与Forge一起使用! 🚀
