fitness-agent-mcp
A universal fitness intelligence layer for AI assistants like Claude, ChatGPT, and Copilot, enabling user profiles, workout/diet plans, calendar scheduling, and gamification via MCP and REST APIs.
README
Fitness Agent MCP
A zero-dependency Express API that acts as a universal fitness intelligence layer for AI assistants. Claude, ChatGPT, and GitHub Copilot all share the same state, gamification engine, and data. Claude and Copilot via the built-in MCP server, ChatGPT via OpenAPI Custom Actions.
No OpenAI key. No database server. One deployed URL.
Table of Contents
- What This Does
- Architecture
- Local Setup
- Deploy to Railway
- Connecting AI Clients
- MCP Tools
- Security Notes
- Environment Variables
1. What This Does
One server, three AI surfaces:
| AI Client | Protocol | How it connects |
|---|---|---|
| Claude Desktop / claude.ai | MCP (StreamableHTTP) | Calls /api/mcp with JSON-RPC |
| GitHub Copilot Chat | MCP (SSE) | Reads .vscode/mcp.json, calls /api/mcp |
| ChatGPT Custom GPT | REST / OpenAPI | Reads /api/openapi.json, calls REST endpoints |
Features: user profiles · workout + diet plans · calendar scheduling · gamification (XP / streaks / 12 achievements) · paginated history · export (JSON / CSV / interactive HTML) · cron reminders
Design principle: The server is a pure storage layer. The AI client (Claude, GPT-4, Copilot) reads tool descriptions and generates all structured data itself — diet plans, workout schedules, calendar events — then passes them as parameters. No server-side AI calls. No API keys required.
2. Architecture
Claude / Copilot ChatGPT Custom GPT
└─ MCP JSON-RPC ──────┐ └─ REST/OpenAPI ──┐
▼ ▼
┌──────────────────────────────────────┐
│ Express API (/api/*) │
│ │
│ MCP tools (8) REST routes │
│ get_state /state │
│ save_state /log-completion │
│ log_completion /normalize │
│ normalize_user_input /generate-plan │
│ generate_plan /schedule-events │
│ schedule_events /export │
│ get_history /progress/history │
│ export_report /healthz │
│ │
│ Gamification engine + node-cron │
└──────────────────┬───────────────────┘
│
▼
┌────────────────┐
│ SQLite (file) │
│ │
│ user_profiles │
│ diet_plans │
│ workout_plans │
│ schedules │
│ progress │
└────────────────┘
Tables are created automatically on first boot via Drizzle migrations — no manual schema push needed.
3. Local Setup
Prerequisites
- Node.js 20+
- pnpm 9+
Install and run
git clone <your-repo-url>
cd fitness-agent-mcp-v2
pnpm install
Copy the example env file (optional — defaults work out of the box):
cp .env.example .env
Start the server:
pnpm --filter @workspace/api-server run dev
The API is at http://localhost:8080/api. SQLite database is created automatically at ./artifacts/api-server/data/fitness.db.
Verify
curl http://localhost:8080/api/healthz
# → {"status":"ok"}
Run tests
pnpm --filter @workspace/api-server test
4. Deploy to Railway
The railway.toml at the project root configures everything automatically.
Steps
- Push this repo to GitHub
- railway.app → New Project → Deploy from GitHub repo → select repo
- Dashboard → Add Volume → Mount path:
/data, Size: 1 GB - Service → Variables → add:
| Key | Value |
|---|---|
PORT |
8080 |
DB_PATH |
/data/fitness.db |
- Deploy — Railway auto-sets
RAILWAY_PUBLIC_DOMAIN
Test
curl https://your-app.up.railway.app/api/healthz
# → {"status":"ok"}
List on Smithery (optional)
Smithery.ai is the MCP marketplace — users can find your server and connect it to Claude with one click.
npx smithery mcp publish "https://your-app.up.railway.app/api/mcp" \
-n yourusername/fitness-agent
5. Connecting AI Clients
Once deployed, get your base URL (https://your-app.up.railway.app).
Claude — claude.ai web
- Settings → Integrations → Add Custom Integration
- Paste:
https://your-app.up.railway.app/api/mcp - Done — syncs to Claude iOS app automatically
Claude Desktop (manual config)
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"fitness-agent": {
"url": "https://your-app.up.railway.app/api/mcp",
"transport": "streamable-http"
}
}
}
Restart Claude Desktop completely after saving.
Get the recommended system prompt:
curl https://your-app.up.railway.app/api/system-prompt
# → use the claude.prompt value
GitHub Copilot — VS Code
Update .vscode/mcp.json with your deployed URL:
{
"servers": {
"fitness-agent": {
"url": "https://your-app.up.railway.app/api/mcp",
"type": "sse"
}
}
}
.github/copilot-instructions.md is already in the repo — Copilot Chat reads it automatically for full API context.
ChatGPT — Custom GPT Actions
- chat.openai.com → profile → My GPTs → Create → Configure → Actions → Add action
- Schema URL:
https://your-app.up.railway.app/api/openapi.json - ChatGPT auto-discovers all REST endpoints
- Paste the
chatgpt.promptvalue fromGET /api/system-promptas your GPT's System Prompt
6. MCP Tools
All 8 tools are available at POST /api/mcp (JSON-RPC, StreamableHTTP).
| Tool | What it does | Who computes the data |
|---|---|---|
get_state |
Fetch full profile, plans, schedule, progress | — |
save_state |
Upsert any section of user state | — |
log_completion |
Log workout/diet, award XP + streak | — |
normalize_user_input |
Extract profile fields from freeform text | AI client passes extracted param |
generate_plan |
Save a diet or workout plan | AI client passes plan param |
schedule_events |
Save calendar events | AI client passes events array |
get_history |
Paginated completion history | — |
export_report |
Report in JSON / CSV / HTML | — |
For normalize_user_input, generate_plan, and schedule_events: the tool description instructs the AI to generate the structured data itself and pass it as a parameter. The server validates and stores it. No server-side AI call is made.
Discover all tools and their input schemas:
POST /api/mcp
Content-Type: application/json
Accept: application/json, text/event-stream
{ "jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {} }
7. Security Notes
Current status: safe for personal use and demos.
- No authentication — any
userIdstring can read/write any user's data. For personal use this is fine. For multi-user deployments, add anx-api-keyheader check before going public. - Open CORS —
app.use(cors())allows all origins. Restrict to your domain in production. - No rate limiting — add
express-rate-limitif hosting publicly. - SQL injection — safe, Drizzle ORM uses parameterized queries throughout.
- Secrets — no hardcoded credentials; all config via environment variables.
8. Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
PORT |
No | 8080 |
Server port |
DB_PATH |
No | ./data/fitness.db |
SQLite file path — set to /data/fitness.db on Railway (volume mount) |
PUBLIC_URL |
No | Auto-detected | Base URL for report links — Railway sets this via RAILWAY_PUBLIC_DOMAIN automatically |
LOG_LEVEL |
No | info |
Pino log level |
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。