Skip to content

Hosted MCP demo at triplex.build/mcp - #117

Open
bjacobso wants to merge 6 commits into
mainfrom
hosted-mcp
Open

bjacobso wants to merge 6 commits into
mainfrom
hosted-mcp

Conversation

@bjacobso

@bjacobso bjacobso commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

This adds a hosted MCP server at triplex.build/mcp, so you can tell an agent "try triplex.build/mcp" and it finds out what Triplex does on its own. It follows the forma-lang.com/mcp design and is built end-to-end with Alchemy and Effect.

  • Effect-native Worker (packages/site/src/worker.ts): Cloudflare.Workers.Worker serving static ASSETS to browsers and answering MCP clients at /mcp over Streamable HTTP. Binds TriplexSession and Cloudflare.Workers.RateLimit("MCP_CALLS") directly in Effect.
  • Effect-native Durable Object (packages/site/src/session.ts, packages/site/src/runtime.ts): Cloudflare.Workers.DurableObject (TriplexSession) running Effect's own McpServer.layerHttp (effect/ai) directly over HttpRouter — no @modelcontextprotocol/sdk dependency. Persists the client's initialize request in storage and replays it on wake so sessions survive Durable Object eviction seamlessly. Each session's SQLite storage holds its own Triplex database, seeded with the homepage site-safety story (six real attributed commands).
  • Tools: the 16 tools from triplex mcp, plus tour (the loaded story and questions worth asking) and reset (restore the starting story while keeping the MCP session active).
  • Limits: 120 calls per minute per IP, a 64 KB cap on requests, writes refused once a session's database passes 25 MB, uninitialized session IDs rejected with 404 without creating storage, and sessions deleted after 24 hours idle. A DELETE request ends a session.
  • Storage adapter (packages/site/src/kv.ts): runs Triplex's supported KV hexastore on Durable Object SQLite (one table, byte-ordered keys, writes buffered and applied in one transactionSync). Does not use or change the frozen /cloudflare backend.
  • Stack (alchemy.run.ts): Command.Build + Effect-native Cloudflare.Workers.Worker, preserving the existing Docs and Docs/Build FQNs, Worker name, and triplex.build domain. Merging does not deploy it; the next docs deploy ships it.
  • Local dev & tests: pnpm site:dev runs alchemy dev --stage local with on-disk state (no Cloudflare account needed; use pnpm docs:dev for VitePress hot reload). Tests in packages/site/test/site.test.ts use alchemy/Test/Vitest with State.inMemoryState() to run the real Effect Worker and a conformance Effect Durable Object in local workerd. No Wrangler config or dependency and no @cloudflare/vitest-plugin in packages/site.
  • docs/mcp.md gains a "Try it without installing" section.
  • packages/site is a new private workspace package outside the published package, so there is no Changeset.

Verification

  • pnpm check passed in full (format, lint, scripts/check-alchemy.mjs, typecheck, docs:check, full test suite, package builds, docs build + llms.txt).
  • pnpm pack:check: not run. This PR changes no published package.
  • Verified node scripts/check-alchemy.mjs and packages/site tests both pass with packages/triplex/dist removed (matching a fresh CI checkout).
  • New Alchemy/workerd tests in packages/site/test/site.test.ts:
    • Triplex's full shared Triples conformance suite against durableObjectKvLayer on native Durable Object SQLite inside an Effect Durable Object (verified it fails when reverse range scans are broken).
    • Full MCP round trip over HTTP: CORS preflight, browser Origin header, unknown session 404, initialize (2025-11-25 and 2025-06-18), tour, bitemporal reads ("as known now" vs "as known when placed"), transaction_apply + duplicate commandId rejection, session isolation, reset, and DELETE -> 404.
  • Also drove pnpm site:dev locally over HTTP, including restarting the dev process to verify Durable Object eviction recovery preserves session writes and replays initialization.

Architecture and release

  • The one-way package graph in ARCHITECTURE.md is preserved. packages/site imports only public subpaths of @triplex-build/triplex.
  • External dependency versions are pinned in the root pnpm catalog (no new external dependencies added; @modelcontextprotocol/sdk and wrangler were removed).
  • Public exports resolve only to built files in dist. No exports changed.
  • User-visible package changes include a Changeset when appropriate. No published package changed.

ampagent and others added 2 commits November 23, 2026 20:08
The docs Worker now answers MCP clients at /mcp (Streamable HTTP) and keeps
serving the docs to browsers. Each MCP session gets its own Durable Object,
whose SQLite storage holds a Triplex database (the KV hexastore over one
byte-ordered table) seeded with the homepage site-safety story. It serves the
triplex mcp tools plus tour and reset, deletes a session after a day idle,
rate limits per client address, caps request size and database size.

The adapter passes the shared Triples conformance suite in workerd.

Amp-Thread-ID: https://ampcode.com/threads/T-01a209f5-723e-73d9-a31a-8c5d49e1c44e
Co-authored-by: Ben Jacobson <[email protected]>
CI deploys before the single package's dist is built, so the bundler left
@triplex-build/triplex/* imports unresolved and the Worker failed at startup.
Alias workspace packages to their sources, as the workerd tests do.

Amp-Thread-ID: https://ampcode.com/threads/T-01a209f5-723e-73d9-a31a-8c5d49e1c44e
Co-authored-by: Ben Jacobson <[email protected]>
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Documentation preview: https://triplex-docs-pr-117.bjacobso.workers.dev

Commit: af66ffa

ampagent and others added 4 commits November 23, 2026 21:05
pnpm site:dev runs alchemy dev on a local stage whose state is on disk, so
it needs no Cloudflare account. The Worker runs in local workerd over the
built site, so /mcp works locally. Drop the wrangler dev config and the
wrangler dependency; the workerd tests keep wrangler.test.jsonc, which
@cloudflare/vitest-plugin reads.

Amp-Thread-ID: https://ampcode.com/threads/T-01a209f5-723e-73d9-a31a-8c5d49e1c44e
Co-authored-by: Ben Jacobson <[email protected]>
The test config evaluates the Alchemy stack and passes the Docs Worker's
entry, compatibility settings, Durable Object and rate limit bindings to
@cloudflare/vitest-plugin as inline Miniflare options, so the tests run the
Worker alchemy.run.ts deploys and wrangler.test.jsonc is gone.

Amp-Thread-ID: https://ampcode.com/threads/T-01a209f5-723e-73d9-a31a-8c5d49e1c44e
Co-authored-by: Ben Jacobson <[email protected]>
…Effect

- Worker (packages/site/src/worker.ts): Effect-native Cloudflare.Workers.Worker
  binding TriplexSession and Cloudflare.Workers.RateLimit directly, serving
  static ASSETS and /mcp via Effect HttpServerRequest/HttpServerResponse.
- Durable Object (packages/site/src/session.ts, runtime.ts): Effect-native
  Cloudflare.Workers.DurableObject running Effect's own Streamable HTTP
  McpServer.layerHttp (dropping @modelcontextprotocol/sdk completely). Persists
  initialize parameters in storage to survive DO eviction cleanly.
- Stack (alchemy.run.ts): Command.Build + Effect-native Cloudflare.Workers.Worker
  preserving the Docs and Docs/Build FQNs.
- Tests (packages/site/test/site.test.ts): alchemy/Test/Vitest deploying the
  real Effect Worker and a conformance Effect Durable Object in local workerd
  (dropping @cloudflare/vitest-plugin and all Wrangler config).

Amp-Thread-ID: https://ampcode.com/threads/T-01a209f5-723e-73d9-a31a-8c5d49e1c44e
Co-authored-by: Ben Jacobson <[email protected]>
alchemy.run.ts imports the Effect-native site Worker, whose runtime module
imports @triplex-build/triplex/*. Running turbo run typecheck first builds
the workspace package declarations before tsc checks tsconfig.alchemy.json.

Amp-Thread-ID: https://ampcode.com/threads/T-01a209f5-723e-73d9-a31a-8c5d49e1c44e
Co-authored-by: Ben Jacobson <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants