This repository now runs as a single Cloudflare Worker deployment that hosts:
- A remote MCP server (
/sse+/mcp) - Stateful MCP sessions via Durable Objects
- A self-contained React widget (JS/CSS inlined into HTML tool output)
src/
index.ts # Worker entry + MCP server routes
data.ts # Domain logic used by MCP tools
session-do.ts # Durable Object for session state
widget/
src/index.tsx # Widget entry point
src/app.tsx # Widget UI
vite.config.ts # Build emits index.js + style.css for inlining
.github/workflows/deploy.yml
wrangler.toml
pnpm install
pnpm --dir widget install
pnpm devWorker runs on http://localhost:8787.
pnpm build- build widget and dry-run worker bundlepnpm tunnel- expose localhost for ChatGPT testingpnpm inspector- run MCP inspector againsthttp://localhost:8787/ssepnpm deploy:dev|test|prodpnpm logs:dev|test|prod
Use the script below to build, launch, validate, and optionally keep the local worker running for a live demo:
pwsh ./scripts/local-e2e-demo.ps1Options:
-SkipInstallskips dependency installation if already installed-KeepRunningleavespnpm devrunning after tests for live walkthroughs-BaseUrloverrides the target URL (defaulthttp://127.0.0.1:8787)
- Deploy (or tunnel) the worker.
- In ChatGPT MCP connector setup, use the Worker SSE URL:
https://<your-worker-domain>/sse
- The streamable HTTP endpoint is:
https://<your-worker-domain>/mcp
- Verify health:
https://<your-worker-domain>/healthshould returnok
GET http://localhost:8787/=> connection instructions JSONGET http://localhost:8787/health=> 200 OKGET http://localhost:8787/sse=> SSE transportPOST http://localhost:8787/mcp=> streamable HTTP MCP
- If widget HTML is blank, run
pnpm --dir widget buildand redeploy. - If ChatGPT connection fails, ensure you configured the
/sseURL (not root). - If state is not retained, verify Durable Object binding
SESSION_DOis present inwrangler.tomland deployed migrationv1was applied.
GitHub Actions workflow .github/workflows/deploy.yml deploys:
- dev on pull request opened/updated
- test on pushes to
main - prod via
workflow_dispatch
Use GitHub environments dev, test, prod and add protection rules to prod for manual approval.