Skip to content

feat(mcp): agent-native wave phase 1 — bridge MCP forwarding + structured diagnostic errors - #142

Merged
antfu merged 1 commit into
mainfrom
feat/agent-mcp-wave-phase-1
Jul 28, 2026
Merged

feat(mcp): agent-native wave phase 1 — bridge MCP forwarding + structured diagnostic errors#142
antfu merged 1 commit into
mainfrom
feat/agent-mcp-wave-phase-1

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Why

Plan 031 (agent-native MCP wave, included here) adopts the architecture Vercel's next-devtools-mcp 0.4.0 validated: the real MCP endpoint lives inside the framework, and external tooling just discovers and proxies it. Devframe already serves route-based MCP on the dev server — but neither hosted bridge could enable or advertise it, and coded errors crossed the MCP boundary as flattened strings.

What

  • Bridge MCP forwarding. viteDevBridge and @devframes/next's createDevframeNextHandler gain an mcp option (forwarded to createDevServer) and advertise the side-car endpoint in their hand-rolled __connection.jsonConnectionMeta['mcp'] gains an optional port for side-car origins, mirroring the WS meta. Shared resolver resolveMcpConnectionMeta exported from devframe/adapters/dev.
  • Structured diagnostic errors. formatMcpError now emits { error: { code, message, fix?, docs? } } for nostics Diagnostics, so agents receive the actionable next step and docs URL instead of a bare message.
  • Docs. The agent-native guide documents the conventions this wave standardizes: description-as-prompt, gateway tools, structured errors. Stale "HTTP planned" comment in build-server.ts corrected.
  • Plan. plans/031-agent-native-mcp-wave.md (umbrella for the three phases) + README row.

Phase 2 (fetch-handler extraction, read_state, hub commands→agent bridge, git agent flags) and Phase 3 (instance registry, devframe connect, in-process Next MCP, e2e proofs) follow as stacked PRs.

Verification

Full gate: pnpm lint && pnpm test && pnpm typecheck && pnpm build — 886 tests incl. new vite-bridge/next-handler MCP round-trips against a real MCP SDK client; API snapshots updated deliberately (new mcp options + meta port).


This PR was created with the help of an agent.

…red diagnostic errors

- viteDevBridge and @devframes/next's createDevframeNextHandler gain an
  mcp option, forwarded to createDevServer, and advertise the side-car
  endpoint in their connection meta (ConnectionMeta.mcp gains port)
- resolveMcpConnectionMeta shared resolver exported from adapters/dev
- formatMcpError emits structured JSON { error: { code, message, fix,
  docs } } for nostics Diagnostics so agents get the actionable next step
- agent-native guide: description-as-prompt, gateway tools, structured
  errors conventions
- plans/031 umbrella plan (agent-native MCP wave) + README row
@netlify

netlify Bot commented Jul 28, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 801177e
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a6862475930df00089e42e2
😎 Deploy Preview https://deploy-preview-142--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@antfu
antfu merged commit 96a8040 into main Jul 28, 2026
12 checks passed
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