Purpose
This package is part of wasmagent (a TypeScript + WASM agent runtime), and its core purpose is to expose any wasmagent agent as a Model Context Protocol (MCP) server for invocation by MCP-capable hosts.
Main capabilities
- Transport-agnostic server: McpAgentServer handles JSON-RPC through a single handle(req) method and is not bound to a specific transport.
- Three access methods:
- Stdio: suitable for scenarios such as Claude Desktop, Cursor, and Glama health checks; in actual deployment, a small Node script can be written and runStdio() called.
- HTTP / Streamable: suitable for environments such as Cloudflare Workers and Vercel.
- Direct handle(): custom transports can directly call the protocol-layer entry point.
- Code mode (dual-tool interface): createCodeModeServer() can wrap any tool registry as an MCP interface of docs_search + execute_code. According to the material, when the number of downstream tools is N=30, the bootstrap token cost drops to 13.6% of the direct approach; the model calls execute_code to execute a script, and the script calls callTool(...) as needed, all under the same CapabilityManifest.
- CapabilityManifest: for every script the model runs through execute_code, network and filesystem policies are enforced at the kernel boundary; regardless of which downstream tools the script calls, this declaration covers the entire execute_code interface.
Usage
The material provides a Stdio deployment approach: write a small Node script and call runStdio() passing in a custom server; complete code examples for HTTP/Streamable and direct handle() are not fully given in the material. Usage instructions for code mode point to docs/guides/code-mode.md.
Applicable scenarios
Suitable for developers who need to connect wasmagent agents to MCP hosts, including desktop clients (Stdio), Serverless/edge environments (HTTP/Streamable), and custom transport integrations; also suitable for scenarios that aim to reduce the bootstrap token overhead caused by a large number of downstream tools through code mode and to uniformly enforce network and filesystem policies within the sandbox.
Limitations
- Maturity is beta, and the API shape may change in minor versions; changes will be announced in the CHANGELOG.
- The material does not provide installation commands, specific dependency versions, performance benchmark details, or complete code examples.
- The license is Apache-2.0.