Gamma MCP服务器
Gamma.app的模型上下文协议(MCP)服务器 - 允许AI助理通过Gamma API生成演示文稿。
特性
- ✅ 3个MCP工具:
- gamma_generate - 创建演示文稿/文档 - gamma_get_generation - 获取一代状态 - gamma_list_generations 前几代人列表
- ✅ 两种模式:
- 标准 - 对于Claude Desktop(本地使用) - 超文本传输协议 针对 AI 引擎和 Web 应用程序(24/7 部署)
- ✅ 全面支持Gamma API:
- 演示文稿、文档、网页 - 自定义主题、音调、受众 - 瑞典语默认值 - 图像生成
安装
1. 克隆/复制项目
cd ~/gamma-mcp-server2.Installera依赖关系
npm install3. 配置API密钥
更新 .env 在Gamma API密钥中存档:
GAMMA_API_KEY=sk-gamma-your-key-here4. 构建项目
npm run build使用
本地测试(stdio模式)
要使用 Claude Desktop 或本地测试:
npm start添加到 Claude Desktop 配置 (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"gamma": {
"command": "node",
"args": ["/absolut/sökväg/till/gamma-mcp-server/dist/index.js"]
}
}
}HTTP服务器(用于AI引擎)
启动HTTP服务器:
npm run start:streamable服务器正在运行 http://localhost:3000/mcp
部署到 allgot.se
方法1:PM2(流程经理)
# Installera PM2
npm install -g pm2
# Starta servern
pm2 start dist/streamable-http-server.js --name gamma-mcp
# Auto-restart vid server reboot
pm2 startup
pm2 save方法2:系统化服务
创建 /etc/systemd/system/gamma-mcp.service:
[Unit]
Description=Gamma MCP Server
After=network.target
[Service]
Type=simple
User=www-data
WorkingDirectory=/home/u210698164/gamma-mcp-server
Environment=NODE_ENV=production
ExecStart=/usr/bin/node dist/streamable-http-server.js
Restart=always
[Install]
WantedBy=multi-user.target激活 :
sudo systemctl enable gamma-mcp
sudo systemctl start gamma-mcpNginx反向代理
在nginx配置中添加:
location /gamma-mcp {
proxy_pass http://localhost:3000/mcp;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# För SSE streaming
proxy_buffering off;
proxy_read_timeout 600s;
}集成医疗AI引擎
1.通过代码引擎专业版
在代码引擎中创建一个PHP片段(类型:function):
function gamma_create_presentation($params) {
$mcp_url = 'https://allgot.se/gamma-mcp';
$request = [
'jsonrpc' => '2.0',
'id' => 1,
'method' => 'tools/call',
'params' => [
'name' => 'gamma_generate',
'arguments' => $params
]
];
$response = wp_remote_post($mcp_url, [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json, text/event-stream'
],
'body' => json_encode($request),
'timeout' => 60
]);
return json_decode(wp_remote_retrieve_body($response), true);
}2.AI引擎总监
如果 AI Engine 支持外部 MCP 服务器,您可以配置:
- 端点:
https://allgot.se/gamma-mcp - 方法:岗位
- 标题:
Accept: application/json, text/event-stream
API示例
创建演示文稿
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "gamma_generate",
"arguments": {
"inputText": "Hållbar utveckling i skolan",
"format": "presentation",
"numCards": 12,
"textTone": "educational",
"textAudience": "teachers",
"textLanguage": "Swedish"
}
}
}获取状态
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "gamma_get_generation",
"arguments": {
"generationId": "gen_abc123"
}
}
}环境变量
| 变量 | 描述 | Default |
|---|---|---|
GAMMA_API_KEY | Din Gamma API密钥(必需) | - |
GAMMA_API_BASE_URL | 伽马API基线-URL | https://public-api.gamma.app/v1.0 |
PORT | HTTP服务器端口 | 3000 |
HOST | HTTP服务器主机 | 0.0.0.0 |
NODE_ENV | 环境模式 | development |
安全
- ⚠️ 从不添加
.envi git - ✅ 在生产中使用HTTPS
- ✅ 限制对 MCP 端点的访问(防火墙/身份验证)
- ✅ 保持Gamma API密钥安全
故障排除
服务器未启动
# Kolla om port 3000 redan används
lsof -i :3000
# Prova annan port
PORT=3001 npm run start:streamableGamma API错误
# Testa API key manuellt
curl -X POST https://public-api.gamma.app/v1.0/generate \
-H "X-API-KEY: your-key-here" \
-H "Content-Type: application/json" \
-d '{"input_text":"Test","format":"presentation"}'MCP连接问题
- 检查
Accept: application/json, text/event-streamheader 有 - Kolla服务器日志:
pm2 logs gamma-mcp或journalctl -u gamma-mcp -f - 请确认 nginx Reverse Proxy 设定正确。
支持
如有任何疑问或问题,请联系:isak@allgot.se
许可证
麻省理工学院许可证 - Allgot.se
