Skip to content

Draft: Upgrade MCP SDK & Cloudflare transport; add resource generation, validation, and CI#50

Merged
Trailgenic merged 4 commits into
mainfrom
codex/modernize-trailgenic-mcp-implementation
Jul 14, 2026
Merged

Draft: Upgrade MCP SDK & Cloudflare transport; add resource generation, validation, and CI#50
Trailgenic merged 4 commits into
mainfrom
codex/modernize-trailgenic-mcp-implementation

Conversation

@Trailgenic

Copy link
Copy Markdown
Owner

Motivation

  • Replace the handwritten MCP JSON-RPC dispatcher with the official Model Context Protocol SDK and Cloudflare stateless Workers integration while preserving the public read-only TrailGenic data contract and tools.
  • Add deterministic bundled resources and registry/bundle parity validation to remove the mutable GitHub-main runtime fallback and make deployments CI-safe.
  • Harden transport policy: Accept/Content-Type normalization, MCP protocol negotiation, and browser Origin validation for the MCP transport.

Description

  • Add package metadata and test/CI scripts in package.json and package-lock.json, declaring @modelcontextprotocol/sdk@^1.29.0, agents@^0.0.115, zod@^3.25.76, and ajv@^8.17.1 plus Worker test and Wrangler dev deps.
  • Implement an official MCP server factory createTrailgenicMcpServer using McpServer from @modelcontextprotocol/sdk/server/mcp.js with Zod/Ajv input-schema adapters, Ajv runtime validation, per-tool annotations, isError: true business-error results, and conditioning date-range error behavior (lib/mcp-server.js).
  • Route MCP POST through Cloudflare's createMcpHandler from agents/mcp with JSON response mode and a fresh server instance per request, add Accept-normalization, strict JSON Content-Type checks, MCP protocol-version validation, and configurable MCP allowed origins (tool-registry/worker.js).
  • Generate MCP resources from canonical registries and add resource read/list helpers with stable URIs trailgenic://datasets/{id} and trailgenic://physiology/{slug} (lib/resources.js) and include resources in discovery/capabilities/tool-registry outputs.
  • Remove runtime fallback to GitHub main for datasets so missing bundled data returns a clear server error; preserve all dataset files and workers/permit-poller/ unchanged.
  • Bump server BUILD.version to 1.4.0 and released to 2026-07-14, and advertise supported MCP protocol versions 2025-11-25 and 2025-06-18 (lib/registry.js).
  • Add deterministic validation scripts and tests: scripts/validate-json.mjs, scripts/validate-registry.mjs, pure node:test registry tests, a Worker-oriented Vitest file scaffold, and CI workflows .github/workflows/ci.yml and updated deploy workflow.

Testing

  • Ran lint (npm run lint) and basic source checks which completed successfully.
  • Ran pure unit tests (node --test tests/registry.test.mjs) and registry parity checks (node scripts/validate-registry.mjs), both succeeded.
  • Ran JSON validation (node scripts/validate-json.mjs) which succeeded.
  • Attempts to run npm ci, Worker-runtime Vitest tests (npm run test:workers), and wrangler dry-run failed locally because the environment returned 403 Forbidden from the npm registry for required packages, so Worker runtime tests, Wrangler dry-run, bundle-size measurements, CI runs on GitHub Actions, and live acceptance could not be completed here.

Codex Task

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workers Ready Ready Preview, Comment Jul 14, 2026 4:15am

Request Review

@Trailgenic
Trailgenic merged commit 2b83eff into main Jul 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant