Skip to content

feat(agent): agent-native wave phase 2 — fetch handler, read_state, commands bridge, git agent tools - #144

Closed
antfubot wants to merge 1 commit into
feat/agent-mcp-wave-phase-1from
feat/agent-mcp-wave-phase-2
Closed

feat(agent): agent-native wave phase 2 — fetch handler, read_state, commands bridge, git agent tools#144
antfubot wants to merge 1 commit into
feat/agent-mcp-wave-phase-1from
feat/agent-mcp-wave-phase-2

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Why

Phase 2 of plan 031 (stacked on #142). The MCP endpoint was h3-only, shared state was invisible to tools-only MCP clients, hub commands had no path to the agent surface, and the git plugin's read RPCs — the most obviously agent-useful data in the workbench — weren't exposed.

What

  • createMcpFetchHandler(ctx, options) — the MCP Streamable-HTTP endpoint as a framework-agnostic web-standard Request → Response handler (sessions, origin gate, teardown included). mountMcpHttp is now a thin h3 wrapper over it. This is the enabler for serving MCP from inside non-h3 hosts (@devframes/next, phase 3).
  • Built-in read_state tool — tool-shaped shared-state access (no key → key list, key → JSON value), honoring the same exposeSharedState filter as the resource projection. Many MCP clients only consume tools; the resources stay for those that don't.
  • Hub commands → agent bridge — opt-in agent field on server commands (same default-deny convention as defineRpcFunction): description-as-prompt, safety (default action), optional positional valibot args (single object unwrapped). Projections track register/update/unregister. agent on a handler-less group throws the new DF8404 (docs page included); the field never crosses the wire.
  • devframe/utils/valibot-json-schema — the valibot→JSON-Schema conversion promoted from an MCP-adapter internal to a public util, so SDK-free hosts (the hub) can convert schemas.
  • Schema-typed handlers may be async — the schema-typed definition branch now types handlers as Thenable<InferReturnType<RS>> (explicit RS ⇒ no inference risk; sync handlers stay assignable). This unblocks schema-typing genuinely-async RPCs — the limitation plan 001 previously hit.
  • git agent surfacestatus/log/show/branches/diff agent-flagged with args/returns schemas (safety: 'read' inferred). Write ops stay agent-invisible. Cross-refs plan 029.

Verification

Full gate: pnpm lint && pnpm test && pnpm typecheck && pnpm build — 896 tests (10 new: read_state list/read/filter/deny, commands-bridge projection/re-sync/zero-arg/DF8404/wire-stripping); API snapshots updated deliberately.


This PR was created with the help of an agent.

…ommands bridge, git agent tools

- createMcpFetchHandler: framework-agnostic web-standard MCP endpoint
  extracted from mountMcpHttp (now a thin h3 wrapper); exported from
  devframe/adapters/mcp for custom hosts (Next App Router, etc.)
- built-in read_state(key?) MCP tool over shared state, honoring the
  exposeSharedState filter alongside the resource projection
- hub commands gain opt-in agent exposure: agent field (description,
  safety, valibot args) projects handler-bearing commands into ctx.agent;
  DF8404 rejects agent exposure on group-only commands
- valibot→JSON-Schema conversion moved to devframe/utils/valibot-json-schema
  (public) so SDK-free hosts can convert schemas
- rpc: schema-typed handlers may be async — Thenable<InferReturnType<RS>>
  in the schema-typed definition branch
- git plugin: status/log/show/branches/diff agent-flagged with valibot
  args/returns schemas (read-only surface; writes stay private)
- docs: hub commands-as-tools, read_state, custom-host mounting; DF8404 page
@antfubot

Copy link
Copy Markdown
Collaborator Author

Folded into #145 together with phase 3 — the phase-3 branch already contains these commits, so #145 now targets the phase-1 branch and carries both phases.

@antfubot antfubot closed this Jul 29, 2026
@antfubot
antfubot deleted the feat/agent-mcp-wave-phase-2 branch July 29, 2026 08:39
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.

1 participant