Add an @netscript/ai/mcp subpath that wraps @tanstack/ai-mcp behind a McpTransportPort, covering stdio and reconnectable Streamable-HTTP transports with none/api-token/oauth auth, and surfaces remote MCP tools into the core tool registry.
Context
Part of epic #238 · cluster ENGINE · wave v1 · depends-on E1, E4
E5 sits in the engine wave alongside the provider adapters and tool registry: it needs the core @netscript/ai port/registry contracts (E1) and the tool-registry surface (E4) in place before remote MCP tools can be registered against it. It ships after those land so the registry has a real slot to receive MCP-sourced tools rather than a placeholder.
Problem / motivation
Today there is no NetScript-native way to consume an MCP server as a tool source. eis-chat hand-rolls MCP wiring per-app (transport selection, reconnect/backoff, auth header plumbing) with no shared port, no connection state machine, and no reuse across providers or apps. Per the standalone-core adapter-by-subpath doctrine (mirroring @netscript/kv / @netscript/kv/redis), MCP integration belongs in @netscript/ai as a self-contained subpath, not as app-level glue or a separate packages/ai-mcp package.
Scope
Ships
packages/ai/mcp.ts (or src/mcp/mod.ts re-exported at ./mcp) implementing McpTransportPort.
- Transport implementations: stdio transport, reconnectable Streamable-HTTP transport (backoff + resume) wrapping
@tanstack/ai-mcp.
- Auth modes:
none, api-token, oauth (token/credential supplied via injected config, no hardcoded secret handling).
- A connection state machine (e.g.
disconnected -> connecting -> connected -> reconnecting -> closed) with explicit transitions and a stop()/dispose path per F-13.
- Registration path that surfaces remote MCP tools into the
ToolRegistryPort/registry established in E4 (tool discovery on connect, de-registration on disconnect).
- Unit tests for transport selection, reconnect/backoff behavior, and auth-mode wiring.
Out of scope
- OTel spans/tracing for MCP connections and tool calls — owned by E9 (the sole
./otel + TelemetryPort slice).
- Core port/registry contracts and provider adapters themselves — owned by E1.
- Tool registry surface and invocation contract — owned by E4.
- Any fresh/ai or fresh-ui wiring of MCP-sourced tools into chat UI — owned by the fresh/ai and fresh-ui clusters.
- Named orchestration strategies over MCP tools — out of scope per the v1 primitives-only orchestration decision.
Public surface
- New subpath export:
@netscript/ai/mcp (added to packages/ai/deno.json exports).
McpTransportPort interface (connect, disconnect/stop, state, tool discovery callback).
StdioMcpTransport and StreamableHttpMcpTransport (or equivalently named) implementations of McpTransportPort.
McpAuthMode union type: "none" | "api-token" | "oauth".
McpConnectionState type/enum for the connection state machine.
- Registration function(s) wiring an
McpTransportPort instance into the E4 tool registry (e.g. registerMcpTools(registry, transport)).
Acceptance & fitness gates
Dependencies
Depends on E1, E4 (GitHub numbers tracked in the #238 DAG checklist). Not blocked by #239.
Size
L
Add an
@netscript/ai/mcpsubpath that wraps@tanstack/ai-mcpbehind aMcpTransportPort, covering stdio and reconnectable Streamable-HTTP transports with none/api-token/oauth auth, and surfaces remote MCP tools into the core tool registry.Context
Part of epic #238 · cluster ENGINE · wave v1 · depends-on E1, E4
E5 sits in the engine wave alongside the provider adapters and tool registry: it needs the core
@netscript/aiport/registry contracts (E1) and the tool-registry surface (E4) in place before remote MCP tools can be registered against it. It ships after those land so the registry has a real slot to receive MCP-sourced tools rather than a placeholder.Problem / motivation
Today there is no NetScript-native way to consume an MCP server as a tool source.
eis-chathand-rolls MCP wiring per-app (transport selection, reconnect/backoff, auth header plumbing) with no shared port, no connection state machine, and no reuse across providers or apps. Per the standalone-core adapter-by-subpath doctrine (mirroring@netscript/kv/@netscript/kv/redis), MCP integration belongs in@netscript/aias a self-contained subpath, not as app-level glue or a separatepackages/ai-mcppackage.Scope
Ships
packages/ai/mcp.ts(orsrc/mcp/mod.tsre-exported at./mcp) implementingMcpTransportPort.@tanstack/ai-mcp.none,api-token,oauth(token/credential supplied via injected config, no hardcoded secret handling).disconnected -> connecting -> connected -> reconnecting -> closed) with explicit transitions and astop()/dispose path per F-13.ToolRegistryPort/registry established in E4 (tool discovery on connect, de-registration on disconnect).Out of scope
./otel+TelemetryPortslice).Public surface
@netscript/ai/mcp(added topackages/ai/deno.jsonexports).McpTransportPortinterface (connect, disconnect/stop, state, tool discovery callback).StdioMcpTransportandStreamableHttpMcpTransport(or equivalently named) implementations ofMcpTransportPort.McpAuthModeunion type:"none" | "api-token" | "oauth".McpConnectionStatetype/enum for the connection state machine.McpTransportPortinstance into the E4 tool registry (e.g.registerMcpTools(registry, transport)).Acceptance & fitness gates
mcp.tssits in the adapters layer, depends only on core ports/domain, no reverse imports from application into domain.@module+ JSDoc on all exported symbols;./mcpsubpath stays at or under 20 exports in its entry module.deno task publish:dry-runWITHOUT--allow-slow-types.stop()/dispose and respectAbortSignalfor in-flight connects/reconnects.none,api-token,oautheach drive the correct handshake/header path against a fake MCP server.Dependencies
Depends on E1, E4 (GitHub numbers tracked in the #238 DAG checklist). Not blocked by #239.
Size
L