Skip to content

feat!: move the MCP implementation into the optional @devframes/agentic peer (0.10) - #391

Merged
antfu merged 6 commits into
mainfrom
feat/agentic-package
Sep 15, 2026
Merged

antfu merged 6 commits into
mainfrom
feat/agentic-package

Conversation

@antfubot

@antfubot antfubot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

What

Targets v0.10. Introduces @devframes/agentic, a new package that owns the agent-surface implementation (the MCP adapter, the devframe connect gateway, and the MCP SDK behind them) as an optional peer of devframe and @devframes/hub.

devframe/adapters/mcp stays the user-facing API. Users install @devframes/agentic to enable the agent surface but never import it: devframe probes for the peer and lazy-loads it (importRuntimeModule), so neither agentic nor the SDK ever enters a consumer bundle graph. The agentic bare root throws with a pointer at the user-facing API; its /mcp and /connect subpaths exist for devframe's loaders.

The exported signatures are typed against devframe's own contract (types/mcp.ts + internal), so no SDK type leaks and the SDK can be swapped inside agentic later without a breaking change.

The enable matrix

mcp setting agentic installed agentic missing
unset / 'auto' mount iff agent.hasSurface() if surface exists: one-time DF0078 warning, no mount; else silent, zero MCP code loaded
true / route object always mount throw DF0079
false fully silent — no probe, no warning same

Importing devframe/adapters/mcp itself without the peer also throws DF0079. devframe connect throws DF0046 (retargeted from the former @modelcontextprotocol/client peer).

Migration guide

Ships with a new migration-0.10 upgrade guide (newest-first, existing guides renumbered): install @devframes/agentic, imports unchanged, the missing-peer matrix, the devframe connect peer swap, and dropping a direct @modelcontextprotocol/client install.

Notable implementation points

  • The peer probe routes through resolveServicePackage (opaque-parameter createRequire), not a literal createRequire(import.meta.url).resolve(...) — turbopack rewrites the latter into a throwing stub inside a bundled Next hub, which broke the aggregate MCP endpoint in custom-hub-next.
  • devframe/adapters/mcp is a plain static re-export of @devframes/agentic/mcp — synchronous signatures preserved; importing it without the peer throws module-not-found, matching the devframe/adapters/cac precedent for optional peers.
  • Pure agent projections (to-json-schema, stringify) stay in devframe under src/agent/, shared by browser WebMCP (still zero-install) and agentic via devframe/internal.
  • Both reference hubs install the peer, as any consumer wanting MCP now does.
  • Rebased on fix(mcp): prove same-machine callers by peer address, not Origin #390: the peer-address locality gate carries over into agentic, with McpConnectionInfo joining the shared contract in devframe/types.

Breaking (0.10)

  • MCP now requires installing @devframes/agentic (see matrix above); imports are unchanged.
  • devframe no longer depends on @modelcontextprotocol/server nor peer-depends on @modelcontextprotocol/client.

All gates pass: lint, knip, test, typecheck, build, and the full e2e suite locally; CI green.


Created with the help of an agent.

@coldtea-pr-lens

coldtea-pr-lens Bot commented Sep 14, 2026

Copy link
Copy Markdown

◈ PR Lens

🟢 +3 new · 🟠 ~8 changed · 🔴 -0 removed · 2 flows · 21 files · commit 496b769


Architecture

Architecture diagram for devframes/devframe at 496b769

11 components touched across 5 lanes.

Open the interactive canvas


Inside the changed components — 2 views

Component view — MCP Server & Route Subsystem

Lazy-loading MCP adapter and shared schema converters extracted into @⁠devframes/agentic/mcp

Architecture view of Component view — MCP Server & Route Subsystem in devframes/devframe

Component view — CLI Discovery Gateway Subsystem

Dynamic loading of the MCP discovery gateway by devframe connect

Architecture view of Component view — CLI Discovery Gateway Subsystem in devframes/devframe

Data flow

Data flow diagram for devframes/devframe at 496b769

Mounting MCP route on server start · Connecting via devframe connect CLI

Open the interactive canvas


The other flows — 1 sequence

Connecting via devframe connect CLI

Sequence diagram of Connecting via devframe connect CLI in devframes/devframe

View

  • Architecture lens
  • Data flow lens
  • Expand every detail

Tip

The CLI's render reads .github/pr-lens.yml and applies your renames, exclusions and lane pins at draw time.

🪧 More tips
  • Run npx skills add coldteadotai/pr-lens, then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."
  • Run npx @coldtea/pr-lens-cli analyze --base origin/main on a branch, then npx @coldtea/pr-lens-cli render .pr-lens/graph.json. Same lenses, your own model key, before the pull request exists.
  • Untick Architecture lens or Data flow lens under View to hide a diagram, or tick Expand every detail to open every section. The comment redraws in a few seconds.
  • Click the link under each diagram to open it on a canvas you can zoom, pan and step through.
  • The diagrams are links. Click one to open it on the canvas, then press W or click play to walk through the change.
  • Open a diagram on the canvas, then press W or click play to walk through the change one step at a time.
  • Set github.comment.collapsed: true in .github/pr-lens.yml to fold the comment behind one View architecture and data flow row. Drawing still runs on every push.
  • Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and your model provider's key as its api-key to run PR Lens from your own CI. Any /chat/completions endpoint works.
  • Push a commit and the comment redraws for the new head. A slow older run never overwrites a newer one.
  • Switch GitHub to dark mode and the diagrams follow. The moving dots are this pull request's data in motion.

Thanks for using PR Lens! It's built by Coldtea, free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

@vercel

vercel Bot commented Sep 14, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
devframe Ready Ready Preview Sep 15, 2026 12:28am UTC

…ic peer

The MCP implementation, the connect gateway, and the MCP SDK behind them
move out of devframe into the new @devframes/agentic package, an optional
peer of devframe and @devframes/hub. devframe stays slim; installing the
peer is what turns the agent surface on. Users never import agentic:
devframe/adapters/mcp stays the user-facing API and loads the peer lazily.

- @devframes/agentic ships /mcp and /connect entries consumed by devframe's
  loaders; the bare root throws. Signatures are typed against devframe's own
  contract, so no SDK type leaks and the SDK stays swappable.
- The mcp enable matrix: 'auto' mounts iff the agent surface is non-empty
  AND the peer resolves (missing peer: one DF0078 warning per process); an
  explicit setting - or importing devframe/adapters/mcp - throws DF0079
  without the peer; false stays silent.
- devframe/adapters/mcp keeps its exports unchanged, built in its own graph
  so its top-level await cannot reshape the server chunking.
- The peer probe routes through resolveServicePackage (an opaque-parameter
  createRequire), not a literal createRequire(import.meta.url).resolve,
  which turbopack rewrites into a throwing stub inside a bundled Next hub.
- Pure agent projections (to-json-schema, stringify) stay in devframe under
  src/agent/, shared by browser WebMCP and agentic via devframe/internal.
- devframe drops @modelcontextprotocol/server (dep) and /client (optional
  peer); DF0046 now points at @devframes/agentic. The reference hubs install
  the peer, as any consumer wanting MCP now does.
@antfubot antfubot changed the title feat!: move the MCP adapter into the optional @devframes/agentic peer feat!: move the MCP implementation into the optional @devframes/agentic peer (0.10) Sep 14, 2026
Replaces the alias's top-level await with a per-function lazy import:
importing the entry is now side-effect-free (DF0079 moves to call time),
and without TLA the entry rejoins the main server build graph, dropping
the isolated tsdown config. createMcpFetchHandler and mountMcpHttp become
async through this entry; the migration guide covers the added await.
…c peer

Replaces the per-function lazy import with a plain re-export of
@devframes/agentic/mcp, keeping the implementation's synchronous
signatures. Importing the entry without the peer now throws
module-not-found, matching the devframe/adapters/cac precedent for
optional peers; first-party adapters keep the coded DF0078/DF0079
lazy-load path.
@antfu
antfu merged commit 70e95ad into main Sep 15, 2026
13 of 14 checks passed
@antfu
antfu deleted the feat/agentic-package branch September 15, 2026 00:26
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