◈ Drawn by PR Lens, free for open source
feat(devframe): serve MCP by default when an agent surface exists
devframes/devframe #332
Architecture
Open full size
Container view — Architecture
Switches the route-based MCP Streamable-HTTP endpoint across Devframe core, hub orchestration, and host framework kits to default to 'auto'. Rather than requiring explicit MCP opt-in, instances inspect their registered agent tools, resources, and agent-flagged RPC functions via DevframeAgentHost.hasSurface(), dynamically mounting the /__mcp endpoint and loading the MCP adapter only when an agent surface is active. When no agent surface is detected, no MCP route is mounted and zero MCP SDK code is loaded, preserving lightweight bundles. In addition, @modelcontextprotocol/server is made a direct dependency of devframe, while @modelcontextprotocol/client remains an optional peer dependency for the CLI connector.
FRAMEWORK KITS & HOSTS
HUB ORCHESTRATION
DEVFRAME CORE ENGINE
CLIENT RUNTIMES & UI
Next.js Reference Hu…
CHANGED
Vite Framework Kit
CHANGED
Next.js Framework Kit
CHANGED
{ }
Hub Commands Subsystem
Hub Core & Lifecycle
CHANGED
{ }
Devframe Agent Host
NEW
{ }
CLI MCP Gateway
CHANGED
Single-Tool Instance Shell
CHANGED
MCP HTTP Route Ha…
CHANGED
{ }
Host & Build Adapters
CHANGED
{ }
Browser RPC Client
configures hub with mcp: 'auto'
forwards mcp: 'auto'
configures Next hub with mcp: 'auto'
mounts devframe handler with mcp: 'auto'
uses Next hub
mounts frames & checks agent surface
mounts aggregate /__mcp route
invoked by CAC and dev server
mounts when agent surface exists (auto)
dials MCP endpoints via client SDK
Data flow
Open full size
Automatic MCP route mounting on agent surface detection
Switches the route-based MCP Streamable-HTTP endpoint across Devframe core, hub orchestration, and host framework kits to default to 'auto'. Rather than requiring explicit MCP opt-in, instances inspect their registered agent tools, resources, and agent-flagged RPC functions via DevframeAgentHost.hasSurface(), dynamically mounting the /__mcp endpoint and loading the MCP adapter only when an agent surface is active. When no agent surface is detected, no MCP route is mounted and zero MCP SDK code is loaded, preserving lightweight bundles. In addition, @modelcontextprotocol/server is made a direct dependency of devframe, while @modelcontextprotocol/client remains an optional peer dependency for the CLI connector.
{ }
Host & Build Adapters
CHANGED
Single-Tool Instance Shell
CHANGED
{ }
Devframe Agent Host
NEW
MCP HTTP Route Handler
CHANGED
initDevframe(def, { mcp: 'auto' })
queries hasSurface()
returns true (tools/resources/agent-RPC found)
lazily imports adapter and mounts /__mcp route
View the pull request on GitHub
feat(devframe): serve MCP by default when an agent surface exists