feat(serve): identity-scoped stack MCP server over HTTP (stack#7)#20
Merged
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.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'sStreamableHTTPServerTransport(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.