@engramx/owner-mcp 0.1.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,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 EngramX contributors
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # @engramx/owner-mcp
2
+
3
+ The **owner-side** MCP server for EngramX — reserve, activate, and check an engram **you own**, from any
4
+ MCP host (Claude Desktop, Codex, …).
5
+
6
+ It is the owner counterpart to **`@engramx/mcp`** (the operator server). This server **never operates**
7
+ memory — no read, no append. That is the append-only operator surface, kept in a separate package so an
8
+ operator host never gains owner powers.
9
+
10
+ | | lib / CLI | MCP server |
11
+ | --- | --- | --- |
12
+ | **owner** (create + own) | `@engramx/owner` | **`@engramx/owner-mcp`** ← this |
13
+ | **operator** (append-only) | `@engramx/client` | `@engramx/mcp` |
14
+
15
+ ## Reserve, then activate
16
+
17
+ The tools map to EngramX's cycle anti-drain:
18
+
19
+ - **`engram_status`** — read-only: do you have nothing, a free reservation, or a live engram?
20
+ - **`engram_reserve`** — a **free** registry record (~$0). No canister, no spend. Idempotent.
21
+ - **`engram_activate`** — **spawns the live canister** (the platform funds it). The committing step.
22
+
23
+ Because reserving is free, a speculative "create" never wastes cycles — the host's approval prompt on
24
+ `engram_activate` is the natural gate on the actual spend.
25
+
26
+ ## Configure (MCP host `mcpServers` entry)
27
+
28
+ ```jsonc
29
+ {
30
+ "command": "npx",
31
+ "args": ["-y", "@engramx/owner-mcp"],
32
+ "env": {
33
+ "ENGRAMX_REGISTRY": "<registry-canister-id>", // required
34
+ "ENGRAMX_OWNER_KEY_PATH": "~/.engramx/owner.key" // optional; default shown
35
+ // or: "ENGRAMX_OWNER_ICP_IDENTITY": "<icp-cli identity name>"
36
+ // local dev: "ENGRAMX_LOCAL": "1"
37
+ }
38
+ }
39
+ ```
40
+
41
+ The signing key is **yours** — EngramX never holds it. A single local key is a **total-loss** risk if
42
+ lost; back it up, or use your icp-cli identity (or the web wizard with a wallet for real recovery).
43
+
44
+ ## After activating
45
+
46
+ You **own** the engram. To let an agent read/append its memory, connect it as an **operator** — a
47
+ separate, append-only step: `npx @engramx/client pair <invite-code> --engram <id>`. Owner ≠ operator,
48
+ by design.
49
+
50
+ ## Honesty
51
+
52
+ The record is tamper-**evident**, not immutable (the owner can overwrite; every change is a signed
53
+ entry anyone can verify). Reserving and activating are free to you (the platform funds the spawn);
54
+ paying to create is not a thing. Nothing is on a public fleet yet.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ // Entry point: start the stdio owner MCP server. (No subcommands — the owner surface is just the
3
+ // reserve/activate/status tools; server.ts reads its config from the environment.)
4
+ await import('./server.js');
5
+ export {};
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,iGAAiG;AACjG,mFAAmF;AAInF,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { Identity } from '@icp-sdk/core/agent';
2
+ import type { CreateResult, ConnectAgentResult } from '@engramx/owner';
3
+ export interface OwnerTarget {
4
+ registryCanisterId: string;
5
+ host: string;
6
+ local: boolean;
7
+ }
8
+ export interface OwnerApi {
9
+ /** The owner principal (the signing identity — the user). */
10
+ ownerPrincipal: string;
11
+ /** Human-readable description of the custody mode (for the startup banner + status tool). */
12
+ custody: string;
13
+ /** Reserve a free registry record (~$0). Never spawns a canister. `invite` = admission code for
14
+ * gate-armed deployments (raw-keypair identities need one there). */
15
+ reserve(invite?: string): Promise<CreateResult>;
16
+ /** Spawn the live canister for the reservation (the funded, committing step). */
17
+ activate(invite?: string): Promise<CreateResult>;
18
+ /** Provision if needed, then mint an append-only operator invite (the spawn-on-pair trigger). */
19
+ connectAgent(name?: string, invite?: string): Promise<ConnectAgentResult>;
20
+ /** Read-only: none / reserved / provisioned. */
21
+ status(): Promise<CreateResult>;
22
+ }
23
+ /** Resolve the registry target from the environment. Throws if the registry id is missing. */
24
+ export declare function resolveTarget(env: NodeJS.ProcessEnv): OwnerTarget;
25
+ /**
26
+ * Load the OWNER signing identity from the environment. Custody is the user's own — EngramX never
27
+ * holds it. Either an icp-cli identity (ENGRAMX_OWNER_ICP_IDENTITY) or a local Ed25519 key
28
+ * (ENGRAMX_OWNER_KEY_PATH, default ~/.engramx/owner.key; generated on first use).
29
+ */
30
+ export declare function loadIdentity(env: NodeJS.ProcessEnv): {
31
+ identity: Identity;
32
+ custody: string;
33
+ };
34
+ /** Assemble the owner API from the environment (identity + target closed over the owner lib). */
35
+ export declare function buildApi(env: NodeJS.ProcessEnv): OwnerApi;
package/dist/owner.js ADDED
@@ -0,0 +1,51 @@
1
+ // Owner context: turn the process environment into a signing identity + registry target, then expose
2
+ // the three owner actions (reserve / activate / status) as a small injectable API. Kept separate from
3
+ // server.ts so the tool layer can be unit-tested with a fake API and no live replica.
4
+ import { localOwnerKey, icpCliOwnerKey, createEngram, provision, status, connectAgent, } from '@engramx/owner';
5
+ const truthy = (v) => v === '1' || v === 'true' || v === 'yes';
6
+ /** Resolve the registry target from the environment. Throws if the registry id is missing. */
7
+ export function resolveTarget(env) {
8
+ const registryCanisterId = env['ENGRAMX_REGISTRY'];
9
+ if (!registryCanisterId) {
10
+ throw new Error('ENGRAMX_REGISTRY is required — set it to the EngramX registry canister id. ' +
11
+ 'This owner MCP reserves/activates engrams against that registry.');
12
+ }
13
+ const local = truthy(env['ENGRAMX_LOCAL']);
14
+ const host = env['ENGRAMX_HOST'] || (local ? 'http://127.0.0.1:4943' : 'https://icp-api.io');
15
+ return { registryCanisterId, host, local };
16
+ }
17
+ /**
18
+ * Load the OWNER signing identity from the environment. Custody is the user's own — EngramX never
19
+ * holds it. Either an icp-cli identity (ENGRAMX_OWNER_ICP_IDENTITY) or a local Ed25519 key
20
+ * (ENGRAMX_OWNER_KEY_PATH, default ~/.engramx/owner.key; generated on first use).
21
+ */
22
+ export function loadIdentity(env) {
23
+ const icpName = env['ENGRAMX_OWNER_ICP_IDENTITY'];
24
+ if (icpName) {
25
+ return {
26
+ identity: icpCliOwnerKey(icpName),
27
+ custody: `icp-cli identity "${icpName}" (EngramX holds nothing)`,
28
+ };
29
+ }
30
+ const key = localOwnerKey(env['ENGRAMX_OWNER_KEY_PATH']);
31
+ return {
32
+ identity: key.identity,
33
+ custody: `local owner key at ${key.keyPath}` +
34
+ (key.created ? ' (NEWLY generated — back it up; loss = permanent loss of ownership)' : ''),
35
+ };
36
+ }
37
+ /** Assemble the owner API from the environment (identity + target closed over the owner lib). */
38
+ export function buildApi(env) {
39
+ const target = resolveTarget(env);
40
+ const { identity, custody } = loadIdentity(env);
41
+ const opts = { identity, ...target };
42
+ return {
43
+ ownerPrincipal: identity.getPrincipal().toText(),
44
+ custody,
45
+ reserve: (invite) => createEngram({ ...opts, activate: false, invite }),
46
+ activate: (invite) => provision({ ...opts, invite }),
47
+ connectAgent: (name, invite) => connectAgent({ ...opts, invite }, { name }),
48
+ status: () => status(opts),
49
+ };
50
+ }
51
+ //# sourceMappingURL=owner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner.js","sourceRoot":"","sources":["../src/owner.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,sGAAsG;AACtG,sFAAsF;AAGtF,OAAO,EACL,aAAa,EACb,cAAc,EACd,YAAY,EACZ,SAAS,EACT,MAAM,EACN,YAAY,GACb,MAAM,gBAAgB,CAAC;AAyBxB,MAAM,MAAM,GAAG,CAAC,CAAqB,EAAW,EAAE,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,KAAK,CAAC;AAE5F,8FAA8F;AAC9F,MAAM,UAAU,aAAa,CAAC,GAAsB;IAClD,MAAM,kBAAkB,GAAG,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACnD,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,6EAA6E;YAC3E,kEAAkE,CACrE,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,GAA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C,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC;QAC7D,YAAY,EAAE,CAAC,IAAa,EAAE,MAAe,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;QAC7F,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;KAC3B,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
package/dist/server.js ADDED
@@ -0,0 +1,34 @@
1
+ // The stdio owner MCP server. Loads the owner identity + registry target from the environment, then
2
+ // exposes the reserve/activate/status tools. Owner-side only — no memory read/append (that is the
3
+ // operator server, @engramx/mcp).
4
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
6
+ import { buildApi } from './owner.js';
7
+ import { registerOwnerTools } from './tools.js';
8
+ function startupHelp(e) {
9
+ const msg = e instanceof Error ? e.message : String(e);
10
+ return (`Error: ${msg}\n\n` +
11
+ 'Owner MCP configuration:\n' +
12
+ ' ENGRAMX_REGISTRY (required) EngramX registry canister id.\n' +
13
+ ' ENGRAMX_OWNER_KEY_PATH local Ed25519 owner key (default ~/.engramx/owner.key).\n' +
14
+ ' ENGRAMX_OWNER_ICP_IDENTITY reuse an icp-cli identity instead of a local key.\n' +
15
+ ' ENGRAMX_HOST replica host (default https://icp-api.io).\n' +
16
+ ' ENGRAMX_LOCAL=1 target a local replica (http://127.0.0.1:4943).');
17
+ }
18
+ let api;
19
+ try {
20
+ api = buildApi(process.env);
21
+ }
22
+ catch (e) {
23
+ console.error(startupHelp(e));
24
+ process.exit(1);
25
+ }
26
+ const server = new McpServer({ name: 'engramx-owner', version: '0.1.0' }, {
27
+ instructions: 'engramx-owner lets the user create and own an engram — a personal canister on the Internet Computer holding an agent\'s memory plus a tamper-evident action record. This server is OWNER-side ONLY: it reserves, activates, and connects agents to engrams the user owns; it does NOT read or append memory (that is the separate append-only OPERATOR surface, @engramx/mcp / @engramx/client). Spawn-only-on-real-use: engram_status (see what exists) -> engram_reserve (a FREE registry record — no canister, no spend) -> then the canister spawns only when the user actually uses it: engram_connect_agent (the usual path — provisions AND mints an append-only operator invite in one step, so it spawns exactly when you wire an agent) or engram_activate (spawn without an agent, only if the user will add memory via the web app / SDK). The signing key is the USER\'S OWN (a local key or their icp-cli identity) — EngramX never holds it; a single local key is a total-loss risk if lost. The record is tamper-EVIDENT, not immutable: the owner can overwrite their own memory, but every change is a signed entry anyone can verify. An operator invite grants append-only access (read + add), never owner powers.',
28
+ });
29
+ registerOwnerTools(server, api);
30
+ const transport = new StdioServerTransport();
31
+ await server.connect(transport);
32
+ // stdout is the MCP protocol channel — log to stderr.
33
+ console.error(`engramx owner MCP started (owner: ${api.ownerPrincipal}, custody: ${api.custody})`);
34
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,kGAAkG;AAClG,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,SAAS,WAAW,CAAC,CAAU;IAC7B,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvD,OAAO,CACL,UAAU,GAAG,MAAM;QACnB,4BAA4B;QAC5B,0EAA0E;QAC1E,yFAAyF;QACzF,mFAAmF;QACnF,4EAA4E;QAC5E,+EAA+E,CAChF,CAAC;AACJ,CAAC;AAED,IAAI,GAAa,CAAC;AAClB,IAAI,CAAC;IACH,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAAC,OAAO,CAAC,EAAE,CAAC;IACX,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,EAC3C;IACE,YAAY,EACV,0qCAA0qC;CAC7qC,CACF,CAAC;AAEF,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEhC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAEhC,sDAAsD;AACtD,OAAO,CAAC,KAAK,CAAC,qCAAqC,GAAG,CAAC,cAAc,cAAc,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { OwnerApi } from './owner.js';
3
+ /**
4
+ * Register the OWNER-side tools. Three tools, deliberately mapping to the reserve→activate anti-drain:
5
+ * status (read), reserve (free, safe), activate (the funded spend — the host's approval UI is the gate).
6
+ * No memory read/append here — that is the separate operator surface.
7
+ */
8
+ export declare function registerOwnerTools(server: McpServer, api: OwnerApi): void;
package/dist/tools.js ADDED
@@ -0,0 +1,69 @@
1
+ import { z } from 'zod';
2
+ const ok = (obj) => ({
3
+ content: [{ type: 'text', text: JSON.stringify(obj, null, 2) }],
4
+ });
5
+ const fail = (message) => ({
6
+ content: [{ type: 'text', text: message }],
7
+ isError: true,
8
+ });
9
+ const view = (r) => ({
10
+ state: r.state,
11
+ canisterId: r.canisterId,
12
+ owner: r.owner,
13
+ alreadyExisted: r.alreadyExisted,
14
+ });
15
+ const errText = (e) => `Error: ${e instanceof Error ? e.message : String(e)}`;
16
+ /**
17
+ * Register the OWNER-side tools. Three tools, deliberately mapping to the reserve→activate anti-drain:
18
+ * status (read), reserve (free, safe), activate (the funded spend — the host's approval UI is the gate).
19
+ * No memory read/append here — that is the separate operator surface.
20
+ */
21
+ export function registerOwnerTools(server, api) {
22
+ server.tool('engram_status', 'Read-only. Report whether YOU (this owner key) have nothing yet, a free reservation, or a live engram — with its canister id if provisioned. No spend, no writes. Call before reserving/activating to avoid duplicates (one engram per principal).', {}, async () => {
23
+ try {
24
+ return ok({ ...view(await api.status()), ownerPrincipal: api.ownerPrincipal, custody: api.custody });
25
+ }
26
+ catch (e) {
27
+ return fail(errText(e));
28
+ }
29
+ });
30
+ server.tool('engram_reserve', 'Reserve an engram that YOU will own — a FREE registry record (~$0). Nothing runs yet and no cycles are spent; it does NOT spawn a canister. Idempotent (one per principal), so it is safe to call speculatively. To actually run the engram, call engram_activate afterward. If the registry rejects with an invite-required error (gate-armed deployment), ask the user for their invite code and pass it as `invite`.', { invite: z.string().optional().describe('Invite code for gate-armed deployments (only needed if a plain call was rejected asking for one).') }, async ({ invite }) => {
31
+ try {
32
+ return ok(view(await api.reserve(invite)));
33
+ }
34
+ catch (e) {
35
+ return fail(errText(e));
36
+ }
37
+ });
38
+ server.tool('engram_connect_agent', 'The usual way to spin up an engram: provision it (if not already live) AND mint an append-only OPERATOR invite in one step — so the canister spawns exactly when you are wiring an agent to it. The platform funds the (~1.15T-cycle) spawn. Returns {canisterId, inviteCode}; the agent redeems the code with `npx @engramx/client pair <inviteCode> --engram <canisterId>`. The grant is append-only (read + append), never owner powers. Prefer this over engram_activate unless you specifically want an empty engram.', {
39
+ name: z.string().optional().describe('A label for this operator/agent (e.g. "openclaw", "claude-desktop"). Defaults to "agent".'),
40
+ invite: z.string().optional().describe('Invite code for gate-armed deployments (only needed if a plain call was rejected asking for one).'),
41
+ }, async ({ name, invite }) => {
42
+ try {
43
+ const r = await api.connectAgent(name, invite);
44
+ return ok({
45
+ ...view(r),
46
+ operatorName: r.operatorName,
47
+ inviteCode: r.inviteCode,
48
+ pairCommand: `npx @engramx/client pair ${r.inviteCode} --engram ${r.canisterId}`,
49
+ note: 'Give pairCommand (or the inviteCode) to the agent/host. The grant is append-only — it can read and add memory, never overwrite, delete, or move funds.',
50
+ });
51
+ }
52
+ catch (e) {
53
+ return fail(errText(e));
54
+ }
55
+ });
56
+ server.tool('engram_activate', 'Spawn the live engram canister WITHOUT connecting an agent — only when the user will add memory through another surface (the web app / SDK). The platform funds the (~1.15T-cycle) spawn. Most of the time you want engram_connect_agent instead (spawn + get an invite in one step). Idempotent: if one is already live, returns its canister id.', { invite: z.string().optional().describe('Invite code for gate-armed deployments (only needed if a plain call was rejected asking for one).') }, async ({ invite }) => {
57
+ try {
58
+ const r = await api.activate(invite);
59
+ return ok({
60
+ ...view(r),
61
+ next: `To let an agent read/append this engram's memory, connect it as an OPERATOR: use engram_connect_agent, or npx @engramx/client pair <invite-code> --engram ${r.canisterId}`,
62
+ });
63
+ }
64
+ catch (e) {
65
+ return fail(errText(e));
66
+ }
67
+ });
68
+ }
69
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,MAAM,EAAE,GAAG,CAAC,GAAY,EAAc,EAAE,CAAC,CAAC;IACxC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;CAChE,CAAC,CAAC;AACH,MAAM,IAAI,GAAG,CAAC,OAAe,EAAc,EAAE,CAAC,CAAC;IAC7C,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,C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,CAAC,MAAM,CAAC,CAAC;YACrC,OAAO,EAAE,CAAC;gBACR,GAAG,IAAI,CAAC,CAAC,CAAC;gBACV,IAAI,EAAE,6JAA6J,CAAC,CAAC,UAAU,EAAE;aAClL,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@engramx/owner-mcp",
3
+ "version": "0.1.0",
4
+ "description": "Owner-side MCP server for EngramX — reserve, activate, and check an engram YOU own, from any MCP host. The owner counterpart to @engramx/mcp (the operator server); it never operates memory.",
5
+ "license": "MIT",
6
+ "author": "EngramX <developer@engramx.ai>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/vhew/engramx",
10
+ "directory": "integrations/owner-mcp"
11
+ },
12
+ "type": "module",
13
+ "main": "dist/index.js",
14
+ "types": "dist/index.d.ts",
15
+ "bin": {
16
+ "engramx-owner-mcp": "./dist/index.js"
17
+ },
18
+ "files": [
19
+ "dist/",
20
+ "README.md"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "dependencies": {
26
+ "@icp-sdk/core": "^5.4.0",
27
+ "@modelcontextprotocol/sdk": "^1.29.0",
28
+ "zod": "^4.4.3",
29
+ "@engramx/owner": "^0.1.0"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^25.9.2",
33
+ "typescript": "^6.0.3",
34
+ "vitest": "^4.1.8"
35
+ },
36
+ "scripts": {
37
+ "build": "tsc",
38
+ "start": "node dist/index.js",
39
+ "typecheck": "tsc --noEmit",
40
+ "test": "vitest run"
41
+ }
42
+ }