@xache/mcp-server 0.6.0 → 0.7.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 +125 -144
- package/package.json +2 -2
- package/src/index.ts +190 -0
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-
|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
- `
|
|
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
|
-
|
|
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 (
|
|
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
|
|
129
|
+
- `context` (optional): Context/category
|
|
126
130
|
- `tags` (optional): Tags for filtering
|
|
127
|
-
- `tier` (optional):
|
|
131
|
+
- `tier` (optional): "hot", "warm", or "cold" (default: warm)
|
|
128
132
|
|
|
129
133
|
#### `xache_memory_retrieve`
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
###
|
|
142
|
+
### Ephemeral Context
|
|
145
143
|
|
|
146
|
-
|
|
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
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
-
|
|
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
|
-
|
|
155
|
-
|
|
156
|
-
- `
|
|
157
|
-
- `
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
#### `
|
|
166
|
+
#### `xache_ephemeral_status`
|
|
167
|
+
Get ephemeral session status and details.
|
|
168
|
+
- `sessionKey` (required): The session key
|
|
169
169
|
|
|
170
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
- `
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
230
|
-
- `summary` (optional):
|
|
218
|
+
- `type` (required): Entity type
|
|
219
|
+
- `summary` (optional): Description
|
|
231
220
|
|
|
232
221
|
#### `xache_graph_add_relationship`
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
- `
|
|
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
|
-
|
|
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
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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.
|
|
263
|
+
The private key is used **client-side only** for signing. It is never transmitted to Xache servers.
|
|
280
264
|
|
|
281
265
|
```
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xache/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.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": "
|
|
35
|
+
"@xache/sdk": "workspace:*",
|
|
36
36
|
"zod": "^3.22.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -686,6 +686,103 @@ const TOOLS: Tool[] = [
|
|
|
686
686
|
required: ['name'],
|
|
687
687
|
},
|
|
688
688
|
},
|
|
689
|
+
|
|
690
|
+
// =========================================================================
|
|
691
|
+
// Ephemeral Context Tools
|
|
692
|
+
// =========================================================================
|
|
693
|
+
{
|
|
694
|
+
name: 'xache_ephemeral_create_session',
|
|
695
|
+
description:
|
|
696
|
+
'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.',
|
|
697
|
+
inputSchema: {
|
|
698
|
+
type: 'object',
|
|
699
|
+
properties: {
|
|
700
|
+
ttlSeconds: {
|
|
701
|
+
type: 'number',
|
|
702
|
+
description: 'Session time-to-live in seconds (default: 3600)',
|
|
703
|
+
},
|
|
704
|
+
maxWindows: {
|
|
705
|
+
type: 'number',
|
|
706
|
+
description: 'Maximum renewal windows (default: 5)',
|
|
707
|
+
},
|
|
708
|
+
},
|
|
709
|
+
required: [],
|
|
710
|
+
},
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
name: 'xache_ephemeral_write_slot',
|
|
714
|
+
description:
|
|
715
|
+
'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).',
|
|
716
|
+
inputSchema: {
|
|
717
|
+
type: 'object',
|
|
718
|
+
properties: {
|
|
719
|
+
sessionKey: {
|
|
720
|
+
type: 'string',
|
|
721
|
+
description: 'The ephemeral session key',
|
|
722
|
+
},
|
|
723
|
+
slot: {
|
|
724
|
+
type: 'string',
|
|
725
|
+
enum: ['conversation', 'facts', 'tasks', 'cache', 'scratch', 'handoff'],
|
|
726
|
+
description: 'Slot name',
|
|
727
|
+
},
|
|
728
|
+
data: {
|
|
729
|
+
type: 'object',
|
|
730
|
+
description: 'Data to write to the slot',
|
|
731
|
+
},
|
|
732
|
+
},
|
|
733
|
+
required: ['sessionKey', 'slot', 'data'],
|
|
734
|
+
},
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
name: 'xache_ephemeral_read_slot',
|
|
738
|
+
description:
|
|
739
|
+
'Read data from an ephemeral session slot.',
|
|
740
|
+
inputSchema: {
|
|
741
|
+
type: 'object',
|
|
742
|
+
properties: {
|
|
743
|
+
sessionKey: {
|
|
744
|
+
type: 'string',
|
|
745
|
+
description: 'The ephemeral session key',
|
|
746
|
+
},
|
|
747
|
+
slot: {
|
|
748
|
+
type: 'string',
|
|
749
|
+
enum: ['conversation', 'facts', 'tasks', 'cache', 'scratch', 'handoff'],
|
|
750
|
+
description: 'Slot name',
|
|
751
|
+
},
|
|
752
|
+
},
|
|
753
|
+
required: ['sessionKey', 'slot'],
|
|
754
|
+
},
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
name: 'xache_ephemeral_promote',
|
|
758
|
+
description:
|
|
759
|
+
'Promote an ephemeral session to persistent memory. Extracts valuable data from all slots and stores as permanent memories with cryptographic receipts.',
|
|
760
|
+
inputSchema: {
|
|
761
|
+
type: 'object',
|
|
762
|
+
properties: {
|
|
763
|
+
sessionKey: {
|
|
764
|
+
type: 'string',
|
|
765
|
+
description: 'The ephemeral session key to promote',
|
|
766
|
+
},
|
|
767
|
+
},
|
|
768
|
+
required: ['sessionKey'],
|
|
769
|
+
},
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
name: 'xache_ephemeral_status',
|
|
773
|
+
description:
|
|
774
|
+
'Get the status and details of an ephemeral session. Shows active slots, total size, TTL, window count, and cumulative cost.',
|
|
775
|
+
inputSchema: {
|
|
776
|
+
type: 'object',
|
|
777
|
+
properties: {
|
|
778
|
+
sessionKey: {
|
|
779
|
+
type: 'string',
|
|
780
|
+
description: 'The ephemeral session key',
|
|
781
|
+
},
|
|
782
|
+
},
|
|
783
|
+
required: ['sessionKey'],
|
|
784
|
+
},
|
|
785
|
+
},
|
|
689
786
|
];
|
|
690
787
|
|
|
691
788
|
// =============================================================================
|
|
@@ -1429,6 +1526,84 @@ async function handleGraphEntityHistory(
|
|
|
1429
1526
|
return output;
|
|
1430
1527
|
}
|
|
1431
1528
|
|
|
1529
|
+
// =============================================================================
|
|
1530
|
+
// Ephemeral Context Handlers
|
|
1531
|
+
// =============================================================================
|
|
1532
|
+
|
|
1533
|
+
async function handleEphemeralCreateSession(
|
|
1534
|
+
client: XacheClient,
|
|
1535
|
+
args: { ttlSeconds?: number; maxWindows?: number }
|
|
1536
|
+
): Promise<string> {
|
|
1537
|
+
const session = await client.ephemeral.createSession({
|
|
1538
|
+
ttlSeconds: args.ttlSeconds,
|
|
1539
|
+
maxWindows: args.maxWindows,
|
|
1540
|
+
});
|
|
1541
|
+
|
|
1542
|
+
return [
|
|
1543
|
+
`Created ephemeral session.`,
|
|
1544
|
+
`Session Key: ${session.sessionKey}`,
|
|
1545
|
+
`Status: ${session.status}`,
|
|
1546
|
+
`TTL: ${session.ttlSeconds}s`,
|
|
1547
|
+
`Window: ${session.window}/${session.maxWindows}`,
|
|
1548
|
+
`Expires: ${session.expiresAt}`,
|
|
1549
|
+
].join('\n');
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
async function handleEphemeralWriteSlot(
|
|
1553
|
+
client: XacheClient,
|
|
1554
|
+
args: { sessionKey: string; slot: string; data: Record<string, unknown> }
|
|
1555
|
+
): Promise<string> {
|
|
1556
|
+
await client.ephemeral.writeSlot(args.sessionKey, args.slot as any, args.data);
|
|
1557
|
+
return `Wrote data to slot "${args.slot}" in session ${args.sessionKey.substring(0, 12)}...`;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
async function handleEphemeralReadSlot(
|
|
1561
|
+
client: XacheClient,
|
|
1562
|
+
args: { sessionKey: string; slot: string }
|
|
1563
|
+
): Promise<string> {
|
|
1564
|
+
const data = await client.ephemeral.readSlot(args.sessionKey, args.slot as any);
|
|
1565
|
+
return `Slot "${args.slot}" data:\n${JSON.stringify(data, null, 2)}`;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
async function handleEphemeralPromote(
|
|
1569
|
+
client: XacheClient,
|
|
1570
|
+
args: { sessionKey: string }
|
|
1571
|
+
): Promise<string> {
|
|
1572
|
+
const result = await client.ephemeral.promoteSession(args.sessionKey);
|
|
1573
|
+
|
|
1574
|
+
let output = `Promoted session ${args.sessionKey.substring(0, 12)}...\n`;
|
|
1575
|
+
output += `Memories created: ${result.memoriesCreated}\n`;
|
|
1576
|
+
if (result.memoryIds.length > 0) {
|
|
1577
|
+
output += `Memory IDs: ${result.memoryIds.join(', ')}\n`;
|
|
1578
|
+
}
|
|
1579
|
+
if (result.receiptId) {
|
|
1580
|
+
output += `Receipt: ${result.receiptId}`;
|
|
1581
|
+
}
|
|
1582
|
+
return output;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
async function handleEphemeralStatus(
|
|
1586
|
+
client: XacheClient,
|
|
1587
|
+
args: { sessionKey: string }
|
|
1588
|
+
): Promise<string> {
|
|
1589
|
+
const session = await client.ephemeral.getSession(args.sessionKey);
|
|
1590
|
+
|
|
1591
|
+
if (!session) {
|
|
1592
|
+
return `Session ${args.sessionKey.substring(0, 12)}... not found.`;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
return [
|
|
1596
|
+
`Session: ${session.sessionKey.substring(0, 12)}...`,
|
|
1597
|
+
`Status: ${session.status}`,
|
|
1598
|
+
`Window: ${session.window}/${session.maxWindows}`,
|
|
1599
|
+
`TTL: ${session.ttlSeconds}s`,
|
|
1600
|
+
`Expires: ${session.expiresAt}`,
|
|
1601
|
+
`Active Slots: ${session.activeSlots.length > 0 ? session.activeSlots.join(', ') : 'none'}`,
|
|
1602
|
+
`Total Size: ${session.totalSize} bytes`,
|
|
1603
|
+
`Cumulative Cost: $${session.cumulativeCost.toFixed(4)}`,
|
|
1604
|
+
].join('\n');
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1432
1607
|
// =============================================================================
|
|
1433
1608
|
// Server Setup
|
|
1434
1609
|
// =============================================================================
|
|
@@ -1523,6 +1698,21 @@ async function main(): Promise<void> {
|
|
|
1523
1698
|
case 'xache_graph_entity_history':
|
|
1524
1699
|
result = await handleGraphEntityHistory(client, args as any);
|
|
1525
1700
|
break;
|
|
1701
|
+
case 'xache_ephemeral_create_session':
|
|
1702
|
+
result = await handleEphemeralCreateSession(client, args as any);
|
|
1703
|
+
break;
|
|
1704
|
+
case 'xache_ephemeral_write_slot':
|
|
1705
|
+
result = await handleEphemeralWriteSlot(client, args as any);
|
|
1706
|
+
break;
|
|
1707
|
+
case 'xache_ephemeral_read_slot':
|
|
1708
|
+
result = await handleEphemeralReadSlot(client, args as any);
|
|
1709
|
+
break;
|
|
1710
|
+
case 'xache_ephemeral_promote':
|
|
1711
|
+
result = await handleEphemeralPromote(client, args as any);
|
|
1712
|
+
break;
|
|
1713
|
+
case 'xache_ephemeral_status':
|
|
1714
|
+
result = await handleEphemeralStatus(client, args as any);
|
|
1715
|
+
break;
|
|
1526
1716
|
default:
|
|
1527
1717
|
throw new Error(`Unknown tool: ${name}`);
|
|
1528
1718
|
}
|