@xache/mcp-server 0.6.0 → 0.8.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/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # @xache/mcp-server
2
2
 
3
- MCP (Model Context Protocol) server for Xache Protocol - collective intelligence, verifiable memory, extraction, and reputation for AI agents.
3
+ MCP (Model Context Protocol) server for Xache Protocol - collective intelligence, verifiable memory, ephemeral working memory, knowledge graph, extraction, and reputation for AI agents.
4
4
 
5
5
  Works with any MCP-compatible client:
6
6
  - Claude Desktop
7
+ - Claude Code
7
8
  - OpenClaw
8
9
  - Cursor
9
10
  - Any MCP client
@@ -36,7 +37,7 @@ export XACHE_CHAIN=base # or 'solana'
36
37
  # Saves cost: $0.002 vs $0.011 with Xache-managed LLM
37
38
  export XACHE_LLM_PROVIDER=anthropic # or 'openai'
38
39
  export XACHE_LLM_API_KEY=sk-ant-...
39
- export XACHE_LLM_MODEL=claude-3-5-sonnet-20241022 # optional
40
+ export XACHE_LLM_MODEL=claude-sonnet-4-5-20250929 # optional
40
41
  ```
41
42
 
42
43
  ### Claude Desktop
@@ -60,9 +61,26 @@ Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_
60
61
  }
61
62
  ```
62
63
 
63
- ### OpenClaw
64
+ ### Claude Code
65
+
66
+ Add to your Claude Code MCP config:
67
+
68
+ ```json
69
+ {
70
+ "mcpServers": {
71
+ "xache": {
72
+ "command": "npx",
73
+ "args": ["@xache/mcp-server"],
74
+ "env": {
75
+ "XACHE_WALLET_ADDRESS": "0x...",
76
+ "XACHE_PRIVATE_KEY": "0x..."
77
+ }
78
+ }
79
+ }
80
+ }
81
+ ```
64
82
 
65
- Add to your OpenClaw config:
83
+ ### OpenClaw
66
84
 
67
85
  ```json
68
86
  {
@@ -73,9 +91,7 @@ Add to your OpenClaw config:
73
91
  "args": ["@xache/mcp-server"],
74
92
  "env": {
75
93
  "XACHE_WALLET_ADDRESS": "0x...",
76
- "XACHE_PRIVATE_KEY": "0x...",
77
- "XACHE_LLM_PROVIDER": "anthropic",
78
- "XACHE_LLM_API_KEY": "sk-ant-..."
94
+ "XACHE_PRIVATE_KEY": "0x..."
79
95
  }
80
96
  }
81
97
  }
@@ -88,207 +104,172 @@ Add to your OpenClaw config:
88
104
  ### Collective Intelligence
89
105
 
90
106
  #### `xache_collective_contribute`
91
-
92
- Share an insight with the collective intelligence pool. Quality contributions earn reputation.
93
-
94
- **Parameters:**
95
- - `pattern` (required): The insight or pattern to share (10-500 chars)
96
- - `domain` (required): Domain/topic (e.g., "api-integration", "research")
97
- - `tags` (required): Categorization tags (1-10 tags)
98
- - `successRate` (optional): Success rate of this pattern (0.0-1.0, default: 0.8)
107
+ Share an insight with the collective intelligence pool.
108
+ - `pattern` (required): The insight or pattern (10-500 chars)
109
+ - `domain` (required): Domain/topic
110
+ - `tags` (required): Categorization tags (1-10)
111
+ - `successRate` (optional): Success rate (0.0-1.0)
99
112
 
100
113
  #### `xache_collective_query`
101
-
102
- Query insights from other agents in the collective.
103
-
104
- **Parameters:**
105
- - `queryText` (required): What to search for (5-500 chars)
114
+ Query insights from the collective.
115
+ - `queryText` (required): What to search for
106
116
  - `domain` (optional): Filter by domain
107
- - `limit` (optional): Max results (1-50, default 5)
117
+ - `limit` (optional): Max results (default 5)
108
118
 
109
119
  #### `xache_collective_list`
110
-
111
- List heuristics in the collective intelligence pool.
112
-
113
- **Parameters:**
120
+ List heuristics in the collective pool.
114
121
  - `domain` (optional): Filter by domain
115
122
  - `limit` (optional): Max results (default 20)
116
123
 
117
124
  ### Memory
118
125
 
119
126
  #### `xache_memory_store`
120
-
121
- Store data with cryptographic receipt. Use for important information that needs verification.
122
-
123
- **Parameters:**
127
+ Store data with cryptographic receipt.
124
128
  - `data` (required): The data object to store
125
- - `context` (optional): Context/category for organization
129
+ - `context` (optional): Context/category
126
130
  - `tags` (optional): Tags for filtering
127
- - `tier` (optional): Storage tier - "hot", "warm", or "cold" (default: warm)
131
+ - `tier` (optional): "hot", "warm", or "cold" (default: warm)
128
132
 
129
133
  #### `xache_memory_retrieve`
130
-
131
- Retrieve a stored memory by its storage key.
132
-
133
- **Parameters:**
134
- - `storageKey` (required): The storage key from when the memory was stored
134
+ Retrieve a stored memory.
135
+ - `storageKey` (required): The storage key
135
136
 
136
137
  #### `xache_memory_list`
137
-
138
- List your stored memories.
139
-
140
- **Parameters:**
138
+ List stored memories.
141
139
  - `context` (optional): Filter by context
142
140
  - `limit` (optional): Max results (default 20)
143
141
 
144
- ### Extraction
142
+ ### Ephemeral Context
145
143
 
146
- #### `xache_extract_memories`
144
+ Short-lived working memory sessions with 6 named slots (`conversation`, `facts`, `tasks`, `cache`, `scratch`, `handoff`). Sessions auto-expire and can be promoted to persistent memory.
147
145
 
148
- Extract structured memories from agent traces using LLM. Automatically stores extracted memories.
146
+ #### `xache_ephemeral_create_session`
147
+ Create a new ephemeral working memory session.
148
+ - `ttlSeconds` (optional): Time-to-live in seconds (default 3600)
149
+ - `maxWindows` (optional): Max renewal windows (default 5)
149
150
 
150
- **Pricing:**
151
- - BYOK mode (your API key): $0.002
152
- - Xache-managed LLM: $0.011
151
+ #### `xache_ephemeral_write_slot`
152
+ Write data to an ephemeral slot.
153
+ - `sessionKey` (required): The session key
154
+ - `slot` (required): Slot name (conversation, facts, tasks, cache, scratch, handoff)
155
+ - `data` (required): Data object to write
153
156
 
154
- **Parameters:**
155
- - `trace` (required): The agent trace/conversation to extract from
156
- - `mode` (optional): "byok" or "xache-managed" (default: byok if API key set)
157
- - `provider` (optional): "anthropic" or "openai" (default: anthropic)
158
- - `model` (optional): Specific model to use
159
- - `contextHint` (optional): Context hint to guide extraction
160
- - `confidenceThreshold` (optional): Min confidence (0.0-1.0, default: 0.7)
161
- - `autoStore` (optional): Auto-store extracted memories (default: true)
157
+ #### `xache_ephemeral_read_slot`
158
+ Read data from an ephemeral slot.
159
+ - `sessionKey` (required): The session key
160
+ - `slot` (required): Slot name
162
161
 
163
- **Example:**
164
- ```
165
- Extract memories from this coding session and store any useful patterns.
166
- ```
162
+ #### `xache_ephemeral_promote`
163
+ Promote an ephemeral session to persistent memory. Extracts valuable data from all slots and stores as permanent memories.
164
+ - `sessionKey` (required): The session key
167
165
 
168
- #### `xache_extract_and_contribute`
166
+ #### `xache_ephemeral_status`
167
+ Get ephemeral session status and details.
168
+ - `sessionKey` (required): The session key
169
169
 
170
- Extract memories AND automatically contribute high-quality heuristics to the collective. Earns reputation for valuable insights.
170
+ **Typical workflow:**
171
+ 1. Create a session at conversation start
172
+ 2. Write facts, tasks, and context to slots as the conversation progresses
173
+ 3. Read slots to maintain context across tool calls
174
+ 4. Promote to persistent memory if the session contained lasting value
175
+ 5. Or let it expire naturally for transient working memory
171
176
 
172
- **Parameters:**
173
- - `trace` (required): The agent trace to extract from
174
- - `domain` (required): Domain for contributed heuristics
177
+ ### Extraction
178
+
179
+ #### `xache_extract_memories`
180
+ Extract structured memories from agent traces using LLM.
181
+ - `trace` (required): The conversation to extract from
175
182
  - `mode` (optional): "byok" or "xache-managed"
176
183
  - `provider` (optional): "anthropic" or "openai"
177
- - `contributionThreshold` (optional): Min confidence for auto-contribute (default: 0.85)
184
+ - `contextHint` (optional): Context hint
185
+ - `confidenceThreshold` (optional): Min confidence (default 0.7)
186
+ - `autoStore` (optional): Auto-store extracted memories (default true)
178
187
 
179
- **Example:**
180
- ```
181
- Extract insights from this API integration session and contribute any valuable patterns to the collective.
182
- Domain: "api-integration"
183
- ```
188
+ #### `xache_extract_and_contribute`
189
+ Extract memories AND auto-contribute heuristics to the collective.
190
+ - `trace` (required): The agent trace
191
+ - `domain` (required): Domain for contributed heuristics
192
+ - `contributionThreshold` (optional): Min confidence for auto-contribute (default 0.85)
184
193
 
185
194
  ### Knowledge Graph
186
195
 
187
196
  #### `xache_graph_extract`
188
-
189
- Extract entities and relationships from text into the knowledge graph.
190
-
191
- **Parameters:**
192
- - `trace` (required): The text to extract entities from
193
- - `domain` (optional): Domain hint (e.g., "engineering", "customer-support")
194
- - `mode` (optional): LLM mode - "byok" or "xache-managed"
195
- - `provider` (optional): LLM provider
196
- - `model` (optional): Specific model to use
197
+ Extract entities and relationships from text.
198
+ - `trace` (required): Text to extract from
199
+ - `domain` (optional): Domain hint
197
200
 
198
201
  #### `xache_graph_load`
199
-
200
202
  Load the full knowledge graph.
201
-
202
- **Parameters:**
203
- - `entityTypes` (optional): Filter to specific entity types
204
- - `validAt` (optional): Load graph at a specific time (ISO8601)
203
+ - `entityTypes` (optional): Filter to specific types
204
+ - `validAt` (optional): Load at a specific time (ISO8601)
205
205
 
206
206
  #### `xache_graph_query`
207
-
208
- Query the knowledge graph around a specific entity.
209
-
210
- **Parameters:**
211
- - `startEntity` (required): Entity name to start from
212
- - `depth` (optional): Number of hops (default: 2)
207
+ Query around a specific entity.
208
+ - `startEntity` (required): Entity name
209
+ - `depth` (optional): Number of hops (default 2)
213
210
 
214
211
  #### `xache_graph_ask`
215
-
216
- Ask a natural language question about the knowledge graph.
217
-
218
- **Parameters:**
219
- - `question` (required): The question to ask
220
- - `mode` (optional): LLM mode
221
- - `provider` (optional): LLM provider
212
+ Ask a natural language question about the graph.
213
+ - `question` (required): The question
222
214
 
223
215
  #### `xache_graph_add_entity`
224
-
225
- Add an entity to the knowledge graph.
226
-
227
- **Parameters:**
216
+ Add an entity.
228
217
  - `name` (required): Entity name
229
- - `type` (required): Entity type (person, organization, tool, concept, etc.)
230
- - `summary` (optional): Brief description
218
+ - `type` (required): Entity type
219
+ - `summary` (optional): Description
231
220
 
232
221
  #### `xache_graph_add_relationship`
233
-
234
- Create a relationship between two entities.
235
-
236
- **Parameters:**
237
- - `fromEntity` (required): Source entity name
238
- - `toEntity` (required): Target entity name
239
- - `type` (required): Relationship type (works_at, knows, uses, manages, etc.)
240
- - `description` (optional): Relationship description
222
+ Create a relationship between entities.
223
+ - `fromEntity` (required): Source entity
224
+ - `toEntity` (required): Target entity
225
+ - `type` (required): Relationship type
226
+ - `description` (optional): Description
241
227
 
242
228
  #### `xache_graph_merge_entities`
243
-
244
- Merge two entities into one. The source is superseded and the target is updated.
245
-
246
- **Parameters:**
229
+ Merge two entities into one.
247
230
  - `sourceName` (required): Entity to merge FROM
248
231
  - `targetName` (required): Entity to merge INTO
249
232
 
250
233
  #### `xache_graph_entity_history`
251
-
252
- Get the full version history of an entity.
253
-
254
- **Parameters:**
255
- - `name` (required): Entity name to look up
234
+ Get entity version history.
235
+ - `name` (required): Entity name
256
236
 
257
237
  ### Reputation
258
238
 
259
239
  #### `xache_check_reputation`
260
-
261
- Check your agent's reputation score. Higher reputation means lower costs and more trust.
262
-
263
- **No parameters required.**
264
-
265
- Returns:
266
- - Overall score (0.0-1.0)
267
- - Level (New, Developing, Established, Trusted, Elite)
268
- - Breakdown by category
240
+ Check your agent's reputation score. No parameters required.
269
241
 
270
242
  #### `xache_leaderboard`
271
-
272
- View top agents by reputation score.
273
-
274
- **Parameters:**
275
- - `limit` (optional): Number of agents to show (default 10)
243
+ View top agents by reputation.
244
+ - `limit` (optional): Number of agents (default 10)
245
+
246
+ ## Pricing
247
+
248
+ | Operation | Price |
249
+ |-----------|-------|
250
+ | Memory Store | $0.002 |
251
+ | Memory Retrieve | $0.003 |
252
+ | Collective Contribute | $0.002 |
253
+ | Collective Query | $0.011 |
254
+ | Ephemeral Session | $0.005 |
255
+ | Ephemeral Promote | $0.05 |
256
+ | Extraction (BYOK) | $0.002 |
257
+ | Extraction (managed) | $0.011 |
258
+ | Graph Operations | $0.002 |
259
+ | Graph Ask (managed) | $0.011 |
276
260
 
277
261
  ## Security
278
262
 
279
- The private key is used **client-side only** for signing. It is never transmitted to Xache servers. Only signatures are sent to prove wallet ownership.
263
+ The private key is used **client-side only** for signing. It is never transmitted to Xache servers.
280
264
 
281
265
  ```
282
- ┌─────────────────────────────────────────┐
283
- │ MCP Server (local) │
284
- │ Private Key → Sign → Signature │
285
- └─────────────────┬───────────────────────┘
286
- │ Only signatures sent
287
-
288
- ┌─────────────────────────────────────────┐
289
- │ Xache API │
290
- │ Verifies signature, never sees key │
291
- └─────────────────────────────────────────┘
266
+ MCP Server (local)
267
+ Private Key -> Sign -> Signature
268
+ |
269
+ | Only signatures sent
270
+ v
271
+ Xache API
272
+ Verifies signature, never sees key
292
273
  ```
293
274
 
294
275
  ## Links
package/dist/index.js CHANGED
@@ -647,6 +647,127 @@ const TOOLS = [
647
647
  required: ['name'],
648
648
  },
649
649
  },
650
+ // =========================================================================
651
+ // Memory Probe (Cognitive Fingerprints)
652
+ // =========================================================================
653
+ {
654
+ name: 'xache_memory_probe',
655
+ description: 'Search your memories by topic using zero-knowledge semantic matching. Uses cognitive fingerprints to find relevant memories without knowing exact storage keys. All fingerprint computation is client-side — the server never sees plaintext.',
656
+ inputSchema: {
657
+ type: 'object',
658
+ properties: {
659
+ query: {
660
+ type: 'string',
661
+ description: 'What to search for in your memories',
662
+ },
663
+ category: {
664
+ type: 'string',
665
+ enum: [
666
+ 'preference', 'fact', 'event', 'procedure', 'relationship',
667
+ 'observation', 'decision', 'goal', 'constraint', 'reference',
668
+ 'summary', 'handoff', 'pattern', 'feedback', 'unknown',
669
+ ],
670
+ description: 'Optional cognitive category filter',
671
+ },
672
+ limit: {
673
+ type: 'number',
674
+ description: 'Maximum number of results (default: 10, max: 50)',
675
+ },
676
+ },
677
+ required: ['query'],
678
+ },
679
+ },
680
+ // =========================================================================
681
+ // Ephemeral Context Tools
682
+ // =========================================================================
683
+ {
684
+ name: 'xache_ephemeral_create_session',
685
+ description: 'Create a new ephemeral working memory session. Returns a session key for storing temporary data in slots (conversation, facts, tasks, cache, scratch, handoff). Sessions auto-expire after TTL.',
686
+ inputSchema: {
687
+ type: 'object',
688
+ properties: {
689
+ ttlSeconds: {
690
+ type: 'number',
691
+ description: 'Session time-to-live in seconds (default: 3600)',
692
+ },
693
+ maxWindows: {
694
+ type: 'number',
695
+ description: 'Maximum renewal windows (default: 5)',
696
+ },
697
+ },
698
+ required: [],
699
+ },
700
+ },
701
+ {
702
+ name: 'xache_ephemeral_write_slot',
703
+ description: 'Write data to an ephemeral session slot. Use slots to organize working memory: conversation (dialog history), facts (extracted facts), tasks (current tasks), cache (temporary data), scratch (working notes), handoff (data for next agent).',
704
+ inputSchema: {
705
+ type: 'object',
706
+ properties: {
707
+ sessionKey: {
708
+ type: 'string',
709
+ description: 'The ephemeral session key',
710
+ },
711
+ slot: {
712
+ type: 'string',
713
+ enum: ['conversation', 'facts', 'tasks', 'cache', 'scratch', 'handoff'],
714
+ description: 'Slot name',
715
+ },
716
+ data: {
717
+ type: 'object',
718
+ description: 'Data to write to the slot',
719
+ },
720
+ },
721
+ required: ['sessionKey', 'slot', 'data'],
722
+ },
723
+ },
724
+ {
725
+ name: 'xache_ephemeral_read_slot',
726
+ description: 'Read data from an ephemeral session slot.',
727
+ inputSchema: {
728
+ type: 'object',
729
+ properties: {
730
+ sessionKey: {
731
+ type: 'string',
732
+ description: 'The ephemeral session key',
733
+ },
734
+ slot: {
735
+ type: 'string',
736
+ enum: ['conversation', 'facts', 'tasks', 'cache', 'scratch', 'handoff'],
737
+ description: 'Slot name',
738
+ },
739
+ },
740
+ required: ['sessionKey', 'slot'],
741
+ },
742
+ },
743
+ {
744
+ name: 'xache_ephemeral_promote',
745
+ description: 'Promote an ephemeral session to persistent memory. Extracts valuable data from all slots and stores as permanent memories with cryptographic receipts.',
746
+ inputSchema: {
747
+ type: 'object',
748
+ properties: {
749
+ sessionKey: {
750
+ type: 'string',
751
+ description: 'The ephemeral session key to promote',
752
+ },
753
+ },
754
+ required: ['sessionKey'],
755
+ },
756
+ },
757
+ {
758
+ name: 'xache_ephemeral_status',
759
+ description: 'Get the status and details of an ephemeral session. Shows active slots, total size, TTL, window count, and cumulative cost.',
760
+ inputSchema: {
761
+ type: 'object',
762
+ properties: {
763
+ sessionKey: {
764
+ type: 'string',
765
+ description: 'The ephemeral session key',
766
+ },
767
+ },
768
+ required: ['sessionKey'],
769
+ },
770
+ },
650
771
  ];
651
772
  // =============================================================================
652
773
  // Tool Handlers
@@ -1190,6 +1311,82 @@ async function handleGraphEntityHistory(client, args) {
1190
1311
  return output;
1191
1312
  }
1192
1313
  // =============================================================================
1314
+ // Memory Probe Handler
1315
+ // =============================================================================
1316
+ async function handleMemoryProbe(client, args) {
1317
+ const result = await client.memory.probe({
1318
+ query: args.query,
1319
+ category: args.category,
1320
+ limit: args.limit || 10,
1321
+ });
1322
+ const matches = result.matches || [];
1323
+ if (matches.length === 0) {
1324
+ return 'No matching memories found for this query.';
1325
+ }
1326
+ let output = `Found ${matches.length} matching memories (total: ${result.total}):\n`;
1327
+ matches.forEach((match, i) => {
1328
+ const data = typeof match.data === 'string'
1329
+ ? match.data.slice(0, 300)
1330
+ : JSON.stringify(match.data).slice(0, 300);
1331
+ output += `\n${i + 1}. [${match.category}] ${data}`;
1332
+ output += ` (key: ${match.storageKey})`;
1333
+ });
1334
+ return output;
1335
+ }
1336
+ // =============================================================================
1337
+ // Ephemeral Context Handlers
1338
+ // =============================================================================
1339
+ async function handleEphemeralCreateSession(client, args) {
1340
+ const session = await client.ephemeral.createSession({
1341
+ ttlSeconds: args.ttlSeconds,
1342
+ maxWindows: args.maxWindows,
1343
+ });
1344
+ return [
1345
+ `Created ephemeral session.`,
1346
+ `Session Key: ${session.sessionKey}`,
1347
+ `Status: ${session.status}`,
1348
+ `TTL: ${session.ttlSeconds}s`,
1349
+ `Window: ${session.window}/${session.maxWindows}`,
1350
+ `Expires: ${session.expiresAt}`,
1351
+ ].join('\n');
1352
+ }
1353
+ async function handleEphemeralWriteSlot(client, args) {
1354
+ await client.ephemeral.writeSlot(args.sessionKey, args.slot, args.data);
1355
+ return `Wrote data to slot "${args.slot}" in session ${args.sessionKey.substring(0, 12)}...`;
1356
+ }
1357
+ async function handleEphemeralReadSlot(client, args) {
1358
+ const data = await client.ephemeral.readSlot(args.sessionKey, args.slot);
1359
+ return `Slot "${args.slot}" data:\n${JSON.stringify(data, null, 2)}`;
1360
+ }
1361
+ async function handleEphemeralPromote(client, args) {
1362
+ const result = await client.ephemeral.promoteSession(args.sessionKey);
1363
+ let output = `Promoted session ${args.sessionKey.substring(0, 12)}...\n`;
1364
+ output += `Memories created: ${result.memoriesCreated}\n`;
1365
+ if (result.memoryIds.length > 0) {
1366
+ output += `Memory IDs: ${result.memoryIds.join(', ')}\n`;
1367
+ }
1368
+ if (result.receiptId) {
1369
+ output += `Receipt: ${result.receiptId}`;
1370
+ }
1371
+ return output;
1372
+ }
1373
+ async function handleEphemeralStatus(client, args) {
1374
+ const session = await client.ephemeral.getSession(args.sessionKey);
1375
+ if (!session) {
1376
+ return `Session ${args.sessionKey.substring(0, 12)}... not found.`;
1377
+ }
1378
+ return [
1379
+ `Session: ${session.sessionKey.substring(0, 12)}...`,
1380
+ `Status: ${session.status}`,
1381
+ `Window: ${session.window}/${session.maxWindows}`,
1382
+ `TTL: ${session.ttlSeconds}s`,
1383
+ `Expires: ${session.expiresAt}`,
1384
+ `Active Slots: ${session.activeSlots.length > 0 ? session.activeSlots.join(', ') : 'none'}`,
1385
+ `Total Size: ${session.totalSize} bytes`,
1386
+ `Cumulative Cost: $${session.cumulativeCost.toFixed(4)}`,
1387
+ ].join('\n');
1388
+ }
1389
+ // =============================================================================
1193
1390
  // Server Setup
1194
1391
  // =============================================================================
1195
1392
  async function main() {
@@ -1273,6 +1470,24 @@ async function main() {
1273
1470
  case 'xache_graph_entity_history':
1274
1471
  result = await handleGraphEntityHistory(client, args);
1275
1472
  break;
1473
+ case 'xache_memory_probe':
1474
+ result = await handleMemoryProbe(client, args);
1475
+ break;
1476
+ case 'xache_ephemeral_create_session':
1477
+ result = await handleEphemeralCreateSession(client, args);
1478
+ break;
1479
+ case 'xache_ephemeral_write_slot':
1480
+ result = await handleEphemeralWriteSlot(client, args);
1481
+ break;
1482
+ case 'xache_ephemeral_read_slot':
1483
+ result = await handleEphemeralReadSlot(client, args);
1484
+ break;
1485
+ case 'xache_ephemeral_promote':
1486
+ result = await handleEphemeralPromote(client, args);
1487
+ break;
1488
+ case 'xache_ephemeral_status':
1489
+ result = await handleEphemeralStatus(client, args);
1490
+ break;
1276
1491
  default:
1277
1492
  throw new Error(`Unknown tool: ${name}`);
1278
1493
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xache/mcp-server",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "MCP server for Xache Protocol - collective intelligence, verifiable memory, and reputation for AI agents",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "homepage": "https://xache.xyz",
33
33
  "dependencies": {
34
34
  "@modelcontextprotocol/sdk": "^1.0.0",
35
- "@xache/sdk": "^5.8.0",
35
+ "@xache/sdk": "^5.10.0",
36
36
  "zod": "^3.22.0"
37
37
  },
38
38
  "devDependencies": {
package/src/index.ts CHANGED
@@ -686,6 +686,135 @@ const TOOLS: Tool[] = [
686
686
  required: ['name'],
687
687
  },
688
688
  },
689
+
690
+ // =========================================================================
691
+ // Memory Probe (Cognitive Fingerprints)
692
+ // =========================================================================
693
+ {
694
+ name: 'xache_memory_probe',
695
+ description:
696
+ 'Search your memories by topic using zero-knowledge semantic matching. Uses cognitive fingerprints to find relevant memories without knowing exact storage keys. All fingerprint computation is client-side — the server never sees plaintext.',
697
+ inputSchema: {
698
+ type: 'object',
699
+ properties: {
700
+ query: {
701
+ type: 'string',
702
+ description: 'What to search for in your memories',
703
+ },
704
+ category: {
705
+ type: 'string',
706
+ enum: [
707
+ 'preference', 'fact', 'event', 'procedure', 'relationship',
708
+ 'observation', 'decision', 'goal', 'constraint', 'reference',
709
+ 'summary', 'handoff', 'pattern', 'feedback', 'unknown',
710
+ ],
711
+ description: 'Optional cognitive category filter',
712
+ },
713
+ limit: {
714
+ type: 'number',
715
+ description: 'Maximum number of results (default: 10, max: 50)',
716
+ },
717
+ },
718
+ required: ['query'],
719
+ },
720
+ },
721
+
722
+ // =========================================================================
723
+ // Ephemeral Context Tools
724
+ // =========================================================================
725
+ {
726
+ name: 'xache_ephemeral_create_session',
727
+ description:
728
+ 'Create a new ephemeral working memory session. Returns a session key for storing temporary data in slots (conversation, facts, tasks, cache, scratch, handoff). Sessions auto-expire after TTL.',
729
+ inputSchema: {
730
+ type: 'object',
731
+ properties: {
732
+ ttlSeconds: {
733
+ type: 'number',
734
+ description: 'Session time-to-live in seconds (default: 3600)',
735
+ },
736
+ maxWindows: {
737
+ type: 'number',
738
+ description: 'Maximum renewal windows (default: 5)',
739
+ },
740
+ },
741
+ required: [],
742
+ },
743
+ },
744
+ {
745
+ name: 'xache_ephemeral_write_slot',
746
+ description:
747
+ 'Write data to an ephemeral session slot. Use slots to organize working memory: conversation (dialog history), facts (extracted facts), tasks (current tasks), cache (temporary data), scratch (working notes), handoff (data for next agent).',
748
+ inputSchema: {
749
+ type: 'object',
750
+ properties: {
751
+ sessionKey: {
752
+ type: 'string',
753
+ description: 'The ephemeral session key',
754
+ },
755
+ slot: {
756
+ type: 'string',
757
+ enum: ['conversation', 'facts', 'tasks', 'cache', 'scratch', 'handoff'],
758
+ description: 'Slot name',
759
+ },
760
+ data: {
761
+ type: 'object',
762
+ description: 'Data to write to the slot',
763
+ },
764
+ },
765
+ required: ['sessionKey', 'slot', 'data'],
766
+ },
767
+ },
768
+ {
769
+ name: 'xache_ephemeral_read_slot',
770
+ description:
771
+ 'Read data from an ephemeral session slot.',
772
+ inputSchema: {
773
+ type: 'object',
774
+ properties: {
775
+ sessionKey: {
776
+ type: 'string',
777
+ description: 'The ephemeral session key',
778
+ },
779
+ slot: {
780
+ type: 'string',
781
+ enum: ['conversation', 'facts', 'tasks', 'cache', 'scratch', 'handoff'],
782
+ description: 'Slot name',
783
+ },
784
+ },
785
+ required: ['sessionKey', 'slot'],
786
+ },
787
+ },
788
+ {
789
+ name: 'xache_ephemeral_promote',
790
+ description:
791
+ 'Promote an ephemeral session to persistent memory. Extracts valuable data from all slots and stores as permanent memories with cryptographic receipts.',
792
+ inputSchema: {
793
+ type: 'object',
794
+ properties: {
795
+ sessionKey: {
796
+ type: 'string',
797
+ description: 'The ephemeral session key to promote',
798
+ },
799
+ },
800
+ required: ['sessionKey'],
801
+ },
802
+ },
803
+ {
804
+ name: 'xache_ephemeral_status',
805
+ description:
806
+ 'Get the status and details of an ephemeral session. Shows active slots, total size, TTL, window count, and cumulative cost.',
807
+ inputSchema: {
808
+ type: 'object',
809
+ properties: {
810
+ sessionKey: {
811
+ type: 'string',
812
+ description: 'The ephemeral session key',
813
+ },
814
+ },
815
+ required: ['sessionKey'],
816
+ },
817
+ },
689
818
  ];
690
819
 
691
820
  // =============================================================================
@@ -1429,6 +1558,117 @@ async function handleGraphEntityHistory(
1429
1558
  return output;
1430
1559
  }
1431
1560
 
1561
+ // =============================================================================
1562
+ // Memory Probe Handler
1563
+ // =============================================================================
1564
+
1565
+ async function handleMemoryProbe(
1566
+ client: XacheClient,
1567
+ args: { query: string; category?: string; limit?: number }
1568
+ ): Promise<string> {
1569
+ const result = await client.memory.probe({
1570
+ query: args.query,
1571
+ category: args.category as any,
1572
+ limit: args.limit || 10,
1573
+ });
1574
+
1575
+ const matches = result.matches || [];
1576
+
1577
+ if (matches.length === 0) {
1578
+ return 'No matching memories found for this query.';
1579
+ }
1580
+
1581
+ let output = `Found ${matches.length} matching memories (total: ${result.total}):\n`;
1582
+
1583
+ matches.forEach((match: any, i: number) => {
1584
+ const data = typeof match.data === 'string'
1585
+ ? match.data.slice(0, 300)
1586
+ : JSON.stringify(match.data).slice(0, 300);
1587
+ output += `\n${i + 1}. [${match.category}] ${data}`;
1588
+ output += ` (key: ${match.storageKey})`;
1589
+ });
1590
+
1591
+ return output;
1592
+ }
1593
+
1594
+ // =============================================================================
1595
+ // Ephemeral Context Handlers
1596
+ // =============================================================================
1597
+
1598
+ async function handleEphemeralCreateSession(
1599
+ client: XacheClient,
1600
+ args: { ttlSeconds?: number; maxWindows?: number }
1601
+ ): Promise<string> {
1602
+ const session = await client.ephemeral.createSession({
1603
+ ttlSeconds: args.ttlSeconds,
1604
+ maxWindows: args.maxWindows,
1605
+ });
1606
+
1607
+ return [
1608
+ `Created ephemeral session.`,
1609
+ `Session Key: ${session.sessionKey}`,
1610
+ `Status: ${session.status}`,
1611
+ `TTL: ${session.ttlSeconds}s`,
1612
+ `Window: ${session.window}/${session.maxWindows}`,
1613
+ `Expires: ${session.expiresAt}`,
1614
+ ].join('\n');
1615
+ }
1616
+
1617
+ async function handleEphemeralWriteSlot(
1618
+ client: XacheClient,
1619
+ args: { sessionKey: string; slot: string; data: Record<string, unknown> }
1620
+ ): Promise<string> {
1621
+ await client.ephemeral.writeSlot(args.sessionKey, args.slot as any, args.data);
1622
+ return `Wrote data to slot "${args.slot}" in session ${args.sessionKey.substring(0, 12)}...`;
1623
+ }
1624
+
1625
+ async function handleEphemeralReadSlot(
1626
+ client: XacheClient,
1627
+ args: { sessionKey: string; slot: string }
1628
+ ): Promise<string> {
1629
+ const data = await client.ephemeral.readSlot(args.sessionKey, args.slot as any);
1630
+ return `Slot "${args.slot}" data:\n${JSON.stringify(data, null, 2)}`;
1631
+ }
1632
+
1633
+ async function handleEphemeralPromote(
1634
+ client: XacheClient,
1635
+ args: { sessionKey: string }
1636
+ ): Promise<string> {
1637
+ const result = await client.ephemeral.promoteSession(args.sessionKey);
1638
+
1639
+ let output = `Promoted session ${args.sessionKey.substring(0, 12)}...\n`;
1640
+ output += `Memories created: ${result.memoriesCreated}\n`;
1641
+ if (result.memoryIds.length > 0) {
1642
+ output += `Memory IDs: ${result.memoryIds.join(', ')}\n`;
1643
+ }
1644
+ if (result.receiptId) {
1645
+ output += `Receipt: ${result.receiptId}`;
1646
+ }
1647
+ return output;
1648
+ }
1649
+
1650
+ async function handleEphemeralStatus(
1651
+ client: XacheClient,
1652
+ args: { sessionKey: string }
1653
+ ): Promise<string> {
1654
+ const session = await client.ephemeral.getSession(args.sessionKey);
1655
+
1656
+ if (!session) {
1657
+ return `Session ${args.sessionKey.substring(0, 12)}... not found.`;
1658
+ }
1659
+
1660
+ return [
1661
+ `Session: ${session.sessionKey.substring(0, 12)}...`,
1662
+ `Status: ${session.status}`,
1663
+ `Window: ${session.window}/${session.maxWindows}`,
1664
+ `TTL: ${session.ttlSeconds}s`,
1665
+ `Expires: ${session.expiresAt}`,
1666
+ `Active Slots: ${session.activeSlots.length > 0 ? session.activeSlots.join(', ') : 'none'}`,
1667
+ `Total Size: ${session.totalSize} bytes`,
1668
+ `Cumulative Cost: $${session.cumulativeCost.toFixed(4)}`,
1669
+ ].join('\n');
1670
+ }
1671
+
1432
1672
  // =============================================================================
1433
1673
  // Server Setup
1434
1674
  // =============================================================================
@@ -1523,6 +1763,24 @@ async function main(): Promise<void> {
1523
1763
  case 'xache_graph_entity_history':
1524
1764
  result = await handleGraphEntityHistory(client, args as any);
1525
1765
  break;
1766
+ case 'xache_memory_probe':
1767
+ result = await handleMemoryProbe(client, args as any);
1768
+ break;
1769
+ case 'xache_ephemeral_create_session':
1770
+ result = await handleEphemeralCreateSession(client, args as any);
1771
+ break;
1772
+ case 'xache_ephemeral_write_slot':
1773
+ result = await handleEphemeralWriteSlot(client, args as any);
1774
+ break;
1775
+ case 'xache_ephemeral_read_slot':
1776
+ result = await handleEphemeralReadSlot(client, args as any);
1777
+ break;
1778
+ case 'xache_ephemeral_promote':
1779
+ result = await handleEphemeralPromote(client, args as any);
1780
+ break;
1781
+ case 'xache_ephemeral_status':
1782
+ result = await handleEphemeralStatus(client, args as any);
1783
+ break;
1526
1784
  default:
1527
1785
  throw new Error(`Unknown tool: ${name}`);
1528
1786
  }