Skip to content

feat(serve): identity-scoped stack MCP server over HTTP (stack#7)#20

Merged
amitpaz1 merged 1 commit into
mainfrom
feat/stack-7-stack-mcp
Jun 26, 2026
Merged

feat(serve): identity-scoped stack MCP server over HTTP (stack#7)#20
amitpaz1 merged 1 commit into
mainfrom
feat/stack-7-stack-mcp

Conversation

@amitpaz1

Copy link
Copy Markdown
Member

Closes agentkitai/agentkit-stack#7. agentkit serve --identity <id> exposes a running stack to LLM clients over MCP (Streamable-HTTP), bound to a single minted identity — not a universal gateway proxy (the gateway-parity anti-goal). Sequences after #9/stack#3/#10.

Identity-scoping enforced two ways:

  • loadServingIdentity() — the server refuses to start unless it holds the identity's private key (present + matches), so it can only act AS that identity.
  • every tool result is stamped servedBy {id, fingerprint}.

Read/verify-scoped tool set: identity_whoami, status, audit_verify, evidence_export — no mint/init/scaffold (those broaden the surface beyond stack-interaction).

  • runStackMcpServer() serves over the SDK's StreamableHTTPServerTransport (stateless — fresh transport+server per request, no cross-identity session state). SDK + node:http via dynamic import. Returns {port, close}.

Tests: 8 (scoped tool set, whoami, servedBy stamp, loadServingIdentity load/missing/key-absent, server start+404+close / refuse-without-identity) + a live MCP-over-HTTP smoke (tools/list → the 4 scoped tools). Full suite 81.

`agentkit serve --identity <id>` exposes a running stack to LLM clients over MCP
(Streamable-HTTP), bound to a single minted identity — NOT a universal gateway
proxy (the gateway-parity anti-goal). Sequences after #9 (identity), stack#3
(audit), #10 (MCP wrapper).

Identity-scoping is enforced two ways:
- src/mcp/stack-tools.ts loadServingIdentity(): the server refuses to start
  unless it holds the identity's private key (present + matches), so it can only
  act AS that identity.
- every tool result is stamped `servedBy {id, fingerprint}`.

The tool set is deliberately read/verify-scoped: identity_whoami, status,
audit_verify, evidence_export — no mint/init/scaffold (those aren't "interact
with the running stack" and would broaden the surface). Reuses the existing
command functions.

- src/mcp/stack-server.ts: runStackMcpServer() serves the scoped tools over the
  SDK's StreamableHTTPServerTransport (stateless: fresh transport+server per
  request, no cross-identity session state). SDK + node:http via dynamic import
  (ESM-from-CJS). Returns {port, close} for clean lifecycle/testing.
- cli.ts: `agentkit serve` (--identity required, --port, --store).

Tests: 8 — scoped tool set (only read/verify), whoami, servedBy stamping,
loadServingIdentity (loads valid / throws missing / refuses key-absent),
runStackMcpServer (starts on a usable identity + 404s non-/mcp + closes / refuses
without identity). Plus a live MCP-over-HTTP smoke (tools/list → the 4 scoped
tools). Full suite 81 green.

Closes agentkitai/agentkit-stack#7.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019tXZpN29akdmG8AEjgSZwk
@amitpaz1 amitpaz1 merged commit 36b15b0 into main Jun 26, 2026
1 check passed
@amitpaz1 amitpaz1 deleted the feat/stack-7-stack-mcp branch June 26, 2026 16:20
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.

Expose running stack as identity-scoped MCP server (sequence after #3/#10; watch gateway-parity anti-goal)

1 participant