@engramx/mcp 0.1.0-rc.2
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 +190 -0
- package/README.md +166 -0
- package/dist/connect-config.d.ts +51 -0
- package/dist/connect-config.js +108 -0
- package/dist/connect-config.js.map +1 -0
- package/dist/connect-config.test.d.ts +1 -0
- package/dist/connect-config.test.js +49 -0
- package/dist/connect-config.test.js.map +1 -0
- package/dist/connect.d.ts +1 -0
- package/dist/connect.js +89 -0
- package/dist/connect.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/profile-tools.d.ts +3 -0
- package/dist/profile-tools.js +144 -0
- package/dist/profile-tools.js.map +1 -0
- package/dist/resources.d.ts +3 -0
- package/dist/resources.js +22 -0
- package/dist/resources.js.map +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +51 -0
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +3 -0
- package/dist/tools.js +398 -0
- package/dist/tools.js.map +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +30 -0
- package/dist/utils.js.map +1 -0
- package/package.json +40 -0
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,166 @@
|
|
|
1
|
+
# @engramx/mcp
|
|
2
|
+
|
|
3
|
+
MCP server for [EngramX](https://engramx.ai) — persistent, decentralized agent memory on the Internet Computer.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js >= 22.12
|
|
8
|
+
- An engram with operator access (session key from `engramx pair`)
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
ENGRAM_CANISTER_ID=xxxxx-xxxxx-xxxxx-xxxxx-xxx npx @engramx/mcp
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Configuration
|
|
17
|
+
|
|
18
|
+
| Variable | Required | Default | Description |
|
|
19
|
+
|----------|----------|---------|-------------|
|
|
20
|
+
| `ENGRAM_CANISTER_ID` | Yes | — | Your engram canister ID |
|
|
21
|
+
| `ENGRAM_SESSION_KEY_PATH` | No | `~/.engramx/session.key` | Path to Ed25519 session key |
|
|
22
|
+
| `ENGRAM_HOST` | No | `https://ic0.app` | ICP host URL |
|
|
23
|
+
|
|
24
|
+
## Setup: Claude Desktop
|
|
25
|
+
|
|
26
|
+
Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"mcpServers": {
|
|
31
|
+
"engramx": {
|
|
32
|
+
"command": "npx",
|
|
33
|
+
"args": ["@engramx/mcp"],
|
|
34
|
+
"env": {
|
|
35
|
+
"ENGRAM_CANISTER_ID": "xxxxx-xxxxx-xxxxx-xxxxx-xxx",
|
|
36
|
+
"ENGRAM_SESSION_KEY_PATH": "/Users/you/.engramx/session.key"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Setup: Cursor
|
|
44
|
+
|
|
45
|
+
Add to `.cursor/mcp.json` in your project root:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"engramx": {
|
|
51
|
+
"command": "npx",
|
|
52
|
+
"args": ["@engramx/mcp"],
|
|
53
|
+
"env": {
|
|
54
|
+
"ENGRAM_CANISTER_ID": "xxxxx-xxxxx-xxxxx-xxxxx-xxx",
|
|
55
|
+
"ENGRAM_SESSION_KEY_PATH": "/Users/you/.engramx/session.key"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Setup: Python Agent
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from mcp import ClientSession, StdioServerParameters
|
|
66
|
+
from mcp.client.stdio import stdio_client
|
|
67
|
+
|
|
68
|
+
server = StdioServerParameters(
|
|
69
|
+
command="npx",
|
|
70
|
+
args=["@engramx/mcp"],
|
|
71
|
+
env={
|
|
72
|
+
"ENGRAM_CANISTER_ID": "xxxxx-xxxxx-xxxxx-xxxxx-xxx",
|
|
73
|
+
"ENGRAM_SESSION_KEY_PATH": "/path/to/session.key",
|
|
74
|
+
},
|
|
75
|
+
)
|
|
76
|
+
async with stdio_client(server) as (read, write):
|
|
77
|
+
async with ClientSession(read, write) as session:
|
|
78
|
+
await session.initialize()
|
|
79
|
+
result = await session.call_tool("engram_list_memory_files", {})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Setup: Generic MCP Client
|
|
83
|
+
|
|
84
|
+
Any MCP-compatible client can spawn the server over stdio:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
ENGRAM_CANISTER_ID=xxxxx-xxxxx-xxxxx-xxxxx-xxx \
|
|
88
|
+
ENGRAM_SESSION_KEY_PATH=/path/to/session.key \
|
|
89
|
+
npx @engramx/mcp
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The server communicates over stdin/stdout using the MCP protocol. Set environment variables for authentication.
|
|
93
|
+
|
|
94
|
+
## Available Tools
|
|
95
|
+
|
|
96
|
+
| Tool | Parameters | Description |
|
|
97
|
+
|------|-----------|-------------|
|
|
98
|
+
| `engram_read_memory` | `path: string` | Read a memory file (content, version, timestamp) |
|
|
99
|
+
| `engram_append_memory` | `path: string, content: string` | Append to a memory file (creates if missing) |
|
|
100
|
+
| `engram_list_memory_files` | _(none)_ | List all memory files |
|
|
101
|
+
| `engram_read_memory_batch` | `paths: string[]` | Read multiple files in one call |
|
|
102
|
+
| `engram_memory_history` | `path: string` | Version history of a file |
|
|
103
|
+
| `engram_read_audit_log` | `fromIndex?: number, limit?: number` | Read audit-log entries (timestamped operations) |
|
|
104
|
+
| `engram_wallet_balance` | _(none)_ | Engram canister cycles balance (fuel) |
|
|
105
|
+
| `engram_status` | _(none)_ | Canister health and stats |
|
|
106
|
+
| `engram_list_services` | _(none)_ | List paid services registered on this engram |
|
|
107
|
+
| `engram_submit_service_request` | `serviceId: string, params: string` | Submit a paid service request; returns a job ID |
|
|
108
|
+
| `engram_get_job_result` | `jobId: string, maxAttempts?: number` | Poll a job to terminal status; returns the job |
|
|
109
|
+
| `engram_dispute_job` | `jobId: string, reason: string` | Dispute a completed job (BuyerConfirm verification) |
|
|
110
|
+
|
|
111
|
+
> **Append-only by design.** This server intentionally exposes **no** `write`, `delete`,
|
|
112
|
+
> `rollback`, `transfer`, or `sign` tools. Operators get read + append only; full
|
|
113
|
+
> overwrite/delete/rollback, fund movement, and signing are owner-only and not reachable
|
|
114
|
+
> over MCP.
|
|
115
|
+
|
|
116
|
+
## Available Resources
|
|
117
|
+
|
|
118
|
+
| URI | Description |
|
|
119
|
+
|-----|-------------|
|
|
120
|
+
| `engram://status` | Canister status as JSON |
|
|
121
|
+
|
|
122
|
+
## Getting an Operator Session Key
|
|
123
|
+
|
|
124
|
+
1. Create an engram at [engramx.ai](https://engramx.ai) or via the CLI
|
|
125
|
+
2. Generate an operator invite in the engram dashboard
|
|
126
|
+
3. Pair your machine:
|
|
127
|
+
```bash
|
|
128
|
+
engramx pair <invite-code> --engram <canister-id>
|
|
129
|
+
```
|
|
130
|
+
4. The session key is saved to `~/.engramx/session.key`
|
|
131
|
+
|
|
132
|
+
See the [EngramX documentation](https://github.com/engramx/engramx) for full instructions.
|
|
133
|
+
|
|
134
|
+
## Local Development
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
git clone https://github.com/engramx/engramx.git
|
|
138
|
+
cd engramx/integrations/mcp
|
|
139
|
+
pnpm install
|
|
140
|
+
pnpm build
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Test with a local ICP replica:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
ENGRAM_CANISTER_ID=<local-canister-id> \
|
|
147
|
+
ENGRAM_HOST=http://localhost:4943 \
|
|
148
|
+
node dist/index.js
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Inspect with the MCP Inspector:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
npx @modelcontextprotocol/inspector -- npx @engramx/mcp
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Troubleshooting
|
|
158
|
+
|
|
159
|
+
**Missing `ENGRAM_CANISTER_ID`**
|
|
160
|
+
The server exits with a clear error. Set the environment variable to your engram canister ID.
|
|
161
|
+
|
|
162
|
+
**Session key not found**
|
|
163
|
+
Generate one with `engramx pair`. The default path is `~/.engramx/session.key`. Override with `ENGRAM_SESSION_KEY_PATH`.
|
|
164
|
+
|
|
165
|
+
**Canister unreachable**
|
|
166
|
+
Check that `ENGRAM_HOST` is correct (default: `https://ic0.app` for mainnet). For local development, use `http://localhost:4943`. Verify network connectivity.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface ConnectParams {
|
|
2
|
+
canisterId: string;
|
|
3
|
+
/** IC gateway host. Defaults to mainnet (icp0.io). Local replica: http://localhost:4943 */
|
|
4
|
+
host?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const MAINNET_HOST = "https://icp0.io";
|
|
7
|
+
/** The remote MCP endpoint URL for an engram canister (boundary-node subdomain routing). */
|
|
8
|
+
export declare function mcpUrl({ canisterId, host }: ConnectParams): string;
|
|
9
|
+
/** Claude Desktop / Cursor STDIO server entry (local @engramx/mcp, session-key auth). */
|
|
10
|
+
export declare function stdioServerConfig({ canisterId, host }: ConnectParams): {
|
|
11
|
+
command: string;
|
|
12
|
+
args: string[];
|
|
13
|
+
env: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
/** The claude_desktop_config.json fragment with the engramx server under mcpServers. */
|
|
16
|
+
export declare function claudeDesktopConfig(p: ConnectParams): {
|
|
17
|
+
mcpServers: {
|
|
18
|
+
engramx: {
|
|
19
|
+
command: string;
|
|
20
|
+
args: string[];
|
|
21
|
+
env: Record<string, string>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export interface ClientGuide {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
/** 'remote' = canister-hosted HTTP MCP + OAuth; 'stdio' = local @engramx/mcp + session key */
|
|
29
|
+
transport: 'remote' | 'stdio';
|
|
30
|
+
steps: string[];
|
|
31
|
+
/** Optional copy-paste install snippet (CLI command, YAML, or JSON). */
|
|
32
|
+
snippet?: string;
|
|
33
|
+
}
|
|
34
|
+
/** Per-client connection guides — identical wording in the CLI and the web page. */
|
|
35
|
+
export declare function clientGuides(p: ConnectParams): ClientGuide[];
|
|
36
|
+
/** Everything a consumer needs in one call. */
|
|
37
|
+
export declare function connectInfo(p: ConnectParams): {
|
|
38
|
+
canisterId: string;
|
|
39
|
+
host: string;
|
|
40
|
+
mcpUrl: string;
|
|
41
|
+
claudeDesktopConfig: {
|
|
42
|
+
mcpServers: {
|
|
43
|
+
engramx: {
|
|
44
|
+
command: string;
|
|
45
|
+
args: string[];
|
|
46
|
+
env: Record<string, string>;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
guides: ClientGuide[];
|
|
51
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Canonical config generation for connecting AI clients (Claude.ai web, Claude Desktop, Cursor, …)
|
|
2
|
+
// to an engram's remote MCP endpoint. Used by the `@engramx/mcp connect` CLI.
|
|
3
|
+
//
|
|
4
|
+
// Dependency-free and free of Node/browser-only APIs so any consumer (this CLI, or a web UI) can
|
|
5
|
+
// import it unchanged. The contract test (connect-config.test.ts) pins the output — downstream UIs
|
|
6
|
+
// that re-render this config should reuse this module + that test so every surface stays identical.
|
|
7
|
+
export const MAINNET_HOST = 'https://icp0.io';
|
|
8
|
+
function isLocal(host) {
|
|
9
|
+
return host.includes('localhost') || host.includes('127.0.0.1');
|
|
10
|
+
}
|
|
11
|
+
/** The remote MCP endpoint URL for an engram canister (boundary-node subdomain routing). */
|
|
12
|
+
export function mcpUrl({ canisterId, host = MAINNET_HOST }) {
|
|
13
|
+
if (isLocal(host))
|
|
14
|
+
return `http://${canisterId}.localhost:4943/mcp`;
|
|
15
|
+
return `https://${canisterId}.icp0.io/mcp`;
|
|
16
|
+
}
|
|
17
|
+
/** Claude Desktop / Cursor STDIO server entry (local @engramx/mcp, session-key auth). */
|
|
18
|
+
export function stdioServerConfig({ canisterId, host = MAINNET_HOST }) {
|
|
19
|
+
const env = { ENGRAM_CANISTER_ID: canisterId };
|
|
20
|
+
// Only pin a non-default host (e.g. local replica); mainnet is the @engramx/mcp default.
|
|
21
|
+
if (host !== MAINNET_HOST && host !== 'https://ic0.app')
|
|
22
|
+
env['ENGRAM_HOST'] = host;
|
|
23
|
+
return { command: 'npx', args: ['-y', '@engramx/mcp'], env };
|
|
24
|
+
}
|
|
25
|
+
/** The claude_desktop_config.json fragment with the engramx server under mcpServers. */
|
|
26
|
+
export function claudeDesktopConfig(p) {
|
|
27
|
+
return { mcpServers: { engramx: stdioServerConfig(p) } };
|
|
28
|
+
}
|
|
29
|
+
/** Per-client connection guides — identical wording in the CLI and the web page. */
|
|
30
|
+
export function clientGuides(p) {
|
|
31
|
+
const url = mcpUrl(p);
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
id: 'claude-web',
|
|
35
|
+
name: 'Claude (claude.ai)',
|
|
36
|
+
transport: 'remote',
|
|
37
|
+
steps: [
|
|
38
|
+
'Open claude.ai → Settings → Connectors → Add custom connector.',
|
|
39
|
+
`Paste the MCP URL: ${url}`,
|
|
40
|
+
'Sign in with the Internet Identity that owns this engram, then approve.',
|
|
41
|
+
'Your engram tools (read/append/list memory, audit log, wallet) appear in new chats.',
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'claude-code',
|
|
46
|
+
name: 'Claude Code (CLI)',
|
|
47
|
+
transport: 'remote',
|
|
48
|
+
snippet: `claude mcp add engramx-memory ${url}`,
|
|
49
|
+
steps: [
|
|
50
|
+
'Run the command, then restart claude-code — OAuth opens in your browser on first use.',
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 'claude-desktop',
|
|
55
|
+
name: 'Claude Desktop (remote)',
|
|
56
|
+
transport: 'remote',
|
|
57
|
+
steps: [
|
|
58
|
+
'Claude Desktop → Settings → Connectors → Add custom connector.',
|
|
59
|
+
`Paste the MCP URL: ${url}`,
|
|
60
|
+
'Authorize with Internet Identity.',
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'cursor',
|
|
65
|
+
name: 'Cursor',
|
|
66
|
+
transport: 'remote',
|
|
67
|
+
steps: [
|
|
68
|
+
'Cursor → Settings → MCP → Add new MCP server.',
|
|
69
|
+
`Paste the remote URL ${url}; the OAuth flow opens in your browser.`,
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: 'copilot',
|
|
74
|
+
name: 'GitHub Copilot',
|
|
75
|
+
transport: 'remote',
|
|
76
|
+
snippet: `gh copilot mcp add engramx-memory ${url}`,
|
|
77
|
+
steps: ['Or add it via the GitHub MCP Registry.'],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 'continue',
|
|
81
|
+
name: 'Continue.dev',
|
|
82
|
+
transport: 'remote',
|
|
83
|
+
snippet: `mcpServers:\n - name: engramx-memory\n transport: streamable-http\n url: ${url}`,
|
|
84
|
+
steps: ['Add this YAML to .continue/mcpServers/engramx.yaml.'],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'claude-desktop-stdio',
|
|
88
|
+
name: 'Claude Desktop / Cursor (local stdio)',
|
|
89
|
+
transport: 'stdio',
|
|
90
|
+
snippet: JSON.stringify(claudeDesktopConfig(p), null, 2),
|
|
91
|
+
steps: [
|
|
92
|
+
`Pair a session key once: npx @engramx/client pair <invite-code> --engram ${p.canisterId}`,
|
|
93
|
+
'Add the JSON to claude_desktop_config.json under "mcpServers", then restart the client.',
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
/** Everything a consumer needs in one call. */
|
|
99
|
+
export function connectInfo(p) {
|
|
100
|
+
return {
|
|
101
|
+
canisterId: p.canisterId,
|
|
102
|
+
host: p.host ?? MAINNET_HOST,
|
|
103
|
+
mcpUrl: mcpUrl(p),
|
|
104
|
+
claudeDesktopConfig: claudeDesktopConfig(p),
|
|
105
|
+
guides: clientGuides(p),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=connect-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-config.js","sourceRoot":"","sources":["../src/connect-config.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,8EAA8E;AAC9E,EAAE;AACF,iGAAiG;AACjG,mGAAmG;AACnG,oGAAoG;AAQpG,MAAM,CAAC,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAE9C,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAClE,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,MAAM,CAAC,EAAE,UAAU,EAAE,IAAI,GAAG,YAAY,EAAiB;IACvE,IAAI,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,UAAU,UAAU,qBAAqB,CAAC;IACpE,OAAO,WAAW,UAAU,cAAc,CAAC;AAC7C,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,iBAAiB,CAAC,EAAE,UAAU,EAAE,IAAI,GAAG,YAAY,EAAiB;IAClF,MAAM,GAAG,GAA2B,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAC;IACvE,yFAAyF;IACzF,IAAI,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,iBAAiB;QAAE,GAAG,CAAC,aAAa,CAAC,GAA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,CAAC;SAClD;QACD;YACE,EAAE,EAAE,UAAU;YACd,IAAI,EAAE,cAAc;YACpB,SAAS,EAAE,QAAQ;YACnB,OAAO,EAAE,mFAAmF,GAAG,EAAE;YACjG,KAAK,EAAE,CAAC,qDAAqD,CAAC;SAC/D;QACD;YACE,EAAE,EAAE,sBAAsB;YAC1B,IAAI,EAAE,uCAAuC;YAC7C,SAAS,EAAE,OAAO;YAClB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;YACxD,KAAK,EAAE;gBACL,4EAA4E,CAAC,CAAC,UAAU,EAAE;gBAC1F,yFAAyF;aAC1F;SACF;KACF,CAAC;AACJ,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,WAAW,CAAC,CAAgB;IAC1C,OAAO;QACL,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY;QAC5B,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACjB,mBAAmB,EAAE,mBAAmB,CAAC,CAAC,CAAC;QAC3C,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { mcpUrl, stdioServerConfig, claudeDesktopConfig, clientGuides, connectInfo, } from './connect-config.js';
|
|
3
|
+
// Contract test for the canonical connect-config. Any downstream UI that re-renders this config
|
|
4
|
+
// should reuse this module + this test, so identical assertions keep every surface emitting the
|
|
5
|
+
// same setup steps.
|
|
6
|
+
describe('connect-config', () => {
|
|
7
|
+
const p = { canisterId: 'aaaaa-bbbbb-ccccc-ddddd-cai' };
|
|
8
|
+
it('mcpUrl: mainnet subdomain routing', () => {
|
|
9
|
+
expect(mcpUrl(p)).toBe('https://aaaaa-bbbbb-ccccc-ddddd-cai.icp0.io/mcp');
|
|
10
|
+
});
|
|
11
|
+
it('mcpUrl: local replica', () => {
|
|
12
|
+
expect(mcpUrl({ ...p, host: 'http://localhost:4943' })).toBe('http://aaaaa-bbbbb-ccccc-ddddd-cai.localhost:4943/mcp');
|
|
13
|
+
});
|
|
14
|
+
it('stdioServerConfig: mainnet omits ENGRAM_HOST', () => {
|
|
15
|
+
expect(stdioServerConfig(p)).toEqual({
|
|
16
|
+
command: 'npx',
|
|
17
|
+
args: ['-y', '@engramx/mcp'],
|
|
18
|
+
env: { ENGRAM_CANISTER_ID: p.canisterId },
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
it('stdioServerConfig: pins a non-default host', () => {
|
|
22
|
+
expect(stdioServerConfig({ ...p, host: 'http://localhost:4943' }).env['ENGRAM_HOST']).toBe('http://localhost:4943');
|
|
23
|
+
});
|
|
24
|
+
it('claudeDesktopConfig: nests the server under mcpServers.engramx', () => {
|
|
25
|
+
expect(claudeDesktopConfig(p).mcpServers.engramx.command).toBe('npx');
|
|
26
|
+
});
|
|
27
|
+
it('clientGuides: covers web/desktop/cursor/stdio and embeds the URL', () => {
|
|
28
|
+
const g = clientGuides(p);
|
|
29
|
+
expect(g.map((x) => x.id)).toEqual([
|
|
30
|
+
'claude-web',
|
|
31
|
+
'claude-code',
|
|
32
|
+
'claude-desktop',
|
|
33
|
+
'cursor',
|
|
34
|
+
'copilot',
|
|
35
|
+
'continue',
|
|
36
|
+
'claude-desktop-stdio',
|
|
37
|
+
]);
|
|
38
|
+
expect(g[0]?.steps.some((s) => s.includes(mcpUrl(p)))).toBe(true);
|
|
39
|
+
// snippets embed the URL (claude-code) / declare the right transport (continue)
|
|
40
|
+
expect(g.find((x) => x.id === 'claude-code')?.snippet).toContain(mcpUrl(p));
|
|
41
|
+
expect(g.find((x) => x.id === 'continue')?.snippet).toContain('streamable-http');
|
|
42
|
+
});
|
|
43
|
+
it('connectInfo: bundles url + config + guides', () => {
|
|
44
|
+
const info = connectInfo(p);
|
|
45
|
+
expect(info.mcpUrl).toBe(mcpUrl(p));
|
|
46
|
+
expect(info.guides.length).toBe(7);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=connect-config.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-config.test.js","sourceRoot":"","sources":["../src/connect-config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAE7B,gGAAgG;AAChG,gGAAgG;AAChG,oBAAoB;AACpB,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,MAAM,CAAC,GAAG,EAAE,UAAU,EAAE,6BAA6B,EAAE,CAAC;IAExD,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC,IAAI,CAC1D,uDAAuD,CACxD,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YACnC,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC;YAC5B,GAAG,EAAE,EAAE,kBAAkB,EAAE,CAAC,CAAC,UAAU,EAAE;SAC1C,CAAC,CAAC;IACL,C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