@astral-mcp/projection 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Matthew Rust
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # @astral-mcp/projection
2
+
3
+ Turn any MCP server into a **code-mode** server with **human-approved side
4
+ effects**, built on MCP MRTR (Multi Round-Trip Requests, revision
5
+ 2026-07-28) and XState v5.
6
+
7
+ Projection wraps an existing MCP server and exposes exactly two tools:
8
+
9
+ - **`execute_machine`** — runs an LLM-authored XState v5 state machine in a
10
+ QuickJS WebAssembly sandbox. Read-only tool calls execute immediately;
11
+ any write suspends the machine into a sealed, encrypted blob and asks the
12
+ human to approve that exact call via MRTR elicitation.
13
+ - **`discover_apis`** — returns generated TypeScript definitions and the
14
+ authoring contract for the wrapped server's tools.
15
+
16
+ All suspension state rides the MRTR `requestState` payload, so Projection is
17
+ fully stateless: any server instance can resume any workflow.
18
+
19
+ ## Usage
20
+
21
+ ```ts
22
+ import { createMcpHandler } from '@modelcontextprotocol/server';
23
+ import { wrapMcpServer } from '@astral-mcp/projection';
24
+
25
+ const facade = await wrapMcpServer(myMcpServer, {
26
+ blob: { key: myThirtyTwoByteKey }, // shared across instances
27
+ policy: { query: 'ask' }, // override annotations per tool
28
+ redact: (tool, args) => ({ ...args, token: '[redacted]' }),
29
+ });
30
+
31
+ export default createMcpHandler(facade.serverFactory);
32
+ ```
33
+
34
+ `serverFactory` carries the negotiated protocol era into each serving unit:
35
+ modern (2026-07-28) clients get MRTR approval round trips; legacy clients
36
+ still run read-only machines and get a structured error the moment a
37
+ machine needs approval. You can also wrap a connected SDK `Client` to put
38
+ Projection in front of a server you don't own.
39
+
40
+ ## Security model
41
+
42
+ | Invariant | How it holds |
43
+ | ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
44
+ | The tools bridge is the only way out of the sandbox | No `fetch`, no filesystem, no host globals; only `xstate` and `@astral-mcp/tools` resolve as imports |
45
+ | No gated call runs without a matching approval | The approved name and arguments are sealed in the blob and executed from there |
46
+ | Clients are untrusted couriers | Blobs are AES-256-GCM encrypted under a per-blob HKDF-derived key and authenticated |
47
+ | A snapshot cannot resume under different code | The blob binds a SHA-256 hash of the original `code` |
48
+ | A wrapped server's annotations are hints, not authority | Unannotated tools default to asking; developer overrides always win |
49
+ | Approval prompts cannot be forged | Prompt text comes from the catalog and redacted arguments, rendered inert |
50
+
51
+ ## Documentation
52
+
53
+ - [Server-author integration guide](https://github.com/astralMCP/projection/blob/main/docs/server-authors.md)
54
+ — policy, blob-key operations, resource caps, lifecycle
55
+ - [Product requirements](https://github.com/astralMCP/projection/blob/main/docs/PRD.md)
56
+ and [engineering decisions](https://github.com/astralMCP/projection/blob/main/docs/DECISIONS.md)
57
+ - [Repository](https://github.com/astralMCP/projection) — scenario test
58
+ harness, self-heal benchmark, and an interactive demo TUI live alongside
59
+ the library
60
+
61
+ Requires Node ≥ 22. MIT licensed.