Token导航 LogoToken导航TokenDH.com
Workout Tracker MCP logo
数据服务stdio官方级别未说明来源级核验

Workout Tracker MCP

MCP Server

一个用于健身追踪工具的数据库服务,实现数据库架构、数据摄入有效负载验证和事务写入路径。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
数据库服务Python数据验证

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

AmanSinghAS

提供方

AmanSinghAS

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -r requirements.txt

详细介绍

运动跟踪器SoR(Postgres)

实现Workout Tracker MCP工具的数据库模式、摄取有效负载验证和事务写入路径。

先决条件

  • Python 3.11+
  • PostgreSQL(本地或容器)
  • DATABASE_URL 指向数据库的环境变量,例如。
  export DATABASE_URL=postgresql+psycopg://postgres:postgres@localhost:5432/workout_tracker

设置

  1. 安装依赖项:
   pip install -r requirements.txt
  1. 通过配置数据库URL DATABASE_URL.

迁移

运行Alembic migrations以创建架构:

alembic upgrade head

运行MCP服务器

启动MCP服务器(流式HTTP传输):

python3 server.py

认证

服务器需要Google OIDC ID令牌(由Google签名并使用 email_verified=true).配置: 集 GOOGLE_CLIENT_ID 添加到您的OAuth客户端ID以强制令牌受众。 集 GOOGLE_CLIENT_SECRET 用于Google令牌交换的OAuth客户端密钥。 可选设置 API_KEY 允许静态密钥通过 Authorization: Bearer . 可选设置 API_KEYS_FILE 加载多个密钥(默认值: api_keys.txt,逗号或换行符分隔)。 集 RESOURCE_SERVER_URL 到您的公共MCP URL(例如。,https://.../mcp)因此OAuth发现可以找到受保护的资源元数据。

要获取用于本地测试的ID令牌,请使用基于浏览器的登录或 gcloud:

gcloud auth application-default login
gcloud auth print-identity-token --audiences ""

服务器在以下位置公开OAuth保护的资源元数据 /.well-known/oauth-protected-resource{path} 以及OAuth服务器元数据 /.well-known/oauth-authorization-server 用于OAuth发现。它还代理Google OAuth /oauth/authorize, /oauth/token,以及 /oauth/register 以确保设置范围并支持动态客户端注册。

将令牌发送到 Authorization 所有MCP请求的标头,例如:

curl -H "Authorization: Bearer $(gcloud auth print-identity-token --audiences \"\")" \
     http://localhost:8000/mcp

# or with API key
curl -H "Authorization: Bearer $API_KEY" http://localhost:8000/mcp

# or with key from file
curl -H "Authorization: Bearer " http://localhost:8000/mcp

MCP工具有效载荷示例

有效载荷 add_workout_entry:

{
  "user_id": "b8d932e9-26ef-4f2d-8b7f-cc1e0a3e3b2c",
  "idempotency_key": "workout-2024-09-01-1",
  "workout": {
    "started_at": "2024-09-01T10:00:00Z",
    "ended_at": "2024-09-01T11:00:00Z",
    "timezone": "America/Los_Angeles",
    "title": "Upper Body",
    "source": "manual",
    "notes": "Felt strong"
  },
  "exercises": [
    {
      "display_name": "Bench Press",
      "canonical_name": "bench press",
      "notes": "Working sets",
      "sets": [
        {"reps": 8, "weight": {"value": 135, "unit": "lb"}, "rpe": 7.5},
        {"reps": 6, "weight": {"value": 62.5, "unit": "kg"}, "rpe": 8.0}
      ]
    }
  ]
}

演示摄取

一个小的辅助脚本可以从Python shell运行:

from sqlalchemy.orm import Session
from src.db.session import engine
from src.service.ingest_workout import ingest_workout
import json

with open("examples/sample_workout.json") as f:
    payload = json.load(f)

with Session(engine) as session:
    result = ingest_workout(session, payload)
    print(result)

测试

测试期望通过以下方式提供实时PostgreSQL数据库 DATABASE_URL。如果未设置变量,它们将跳过。 使用Make目标确保本地运行与CI匹配,并通过Docker Compose启动本地Postgres:

# start the database used by tests
make db-up

# wait for Postgres to be ready (optional, test target already does this)
make db-wait

# run the test suite against the configured database
make test

# run all CI checks (tests + Docker image build), with automatic DB lifecycle management
make ci

JSON模式

要导出摄取有效负载的JSON模式,请执行以下操作:

from src.domain.payloads import workout_payload_schema
import json

print(json.dumps(workout_payload_schema(), indent=2))

云运行部署(CI/CD)

GitHub Actions工作流在推送时部署到Cloud Run main.

必需的GitHub机密

  • GCP_WORKLOAD_IDENTITY_PROVIDER
  • GCP_SERVICE_ACCOUNT_EMAIL
  • DB_PASSWORD

GCP设置检查表

  1. 创建一个名为的工件注册表仓库 workout-tracker-mcpus-central1.
  2. 创建一个名为的Cloud SQL Postgres实例 workout-tracker-postgresus-central1.
  3. 创建数据库 workout_tracker 和用户 postgres (或更新工作流变量)。
  4. 为GitHub操作配置工作负载身份联合并授予服务帐户:

- roles/run.admin - roles/iam.serviceAccountUser - roles/artifactregistry.writer - roles/cloudsql.client

工作流文件是 /.github/workflows/deploy-cloudrun.yml.

目录标签

目录标签

数据库服务Python数据验证本地部署健身追踪事务处理

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

oauth

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiooauth部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP