内容
# Forem 远程 MCP 服务器(Vercel-ready)
一个零配置的远程 MCP 服务器,允许 AI 客户端使用在 MCP 服务器 `api-key` 头部中传递的 API 密钥管理 Forem 账户。
## 支持的工具
- `create_post`
- `update_post`
- `delete_post`
- `get_post`
- `list_my_posts`
- `set_publish_state`
## 部署(零配置)
1. 将此仓库推送到 GitHub。
2. 导入到 Vercel。
3. 将环境变量 `FOREM_INSTANCE_URL`(或 `FOREM_BASE_URL`)设置为您的 Forem 实例 URL,例如 `https://dev.to` 或 `https://community.example.com`。
4. 部署。
`vercel.json` 显式地将 `/`(和 `/mcp`)重写为 `/api/index.js`,避免路由解析歧义,使部署的根 URL 直接作为客户端期望的 MCP 端点。
## MCP 客户端配置
使用您的服务器 URL,并在 `api-key` 头部中传递 Forem API 密钥:
```json
{
"mcpServers": {
"my-remote-server": {
"url": "https://forem-mcp.vercel.app",
"headers": {
"Content-Type": "application/json",
"api-key": "YOUR_FOREM_API_KEY",
"User-Agent": "forem-remote-mcp/1.0.0"
}
}
}
}
```
**重要:** Forem API 需要:
- `api-key` 头部进行身份验证(不是 `Authorization: Bearer`)
- `User-Agent` 头部(Forem API 需要,缺少时返回 401)
## 本地开发
```bash
npm run start
```
## 备注
- 服务器从 `api-key` 头部(或 `Authorization: Bearer` 作为备用)提取您的令牌,并将其转发到 Forem 作为 `api-key` 头部。
- 端点传输是 MCP JSON-RPC over HTTP(`POST /`)。
## 必需的环境变量
- `FOREM_INSTANCE_URL`(首选)或 `FOREM_BASE_URL`:您的 Forem 实例的基本 URL(不需要尾部斜杠)。