@engramprotocol/mcp-server 0.9.1 → 0.10.1

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.
Files changed (92) hide show
  1. package/README.md +48 -37
  2. package/package.json +5 -3
  3. package/templates/hooks/session_start_boot.sh +63 -0
  4. package/templates/hooks/user_prompt_submit_reminder.sh +78 -0
  5. package/dist/cli.d.ts +0 -3
  6. package/dist/cli.d.ts.map +0 -1
  7. package/dist/cli.js +0 -79
  8. package/dist/cli.js.map +0 -1
  9. package/dist/http-client.d.ts +0 -33
  10. package/dist/http-client.d.ts.map +0 -1
  11. package/dist/http-client.js +0 -106
  12. package/dist/http-client.js.map +0 -1
  13. package/dist/server.d.ts +0 -18
  14. package/dist/server.d.ts.map +0 -1
  15. package/dist/server.js +0 -18
  16. package/dist/server.js.map +0 -1
  17. package/dist/tools/_helpers.d.ts +0 -18
  18. package/dist/tools/_helpers.d.ts.map +0 -1
  19. package/dist/tools/_helpers.js +0 -37
  20. package/dist/tools/_helpers.js.map +0 -1
  21. package/dist/tools/boot.d.ts +0 -4
  22. package/dist/tools/boot.d.ts.map +0 -1
  23. package/dist/tools/boot.js +0 -18
  24. package/dist/tools/boot.js.map +0 -1
  25. package/dist/tools/confirm-review.d.ts +0 -4
  26. package/dist/tools/confirm-review.d.ts.map +0 -1
  27. package/dist/tools/confirm-review.js +0 -18
  28. package/dist/tools/confirm-review.js.map +0 -1
  29. package/dist/tools/context.d.ts +0 -4
  30. package/dist/tools/context.d.ts.map +0 -1
  31. package/dist/tools/context.js +0 -30
  32. package/dist/tools/context.js.map +0 -1
  33. package/dist/tools/decide.d.ts +0 -13
  34. package/dist/tools/decide.d.ts.map +0 -1
  35. package/dist/tools/decide.js +0 -59
  36. package/dist/tools/decide.js.map +0 -1
  37. package/dist/tools/entity.d.ts +0 -11
  38. package/dist/tools/entity.d.ts.map +0 -1
  39. package/dist/tools/entity.js +0 -54
  40. package/dist/tools/entity.js.map +0 -1
  41. package/dist/tools/epistemic.d.ts +0 -4
  42. package/dist/tools/epistemic.d.ts.map +0 -1
  43. package/dist/tools/epistemic.js +0 -31
  44. package/dist/tools/epistemic.js.map +0 -1
  45. package/dist/tools/get.d.ts +0 -4
  46. package/dist/tools/get.d.ts.map +0 -1
  47. package/dist/tools/get.js +0 -24
  48. package/dist/tools/get.js.map +0 -1
  49. package/dist/tools/index.d.ts +0 -26
  50. package/dist/tools/index.d.ts.map +0 -1
  51. package/dist/tools/index.js +0 -67
  52. package/dist/tools/index.js.map +0 -1
  53. package/dist/tools/list.d.ts +0 -4
  54. package/dist/tools/list.d.ts.map +0 -1
  55. package/dist/tools/list.js +0 -41
  56. package/dist/tools/list.js.map +0 -1
  57. package/dist/tools/note.d.ts +0 -15
  58. package/dist/tools/note.d.ts.map +0 -1
  59. package/dist/tools/note.js +0 -47
  60. package/dist/tools/note.js.map +0 -1
  61. package/dist/tools/projects.d.ts +0 -9
  62. package/dist/tools/projects.d.ts.map +0 -1
  63. package/dist/tools/projects.js +0 -63
  64. package/dist/tools/projects.js.map +0 -1
  65. package/dist/tools/recall.d.ts +0 -4
  66. package/dist/tools/recall.d.ts.map +0 -1
  67. package/dist/tools/recall.js +0 -19
  68. package/dist/tools/recall.js.map +0 -1
  69. package/dist/tools/relate.d.ts +0 -4
  70. package/dist/tools/relate.d.ts.map +0 -1
  71. package/dist/tools/relate.js +0 -31
  72. package/dist/tools/relate.js.map +0 -1
  73. package/dist/tools/set-status.d.ts +0 -13
  74. package/dist/tools/set-status.d.ts.map +0 -1
  75. package/dist/tools/set-status.js +0 -48
  76. package/dist/tools/set-status.js.map +0 -1
  77. package/dist/tools/show.d.ts +0 -11
  78. package/dist/tools/show.d.ts.map +0 -1
  79. package/dist/tools/show.js +0 -25
  80. package/dist/tools/show.js.map +0 -1
  81. package/dist/tools/stats.d.ts +0 -11
  82. package/dist/tools/stats.d.ts.map +0 -1
  83. package/dist/tools/stats.js +0 -21
  84. package/dist/tools/stats.js.map +0 -1
  85. package/dist/tools/track-task.d.ts +0 -10
  86. package/dist/tools/track-task.d.ts.map +0 -1
  87. package/dist/tools/track-task.js +0 -56
  88. package/dist/tools/track-task.js.map +0 -1
  89. package/dist/tools/update.d.ts +0 -4
  90. package/dist/tools/update.d.ts.map +0 -1
  91. package/dist/tools/update.js +0 -25
  92. package/dist/tools/update.js.map +0 -1
package/README.md CHANGED
@@ -2,51 +2,62 @@
2
2
 
3
3
  MCP wrapper around the EML HTTP API. Exposes the Engram Protocol as MCP tools for Claude Code (and other MCP clients) — stdio transport, Bearer token auth against `api.engramprotocol.io`.
4
4
 
5
- ## Install + Run
5
+ Request an API token: **parsley_22bonds@icloud.com**
6
+
7
+ ## Install
6
8
 
7
9
  ```bash
8
- npx @engramprotocol/mcp-server --url <api-url> --token <bearer>
10
+ EML_API_TOKEN=eml_<prefix><secret> \
11
+ npx @engramprotocol/mcp-server setup install
9
12
  ```
10
13
 
11
- or via env vars:
14
+ The installer:
15
+ - Verifies the token against `/stats` before storing
16
+ - Writes `~/.eml/config` (chmod 600) with URL + token + client-version
17
+ - Registers the `engramprotocol` MCP server via `claude mcp add` (user scope, stdio transport, semver-range-pinned to `@~0.10`)
18
+ - Adds two hooks to `~/.claude/settings.json` (see [Hooks](#hooks) below):
19
+ - **SessionStart** → loads your brain at session start (identity, rules, decisions, status, tasks, protocol conventions)
20
+ - **UserPromptSubmit** → light mid-session reminder on turn 1, every 5 turns, or after >1h pause
21
+ - Adds two permissions: `mcp__engramprotocol__*` (skip per-call prompt for EML tools) and `Bash(npx @engramprotocol/mcp-server setup *)` (let the agent auto-execute `setup update` when prompted)
22
+ - Performs a final `/stats` round-trip as smoke test
23
+
24
+ A backup of `~/.claude/settings.json` is created first (pattern `.pre-eml-install-YYYY-MM-DD-HH-MM-SS.bak`).
25
+
26
+ ### Update
12
27
 
13
28
  ```bash
14
- EML_API_URL=https://api.engramprotocol.io \
15
- EML_API_TOKEN=eml_<prefix><secret> \
16
- npx @engramprotocol/mcp-server
29
+ npx @engramprotocol/mcp-server@latest setup update
17
30
  ```
18
31
 
19
- ## Claude Code config
32
+ Refreshes hook templates (marker-aware — preserves files you customised), bumps `EML_CLIENT_VERSION` in `~/.eml/config`. Idempotent. The `@latest` suffix busts the npx cache so you actually get the new version.
20
33
 
21
- The recommended way is via `claude mcp add`:
34
+ ### Uninstall
22
35
 
23
36
  ```bash
24
- claude mcp add engramprotocol \
25
- --env EML_API_URL=https://api.engramprotocol.io \
26
- --env EML_API_TOKEN=eml_<prefix><secret> \
27
- -- npx -y @engramprotocol/mcp-server
37
+ npx @engramprotocol/mcp-server setup uninstall
28
38
  ```
29
39
 
30
- Or directly in `~/.claude/settings.json` (or your client's MCP config path):
31
-
32
- ```json
33
- {
34
- "mcpServers": {
35
- "engramprotocol": {
36
- "command": "npx",
37
- "args": ["-y", "@engramprotocol/mcp-server"],
38
- "env": {
39
- "EML_API_URL": "https://api.engramprotocol.io",
40
- "EML_API_TOKEN": "eml_<prefix><secret>"
41
- }
42
- }
43
- }
44
- }
45
- ```
40
+ Removes the MCP registration, the two managed hook entries, the two managed permission entries, and `~/.eml/hooks/`. Your own hooks and permissions are untouched. `~/.eml/config` is kept by default (asks for confirmation before delete — it contains your token).
41
+
42
+ ## Hooks
43
+
44
+ Two bash hooks land in `~/.eml/hooks/`:
45
+
46
+ ### `session_start_boot.sh` (SessionStart event)
47
+ - Sources `~/.eml/config`, POSTs to `/boot`, prints the returned markdown to stdout
48
+ - Claude Code injects that stdout into model context — **invisible in chat** but reaches the model (verified empirically; behavior decided 2026-05-15)
49
+ - Performs an update-banner check: if `EML_CLIENT_VERSION` from config differs from `/boot.version`, emits a banner pointing to `setup update`
50
+ - Fail-soft: missing config, missing vars, or unreachable server emits a warning and exits 0 — session continues without brain
51
+
52
+ ### `user_prompt_submit_reminder.sh` (UserPromptSubmit event)
53
+ - Local only, no HTTP
54
+ - Triggers a 5-bullet reminder on turn 1, every 5 turns, or after >1h pause
55
+ - Per-session turn counter at `/tmp/eml-turns/<session_id>`
56
+ - Reminder content is a heredoc inside the script — refreshed via `setup update`
46
57
 
47
- Request api token via email: parsley_22bonds@icloud.com
58
+ Both hooks log to `~/.eml/logs/<event>-YYYY-MM-DD.log` (self-rotating per day) and carry a `# managed-by: engramprotocol-setup` marker line that lets `setup update` / `setup uninstall` identify which files they own.
48
59
 
49
- ## Tools (v0.9.1)
60
+ ## Tools (v0.10.0)
50
61
 
51
62
  All tools have an `eml_` prefix. Total: **17 tools**.
52
63
 
@@ -54,7 +65,7 @@ All tools have an `eml_` prefix. Total: **17 tools**.
54
65
 
55
66
  | Tool | HTTP endpoint | Use case |
56
67
  |---|---|---|
57
- | `eml_boot` | `POST /boot` | Identity + status + open tasks at session start |
68
+ | `eml_boot` | `POST /boot` | Manual brain-reload (SessionStart-Hook does this automatically at session start) |
58
69
  | `eml_recall` | `POST /recall` | Topic search (FTS5 + recency) |
59
70
 
60
71
  ### Write (typed)
@@ -64,14 +75,14 @@ All tools have an `eml_` prefix. Total: **17 tools**.
64
75
  | `eml_decide` | `POST /context` (type=decision) | Record a deliberate, documented decision |
65
76
  | `eml_set_status` | `POST /context` (type=status) | Set current status for a scope (auto-supersedes old active status) |
66
77
  | `eml_track_task` | `POST /context` (type=task) | Plan/track a task with priority + due date |
67
- | `eml_note` | `POST /context` (kind-discriminated) | Sammelfach for rule/profile/event/reference/log |
78
+ | `eml_note` | `POST /context` (kind-discriminated) | Catch-all for rule/profile/event/reference/log |
68
79
 
69
80
  ### Read / Find
70
81
 
71
82
  | Tool | HTTP endpoint | Use case |
72
83
  |---|---|---|
73
84
  | `eml_show` | `GET /brain-state?scope=` | Curated snapshot for any scope |
74
- | `eml_list` | `GET /list[/mode]` | Filter-based engram list |
85
+ | `eml_list` | `GET /list` | Filter-based engram list |
75
86
  | `eml_get` | `GET /engram/:id` | Single engram + relations |
76
87
  | `eml_projects` | `GET /projects` | List projects (filter: status) |
77
88
  | `eml_entities` | `GET /entities` | List entities (filter: kind) |
@@ -92,12 +103,12 @@ All tools have an `eml_` prefix. Total: **17 tools**.
92
103
  | `eml_entity_create` | `POST /entity` | Register an entity (required before `scope=entity.<id>`) |
93
104
  | `eml_entity_update` | `PUT /entity/:id` | Patch entity fields |
94
105
 
95
- ### Intentionally not exposed (v0.9.1)
106
+ ### Intentionally not exposed (v0.10.0)
96
107
 
97
108
  - `eml_relate` — available via HTTP API directly
98
- - `eml_confirm_review` — deferred to brain-hygiene cluster (post-v0.9.1)
99
- - Epistemic-mode write tools (observation/hypothesis/assessment/prediction/pattern) — available via HTTP API
100
- - `eml_session_get` — deferred to v0.9.2 (cross-session awareness)
109
+ - `eml_confirm_review` — deferred to brain-hygiene cluster
110
+ - Epistemic-mode write tools (observation/hypothesis/assessment/prediction/pattern) — Alpha-state, available via HTTP API
111
+ - Session-Awareness tools — deferred to its own future version
101
112
  - `eml_*_delete` — by design not in the agent action space; cleanup is operator-only
102
113
 
103
114
  ## Error handling
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "@engramprotocol/mcp-server",
3
- "version": "0.9.1",
4
- "description": "MCP wrapper for the EML HTTP API — exposes the Engram Protocol as MCP tools for Claude Code and other MCP clients",
3
+ "version": "0.10.1",
4
+ "description": "MCP wrapper for the EML HTTP API — exposes the Engram Protocol as MCP tools for Claude Code and other MCP clients. Includes setup-mode for one-shot install/update/uninstall.",
5
5
  "license": "MIT",
6
6
  "main": "dist/server.js",
7
7
  "types": "dist/server.d.ts",
8
8
  "bin": {
9
- "eml-mcp-server": "./dist/cli.js"
9
+ "eml-mcp-server": "./dist/cli.js",
10
+ "mcp-server": "./dist/cli.js"
10
11
  },
11
12
  "files": [
12
13
  "dist",
14
+ "templates",
13
15
  "README.md",
14
16
  "LICENSE"
15
17
  ],
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env bash
2
+ # managed-by: engramprotocol-setup
3
+ #
4
+ # SessionStart-Hook: loads the EML brain into Claude Code's session context.
5
+ # Output is invisible-in-chat but reaches the model's context (verified empirically
6
+ # via spike 2026-05-15 — see brain decision dc5a9ad5).
7
+ #
8
+ # Layout: 7 sections — safety+constants, log+stdin, config check, sanity, /boot
9
+ # call, update-banner check, emit markdown.
10
+
11
+ set -eu
12
+
13
+ # --- 1. Safety + Constants -------------------------------------------------
14
+ CONFIG="$HOME/.eml/config"
15
+ LOG_DIR="$HOME/.eml/logs"
16
+
17
+ # --- 2. Log setup + stdin capture ------------------------------------------
18
+ mkdir -p "$LOG_DIR"
19
+ LOG_FILE="$LOG_DIR/session-start-$(date -u +%Y-%m-%d).log"
20
+ TS=$(date -u +%Y-%m-%dT%H:%M:%SZ)
21
+ STDIN=$(cat || true)
22
+ echo "[$TS] fired (pid=$$) stdin=$STDIN" >> "$LOG_FILE"
23
+
24
+ # --- 3. Config check + source ----------------------------------------------
25
+ if [ ! -f "$CONFIG" ]; then
26
+ echo "⚠️ EML config missing at $CONFIG — run 'npx @engramprotocol/mcp-server setup'"
27
+ echo "[$TS] FAIL config missing" >> "$LOG_FILE"
28
+ exit 0
29
+ fi
30
+ . "$CONFIG"
31
+
32
+ # --- 4. Sanity: required vars ----------------------------------------------
33
+ if [ -z "${EML_URL:-}" ] || [ -z "${EML_API_TOKEN:-}" ]; then
34
+ echo "⚠️ EML config incomplete — EML_URL or EML_API_TOKEN missing in $CONFIG"
35
+ echo "[$TS] FAIL incomplete config" >> "$LOG_FILE"
36
+ exit 0
37
+ fi
38
+
39
+ # --- 5. Call /boot ---------------------------------------------------------
40
+ RESPONSE=$(curl -fsS -m 8 \
41
+ -H "Authorization: Bearer $EML_API_TOKEN" \
42
+ -H "Content-Type: application/json" \
43
+ -X POST -d '{}' \
44
+ "$EML_URL/boot" 2>>"$LOG_FILE") || {
45
+ echo "⚠️ EML Boot failed — server unreachable or auth error. See $LOG_FILE"
46
+ echo "[$TS] FAIL curl non-zero" >> "$LOG_FILE"
47
+ exit 0
48
+ }
49
+
50
+ # --- 6. Update-banner check ------------------------------------------------
51
+ SERVER_VER=$(echo "$RESPONSE" | jq -r '.version // empty')
52
+ if [ -n "${EML_CLIENT_VERSION:-}" ] && [ -n "$SERVER_VER" ] && [ "$EML_CLIENT_VERSION" != "$SERVER_VER" ]; then
53
+ cat <<EOF
54
+ ## ⚠️ Update Available
55
+ - @engramprotocol/mcp-server: $EML_CLIENT_VERSION → $SERVER_VER available
56
+ - **Run** \`npx @engramprotocol/mcp-server setup update\`, **or ask me to update for you** — I'll run it on your behalf.
57
+
58
+ EOF
59
+ fi
60
+
61
+ # --- 7. Emit boot markdown + log success -----------------------------------
62
+ echo "$RESPONSE" | jq -r '.markdown'
63
+ echo "[$TS] OK ver=$SERVER_VER bytes=$(echo "$RESPONSE" | wc -c)" >> "$LOG_FILE"
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env bash
2
+ # managed-by: engramprotocol-setup
3
+ #
4
+ # UserPromptSubmit-Hook: Mid-session reminder to keep the model anchored in EML
5
+ # patterns. Claude Code fires this hook on every user message. The hook decides
6
+ # whether to print the reminder (when a trigger condition matches) or stay silent.
7
+ #
8
+ # Triggers (any one suffices):
9
+ # - turn == 1 (initial reminder at session start; SessionStart-Hook already
10
+ # loaded SYSTEM_RULES + brain state, so one reinforcement is enough)
11
+ # - turn % 5 == 0 (every 5th turn — anti-drift cadence)
12
+ # - counter file mtime > 1h ago (session resumed after pause)
13
+ #
14
+ # State files (per v0.10.0-PROPOSAL B.4.1):
15
+ # /tmp/eml-turns/<session_id> turn counter
16
+ # ~/.eml/logs/user-prompt-submit-*.log debug log (self-rotating per day)
17
+ #
18
+ # Local-only, no HTTP. Reminder content lives inline as heredoc — single source of
19
+ # truth, evolves with the npm-package via `setup update`.
20
+
21
+ set -eu
22
+
23
+ LOG_DIR="$HOME/.eml/logs"
24
+ TURNS_DIR="/tmp/eml-turns"
25
+
26
+ mkdir -p "$LOG_DIR" "$TURNS_DIR"
27
+ LOG_FILE="$LOG_DIR/user-prompt-submit-$(date -u +%Y-%m-%d).log"
28
+ TS=$(date -u +%Y-%m-%dT%H:%M:%SZ)
29
+
30
+ # --- 1. Parse stdin for session_id -----------------------------------------
31
+ STDIN=$(cat || true)
32
+ SESSION_ID=$(echo "$STDIN" | jq -r '.session_id // empty' 2>/dev/null || true)
33
+
34
+ if [ -z "$SESSION_ID" ]; then
35
+ echo "[$TS] no session_id in stdin, silent" >> "$LOG_FILE"
36
+ exit 0
37
+ fi
38
+
39
+ COUNTER_FILE="$TURNS_DIR/$SESSION_ID"
40
+
41
+ # --- 2. Read counter + detect long pause -----------------------------------
42
+ RESUMED_AFTER_PAUSE=0
43
+ if [ -f "$COUNTER_FILE" ]; then
44
+ TURN=$(cat "$COUNTER_FILE" 2>/dev/null || echo 0)
45
+ # mtime — macOS uses `stat -f %m`, Linux uses `stat -c %Y`
46
+ MTIME=$(stat -f %m "$COUNTER_FILE" 2>/dev/null || stat -c %Y "$COUNTER_FILE" 2>/dev/null || echo 0)
47
+ NOW=$(date +%s)
48
+ ELAPSED=$((NOW - MTIME))
49
+ if [ "$ELAPSED" -gt 3600 ]; then RESUMED_AFTER_PAUSE=1; fi
50
+ else
51
+ TURN=0
52
+ fi
53
+
54
+ TURN=$((TURN + 1))
55
+ echo "$TURN" > "$COUNTER_FILE"
56
+
57
+ # --- 3. Trigger decision ---------------------------------------------------
58
+ SHOULD_REMIND=0
59
+ if [ "$TURN" -eq 1 ]; then SHOULD_REMIND=1; fi
60
+ if [ "$((TURN % 5))" -eq 0 ]; then SHOULD_REMIND=1; fi
61
+ if [ "$RESUMED_AFTER_PAUSE" -eq 1 ]; then SHOULD_REMIND=1; fi
62
+
63
+ if [ "$SHOULD_REMIND" -eq 0 ]; then
64
+ echo "[$TS] silent turn=$TURN sid=$SESSION_ID" >> "$LOG_FILE"
65
+ exit 0
66
+ fi
67
+
68
+ # --- 4. Emit reminder (invisible-in-chat, in-model-context per Spike-2) ----
69
+ cat <<'EOF'
70
+ [EML Reminder]
71
+ - Store-worthy moments (decisions, status changes, tasks, events, feedback rules) → use the matching typed tool (eml_decide / eml_set_status / eml_track_task / eml_note).
72
+ - Question about customer / project / topic? eml_recall or eml_show first — don't guess from conversation memory.
73
+ - Before write: matching active engram exists? skip, or supersede via eml_update (don't duplicate).
74
+ - Routine updates: act + inform in 1-2 lines, no permission-asking.
75
+ - EML brain is the canonical knowledge base — check it before falling back to conversation memory.
76
+ EOF
77
+
78
+ echo "[$TS] OK turn=$TURN sid=$SESSION_ID reminded (pause=$RESUMED_AFTER_PAUSE)" >> "$LOG_FILE"
package/dist/cli.d.ts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js DELETED
@@ -1,79 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const server_1 = require("./server");
5
- function parseArgs(argv) {
6
- const out = {};
7
- for (let i = 0; i < argv.length; i++) {
8
- const a = argv[i];
9
- if (a === '--help' || a === '-h') {
10
- out.help = true;
11
- continue;
12
- }
13
- if (a === '--url') {
14
- out.url = argv[++i];
15
- continue;
16
- }
17
- if (a === '--token') {
18
- out.token = argv[++i];
19
- continue;
20
- }
21
- if (a === '--name') {
22
- out.name = argv[++i];
23
- continue;
24
- }
25
- }
26
- return out;
27
- }
28
- function printHelpAndExit(code) {
29
- const msg = `eml-mcp-server — MCP wrapper for the EML HTTP API
30
-
31
- Usage:
32
- eml-mcp-server --url <api-url> --token <bearer> [--name <client-name>]
33
-
34
- Args:
35
- --url EML_API_URL EML API URL (e.g. http://localhost:3117)
36
- --token EML_API_TOKEN Bearer token (eml_<prefix><secret>)
37
- --name EML_CLIENT_NAME Client name in server logs (default: eml-mcp-server)
38
- --help
39
-
40
- Example — Claude Code MCP config:
41
- {
42
- "mcpServers": {
43
- "engramprotocol": {
44
- "command": "npx",
45
- "args": ["-y", "@engramprotocol/mcp-server"],
46
- "env": {
47
- "EML_API_URL": "https://api.engramprotocol.io",
48
- "EML_API_TOKEN": "eml_..."
49
- }
50
- }
51
- }
52
- }
53
- `;
54
- process.stderr.write(msg);
55
- process.exit(code);
56
- }
57
- async function main() {
58
- const args = parseArgs(process.argv.slice(2));
59
- if (args.help)
60
- printHelpAndExit(0);
61
- const url = args.url ?? process.env.EML_API_URL;
62
- const token = args.token ?? process.env.EML_API_TOKEN;
63
- const clientName = args.name ?? process.env.EML_CLIENT_NAME ?? 'eml-mcp-server';
64
- if (!url || !token) {
65
- process.stderr.write('Error: --url + --token (or EML_API_URL + EML_API_TOKEN) are required.\n\n');
66
- printHelpAndExit(1);
67
- }
68
- try {
69
- await (0, server_1.startMcpServer)({ url, token, clientName });
70
- process.stderr.write(`[eml-mcp-server] connected, stdio-transport ready (${clientName} → ${url})\n`);
71
- }
72
- catch (err) {
73
- const e = err;
74
- process.stderr.write(`[eml-mcp-server] startup failed: ${e.message}\n`);
75
- process.exit(1);
76
- }
77
- }
78
- main();
79
- //# sourceMappingURL=cli.js.map
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,qCAAyC;AAuBzC,SAAS,SAAS,CAAC,IAAc;IAC/B,MAAM,GAAG,GAAY,EAAE,CAAA;IACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;YAAC,SAAQ;QAAC,CAAC;QAC/D,IAAI,CAAC,KAAK,OAAO,EAAI,CAAC;YAAC,GAAG,CAAC,GAAG,GAAK,I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C;QACH,MAAM,IAAA,uBAAc,EAAC,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAA;QAChD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sDAAsD,UAAU,MAAM,GAAG,KAAK,CAAC,CAAA;IACtG,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,GAAY,CAAA;QACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAA;QACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAA"}
@@ -1,33 +0,0 @@
1
- /**
2
- * Thin fetch wrapper for the EML HTTP API (v0.9-PROPOSAL §6.2).
3
- *
4
- * Deliberately lives without an `@engramprotocol/core` dependency — the MCP
5
- * server ships as a small npm package (`@engramprotocol/mcp-server`) that
6
- * only needs the SDK + zod + this file.
7
- *
8
- * Error handling: all failures throw `EmlApiError`. Tools catch it in the
9
- * handler and map to an `isError: true` result (see v0.9-PROPOSAL §6.4
10
- * "Error handling — two channels").
11
- */
12
- export interface HttpClientOptions {
13
- url: string;
14
- token: string;
15
- timeoutMs?: number;
16
- }
17
- export declare class EmlApiError extends Error {
18
- status: number;
19
- body: unknown;
20
- constructor(status: number, body: unknown, message: string);
21
- }
22
- export declare class HttpClient {
23
- private readonly baseUrl;
24
- private readonly headers;
25
- private readonly timeoutMs;
26
- constructor(opts: HttpClientOptions);
27
- get(path: string, query?: Record<string, string | number | undefined>): Promise<unknown>;
28
- post(path: string, body?: unknown): Promise<unknown>;
29
- put(path: string, body?: unknown): Promise<unknown>;
30
- private buildPath;
31
- private request;
32
- }
33
- //# sourceMappingURL=http-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,qBAAa,WAAY,SAAQ,KAAK;IAE3B,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,OAAO;gBADb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACpB,OAAO,EAAE,MAAM;CAKlB;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAChD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;gBAEtB,IAAI,EAAE,iBAAiB;IAS7B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAIxF,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpD,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzD,OAAO,CAAC,SAAS;YAUH,OAAO;CA+BtB"}
@@ -1,106 +0,0 @@
1
- "use strict";
2
- /**
3
- * Thin fetch wrapper for the EML HTTP API (v0.9-PROPOSAL §6.2).
4
- *
5
- * Deliberately lives without an `@engramprotocol/core` dependency — the MCP
6
- * server ships as a small npm package (`@engramprotocol/mcp-server`) that
7
- * only needs the SDK + zod + this file.
8
- *
9
- * Error handling: all failures throw `EmlApiError`. Tools catch it in the
10
- * handler and map to an `isError: true` result (see v0.9-PROPOSAL §6.4
11
- * "Error handling — two channels").
12
- */
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.HttpClient = exports.EmlApiError = void 0;
15
- class EmlApiError extends Error {
16
- status;
17
- body;
18
- constructor(status, body, message) {
19
- super(message);
20
- this.status = status;
21
- this.body = body;
22
- this.name = 'EmlApiError';
23
- }
24
- }
25
- exports.EmlApiError = EmlApiError;
26
- class HttpClient {
27
- baseUrl;
28
- headers;
29
- timeoutMs;
30
- constructor(opts) {
31
- this.baseUrl = opts.url.replace(/\/+$/, '');
32
- this.headers = {
33
- 'Authorization': `Bearer ${opts.token}`,
34
- 'Content-Type': 'application/json',
35
- };
36
- this.timeoutMs = opts.timeoutMs ?? 30_000;
37
- }
38
- async get(path, query) {
39
- return this.request('GET', this.buildPath(path, query));
40
- }
41
- async post(path, body) {
42
- return this.request('POST', path, body);
43
- }
44
- async put(path, body) {
45
- return this.request('PUT', path, body);
46
- }
47
- buildPath(path, query) {
48
- if (!query)
49
- return path;
50
- const params = [];
51
- for (const [k, v] of Object.entries(query)) {
52
- if (v === undefined || v === null)
53
- continue;
54
- params.push(`${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`);
55
- }
56
- return params.length ? `${path}?${params.join('&')}` : path;
57
- }
58
- async request(method, path, body) {
59
- const controller = new AbortController();
60
- const timer = setTimeout(() => controller.abort(), this.timeoutMs);
61
- try {
62
- const res = await fetch(`${this.baseUrl}${path}`, {
63
- method,
64
- headers: this.headers,
65
- body: body !== undefined ? JSON.stringify(body) : undefined,
66
- signal: controller.signal,
67
- });
68
- const text = await res.text();
69
- let parsed = null;
70
- if (text) {
71
- try {
72
- parsed = JSON.parse(text);
73
- }
74
- catch {
75
- parsed = text;
76
- }
77
- }
78
- if (!res.ok) {
79
- const msg = extractErrorMessage(parsed) ?? `HTTP ${res.status}`;
80
- throw new EmlApiError(res.status, parsed, `${method} ${path} → ${res.status}: ${msg}`);
81
- }
82
- return parsed;
83
- }
84
- catch (err) {
85
- if (err instanceof EmlApiError)
86
- throw err;
87
- const e = err;
88
- if (e.name === 'AbortError') {
89
- throw new EmlApiError(0, null, `${method} ${path} timed out after ${this.timeoutMs}ms`);
90
- }
91
- throw new EmlApiError(0, null, `${method} ${path} failed: ${e.message}`);
92
- }
93
- finally {
94
- clearTimeout(timer);
95
- }
96
- }
97
- }
98
- exports.HttpClient = HttpClient;
99
- function extractErrorMessage(body) {
100
- if (body && typeof body === 'object' && 'error' in body) {
101
- const e = body.error;
102
- return typeof e === 'string' ? e : JSON.stringify(e);
103
- }
104
- return null;
105
- }
106
- //# sourceMappingURL=http-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-client.js","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAQH,MAAa,WAAY,SAAQ,KAAK;IAE3B;IACA;IAFT,YACS,MAAc,EACd,IAAa,EACpB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAA;QAJP,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAS;QAIpB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;IAC3B,CAAC;CACF;AATD,kCASC;AAED,MAAa,UAAU;IACJ,OAAO,CAAQ;IACf,OAAO,CAAwB;IAC/B,SAAS,CAAQ;IAElC,YAAY,IAAuB;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QAC3C,IAAI,CAAC,OAAO,GAAG;YACb,eAAe,EAAE,UAAU,IAAI,CAAC,KAAK,EAAE;YACvC,cAAc,EAAE,kBAAkB;SACnC,CAAA;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,IAAY,EAAE,KAAmD;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IACzD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,IAAc;QAC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,YAAY,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC;IACH,CAAC;CACF;AAnED,gCAmEC;AAED,SAAS,mBAAmB,CAAC,IAAa;IACxC,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACxD,MAAM,CAAC,GAAI,IAA2B,CAAC,KAAK,CAAA;QAC5C,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
package/dist/server.d.ts DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * MCP server setup (v0.9-PROPOSAL §6).
3
- *
4
- * Single-mode HTTP client (no embedded SQLite). Self-host uses the same
5
- * invocation, just with `--url http://localhost:3117`.
6
- *
7
- * Stdio transport: local process spawned by Claude Code's MCP config.
8
- * Capabilities: tools only (static, listChanged=false). Resources/prompts
9
- * are v0.9.x polish.
10
- */
11
- export interface McpServerOptions {
12
- url: string;
13
- token: string;
14
- clientName?: string;
15
- serverVersion?: string;
16
- }
17
- export declare function startMcpServer(opts: McpServerOptions): Promise<void>;
18
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAY1E"}
package/dist/server.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.startMcpServer = startMcpServer;
4
- const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
5
- const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
6
- const http_client_1 = require("./http-client");
7
- const tools_1 = require("./tools");
8
- async function startMcpServer(opts) {
9
- const httpClient = new http_client_1.HttpClient({ url: opts.url, token: opts.token });
10
- const server = new mcp_js_1.McpServer({
11
- name: opts.clientName ?? 'eml-mcp-server',
12
- version: opts.serverVersion ?? '0.9.0',
13
- });
14
- (0, tools_1.registerAllTools)(server, httpClient);
15
- const transport = new stdio_js_1.StdioServerTransport();
16
- await server.connect(transport);
17
- }
18
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;AAuBA,wCAYC;AAnCD,oEAAmE;AACnE,wEAAgF;AAChF,+CAA0C;AAC1C,mCAA0C;AAoBnC,KAAK,UAAU,cAAc,CAAC,IAAsB;IACzD,MAAM,UAAU,GAAG,IAAI,wBAAU,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;IAEvE,MAAM,MAAM,GAAG,IAAI,kBAAS,CAAC;QAC3B,IAAI,EAAE,IAAI,CAAC,UAAU,IAAI,gBAAgB;QACzC,OAAO,EAAE,IAAI,CAAC,aAAa,IAAI,OAAO;KACvC,CAAC,CAAA;IAEF,IAAA,wBAAgB,EAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAEpC,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAA;IAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AACjC,CAAC"}
@@ -1,18 +0,0 @@
1
- /**
2
- * Tool handler wrapper (v0.9-PROPOSAL §6.4 "Error handling — two channels").
3
- *
4
- * - Backend errors (e.g. 401/500) → `isError: true` with a message for the
5
- * LLM (ideally phrased so the model can self-correct).
6
- * - Protocol errors (malformed request, unknown tool) are left to the SDK.
7
- *
8
- * The CallToolResult type comes from the SDK; we just return the plain object —
9
- * no type assertion needed (registerTool handles that).
10
- */
11
- export declare function callTool<T>(fn: () => Promise<T>): Promise<{
12
- content: Array<{
13
- type: 'text';
14
- text: string;
15
- }>;
16
- isError?: boolean;
17
- }>;
18
- //# sourceMappingURL=_helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_helpers.d.ts","sourceRoot":"","sources":["../../src/tools/_helpers.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAC/D,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAC,CAoBD"}
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.callTool = callTool;
4
- const http_client_1 = require("../http-client");
5
- /**
6
- * Tool handler wrapper (v0.9-PROPOSAL §6.4 "Error handling — two channels").
7
- *
8
- * - Backend errors (e.g. 401/500) → `isError: true` with a message for the
9
- * LLM (ideally phrased so the model can self-correct).
10
- * - Protocol errors (malformed request, unknown tool) are left to the SDK.
11
- *
12
- * The CallToolResult type comes from the SDK; we just return the plain object —
13
- * no type assertion needed (registerTool handles that).
14
- */
15
- async function callTool(fn) {
16
- try {
17
- const result = await fn();
18
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
19
- }
20
- catch (err) {
21
- if (err instanceof http_client_1.EmlApiError) {
22
- return {
23
- isError: true,
24
- content: [{
25
- type: 'text',
26
- text: `EML API error (HTTP ${err.status}): ${err.message}`,
27
- }],
28
- };
29
- }
30
- const e = err;
31
- return {
32
- isError: true,
33
- content: [{ type: 'text', text: `Tool execution failed: ${e.message}` }],
34
- };
35
- }
36
- }
37
- //# sourceMappingURL=_helpers.js.map