@memoryrelay/mcp-server 0.1.7 ā 0.1.9
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 +119 -7
- package/dist/index.js +178 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
- **Persistent Memory**: Store and retrieve memories across conversations
|
|
12
12
|
- **Semantic Search**: Find relevant memories using natural language queries
|
|
13
13
|
- **Entity Management**: Create and link entities (people, projects, concepts) for knowledge graphs
|
|
14
|
+
- **MCP Resources**: Expose memories as readable resources for richer context injection
|
|
15
|
+
- **MCP Prompts**: Built-in prompt templates for common memory workflows
|
|
14
16
|
- **Security Hardened**: API key masking, input validation, sanitized errors
|
|
15
17
|
- **MCP Compliant**: Works with Claude Desktop, OpenClaw, and any MCP client
|
|
16
18
|
- **Fully Tested**: 102+ test cases covering all functionality
|
|
@@ -68,9 +70,9 @@ Edit `~/.openclaw/openclaw.json`:
|
|
|
68
70
|
}
|
|
69
71
|
```
|
|
70
72
|
|
|
71
|
-
#### For Claude Desktop
|
|
73
|
+
#### For Claude Desktop (macOS)
|
|
72
74
|
|
|
73
|
-
Edit `~/Library/Application Support/Claude/claude_desktop_config.json
|
|
75
|
+
Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
74
76
|
|
|
75
77
|
```json
|
|
76
78
|
{
|
|
@@ -86,6 +88,34 @@ Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) o
|
|
|
86
88
|
}
|
|
87
89
|
```
|
|
88
90
|
|
|
91
|
+
#### For Claude Desktop (Windows)
|
|
92
|
+
|
|
93
|
+
On Windows, `npx` with scoped packages can fail to resolve the bin entry. Install globally first, then use `node` directly.
|
|
94
|
+
|
|
95
|
+
**Step 1:** Install the package globally:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npm install -g @memoryrelay/mcp-server
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Step 2:** Edit `%APPDATA%\Claude\claude_desktop_config.json`:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"mcpServers": {
|
|
106
|
+
"memoryrelay": {
|
|
107
|
+
"command": "node",
|
|
108
|
+
"args": ["%APPDATA%\\npm\\node_modules\\@memoryrelay\\mcp-server\\dist\\index.js"],
|
|
109
|
+
"env": {
|
|
110
|
+
"MEMORYRELAY_API_KEY": "mem_prod_xxxxx"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
> **Note:** Replace `%APPDATA%` with your actual path (e.g., `C:\\Users\\YourName\\AppData\\Roaming`). You can find it by running `echo %APPDATA%` in Command Prompt.
|
|
118
|
+
|
|
89
119
|
### 3. Restart Your Client
|
|
90
120
|
|
|
91
121
|
Restart OpenClaw or Claude Desktop to load the MCP server.
|
|
@@ -318,6 +348,53 @@ Check API connectivity and server health.
|
|
|
318
348
|
|
|
319
349
|
---
|
|
320
350
|
|
|
351
|
+
## š Resources
|
|
352
|
+
|
|
353
|
+
The server exposes memories as MCP resources, allowing clients to read memory data directly.
|
|
354
|
+
|
|
355
|
+
### Static Resources
|
|
356
|
+
|
|
357
|
+
#### `memory:///recent`
|
|
358
|
+
|
|
359
|
+
Returns the 20 most recent memories as a JSON resource.
|
|
360
|
+
|
|
361
|
+
### Resource Templates
|
|
362
|
+
|
|
363
|
+
#### `memory:///{id}`
|
|
364
|
+
|
|
365
|
+
Retrieve a specific memory by its UUID. Replace `{id}` with a valid memory UUID.
|
|
366
|
+
|
|
367
|
+
**Example URI:** `memory:///550e8400-e29b-41d4-a716-446655440000`
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## š¬ Prompts
|
|
372
|
+
|
|
373
|
+
The server provides prompt templates that guide the AI through common memory workflows.
|
|
374
|
+
|
|
375
|
+
### `store_memory`
|
|
376
|
+
|
|
377
|
+
Store information as a persistent memory with appropriate metadata.
|
|
378
|
+
|
|
379
|
+
**Arguments:**
|
|
380
|
+
- `information` (string, required) - The information to remember
|
|
381
|
+
- `category` (string, optional) - Category tag (e.g., preference, fact, instruction)
|
|
382
|
+
|
|
383
|
+
### `recall_memories`
|
|
384
|
+
|
|
385
|
+
Search for and recall relevant memories about a topic.
|
|
386
|
+
|
|
387
|
+
**Arguments:**
|
|
388
|
+
- `topic` (string, required) - The topic or question to search memories for
|
|
389
|
+
|
|
390
|
+
### `summarize_memories`
|
|
391
|
+
|
|
392
|
+
List and summarize all recent memories for context.
|
|
393
|
+
|
|
394
|
+
**Arguments:** None
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
321
398
|
## š Security
|
|
322
399
|
|
|
323
400
|
This MCP server is designed with security best practices:
|
|
@@ -358,7 +435,7 @@ For detailed security information, see [SECURITY.md](./docs/SECURITY.md).
|
|
|
358
435
|
```bash
|
|
359
436
|
# Clone the repository
|
|
360
437
|
git clone https://github.com/memoryrelay/mcp-server.git
|
|
361
|
-
cd
|
|
438
|
+
cd mcp-server
|
|
362
439
|
|
|
363
440
|
# Install dependencies
|
|
364
441
|
npm install
|
|
@@ -395,7 +472,7 @@ npm run type-check
|
|
|
395
472
|
### Project Structure
|
|
396
473
|
|
|
397
474
|
```
|
|
398
|
-
mcp/
|
|
475
|
+
mcp-server/
|
|
399
476
|
āāā src/
|
|
400
477
|
ā āāā index.ts # Entry point
|
|
401
478
|
ā āāā server.ts # MCP server implementation
|
|
@@ -413,7 +490,10 @@ mcp/
|
|
|
413
490
|
ā āāā SECURITY.md # Security documentation
|
|
414
491
|
āāā package.json
|
|
415
492
|
āāā tsconfig.json
|
|
493
|
+
āāā tsup.config.ts
|
|
416
494
|
āāā vitest.config.ts
|
|
495
|
+
āāā CHANGELOG.md
|
|
496
|
+
āāā LICENSE
|
|
417
497
|
āāā README.md
|
|
418
498
|
```
|
|
419
499
|
|
|
@@ -458,6 +538,21 @@ mcp/
|
|
|
458
538
|
```
|
|
459
539
|
4. Check firewall/proxy settings
|
|
460
540
|
|
|
541
|
+
### Windows: `npx` Fails with Scoped Package
|
|
542
|
+
|
|
543
|
+
**Problem:** `'memoryrelay-mcp-server' is not recognized` when using `npx` on Windows
|
|
544
|
+
|
|
545
|
+
**Solutions:**
|
|
546
|
+
1. Install globally instead of using `npx`:
|
|
547
|
+
```bash
|
|
548
|
+
npm install -g @memoryrelay/mcp-server
|
|
549
|
+
```
|
|
550
|
+
2. Use `node` directly in your Claude Desktop config (see [Windows setup](#for-claude-desktop-windows) above)
|
|
551
|
+
3. Verify the global install path:
|
|
552
|
+
```bash
|
|
553
|
+
npm root -g
|
|
554
|
+
```
|
|
555
|
+
|
|
461
556
|
### Tools Not Showing Up
|
|
462
557
|
|
|
463
558
|
**Problem:** MCP tools not available in client
|
|
@@ -508,7 +603,7 @@ Debug logs go to stderr and include:
|
|
|
508
603
|
|
|
509
604
|
### Getting Help
|
|
510
605
|
|
|
511
|
-
- š [Full Documentation](https://github.com/memoryrelay/mcp-server
|
|
606
|
+
- š [Full Documentation](https://github.com/memoryrelay/mcp-server#readme)
|
|
512
607
|
- š [Report Issues](https://github.com/memoryrelay/mcp-server/issues)
|
|
513
608
|
- š¬ [Discussions](https://github.com/memoryrelay/mcp-server/discussions)
|
|
514
609
|
- š [Security Policy](./docs/SECURITY.md)
|
|
@@ -546,7 +641,7 @@ npm run test:security # Security tests only
|
|
|
546
641
|
|
|
547
642
|
## š License
|
|
548
643
|
|
|
549
|
-
MIT License - see [LICENSE](
|
|
644
|
+
MIT License - see [LICENSE](./LICENSE) for details
|
|
550
645
|
|
|
551
646
|
---
|
|
552
647
|
|
|
@@ -563,12 +658,29 @@ MIT License - see [LICENSE](../LICENSE) for details
|
|
|
563
658
|
|
|
564
659
|
## š Contributing
|
|
565
660
|
|
|
566
|
-
Contributions welcome! Please
|
|
661
|
+
Contributions welcome! Please open an issue or pull request on [GitHub](https://github.com/memoryrelay/mcp-server).
|
|
567
662
|
|
|
568
663
|
---
|
|
569
664
|
|
|
570
665
|
## š Changelog
|
|
571
666
|
|
|
667
|
+
### v0.1.9 (2026-02-15)
|
|
668
|
+
|
|
669
|
+
- Add Windows-specific Claude Desktop setup instructions (global install + `node` command)
|
|
670
|
+
- Add Windows `npx` scoped package troubleshooting guide
|
|
671
|
+
- Fix project structure diagram, broken links, and missing files in README
|
|
672
|
+
|
|
673
|
+
### v0.1.8 (2026-02-15)
|
|
674
|
+
|
|
675
|
+
- Add MCP resources: `memory:///recent` and `memory:///{id}` for direct memory access
|
|
676
|
+
- Add MCP prompts: `store_memory`, `recall_memories`, `summarize_memories` templates
|
|
677
|
+
- Fix `npx @memoryrelay/mcp-server` execution for scoped packages
|
|
678
|
+
- Fix server version reporting (was hardcoded as 0.1.0)
|
|
679
|
+
- Implement `OPENCLAW_AGENT_NAME` environment variable support
|
|
680
|
+
- Fix error help URL to point to current repository
|
|
681
|
+
- Fix GitHub Release install commands to use scoped package name
|
|
682
|
+
- Fix TypeScript strict mode errors
|
|
683
|
+
|
|
572
684
|
### v0.1.0 (2026-02-12)
|
|
573
685
|
|
|
574
686
|
- Initial release
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,9 @@ function getAgentId(config) {
|
|
|
43
43
|
if (config.agentId) {
|
|
44
44
|
return config.agentId;
|
|
45
45
|
}
|
|
46
|
+
if (process.env.OPENCLAW_AGENT_NAME) {
|
|
47
|
+
return process.env.OPENCLAW_AGENT_NAME;
|
|
48
|
+
}
|
|
46
49
|
const hostname = process.env.HOSTNAME || "unknown";
|
|
47
50
|
return `agent-${hostname.slice(0, 8)}`;
|
|
48
51
|
}
|
|
@@ -123,7 +126,12 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
123
126
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
124
127
|
import {
|
|
125
128
|
CallToolRequestSchema,
|
|
126
|
-
ListToolsRequestSchema
|
|
129
|
+
ListToolsRequestSchema,
|
|
130
|
+
ListResourcesRequestSchema,
|
|
131
|
+
ListResourceTemplatesRequestSchema,
|
|
132
|
+
ReadResourceRequestSchema,
|
|
133
|
+
ListPromptsRequestSchema,
|
|
134
|
+
GetPromptRequestSchema
|
|
127
135
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
128
136
|
import { z as z2 } from "zod";
|
|
129
137
|
|
|
@@ -358,21 +366,25 @@ var MemoryRelayMCPServer = class {
|
|
|
358
366
|
this.server = new Server(
|
|
359
367
|
{
|
|
360
368
|
name: "@memoryrelay/mcp-server",
|
|
361
|
-
version: "0.1.
|
|
369
|
+
version: "0.1.9"
|
|
362
370
|
},
|
|
363
371
|
{
|
|
364
372
|
capabilities: {
|
|
365
|
-
tools: {}
|
|
373
|
+
tools: {},
|
|
374
|
+
resources: {},
|
|
375
|
+
prompts: {}
|
|
366
376
|
}
|
|
367
377
|
}
|
|
368
378
|
);
|
|
369
|
-
this.
|
|
379
|
+
this.setupToolHandlers();
|
|
380
|
+
this.setupResourceHandlers();
|
|
381
|
+
this.setupPromptHandlers();
|
|
370
382
|
this.logger.info("MCP server initialized");
|
|
371
383
|
}
|
|
372
384
|
/**
|
|
373
|
-
* Setup MCP
|
|
385
|
+
* Setup MCP tool handlers
|
|
374
386
|
*/
|
|
375
|
-
|
|
387
|
+
setupToolHandlers() {
|
|
376
388
|
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
377
389
|
tools: [
|
|
378
390
|
{
|
|
@@ -555,7 +567,7 @@ var MemoryRelayMCPServer = class {
|
|
|
555
567
|
]
|
|
556
568
|
}));
|
|
557
569
|
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
558
|
-
const { name, arguments: args } = request.params;
|
|
570
|
+
const { name, arguments: args = {} } = request.params;
|
|
559
571
|
this.logger.debug(`Tool called: ${name}`, args);
|
|
560
572
|
try {
|
|
561
573
|
switch (name) {
|
|
@@ -753,6 +765,164 @@ var MemoryRelayMCPServer = class {
|
|
|
753
765
|
}
|
|
754
766
|
});
|
|
755
767
|
}
|
|
768
|
+
/**
|
|
769
|
+
* Setup MCP resource handlers
|
|
770
|
+
*/
|
|
771
|
+
setupResourceHandlers() {
|
|
772
|
+
this.server.setRequestHandler(ListResourcesRequestSchema, async () => ({
|
|
773
|
+
resources: [
|
|
774
|
+
{
|
|
775
|
+
uri: "memory:///recent",
|
|
776
|
+
name: "Recent Memories",
|
|
777
|
+
description: "The 20 most recent memories stored in MemoryRelay",
|
|
778
|
+
mimeType: "application/json"
|
|
779
|
+
}
|
|
780
|
+
]
|
|
781
|
+
}));
|
|
782
|
+
this.server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => ({
|
|
783
|
+
resourceTemplates: [
|
|
784
|
+
{
|
|
785
|
+
uriTemplate: "memory:///{id}",
|
|
786
|
+
name: "Memory by ID",
|
|
787
|
+
description: "Retrieve a specific memory by its UUID",
|
|
788
|
+
mimeType: "application/json"
|
|
789
|
+
}
|
|
790
|
+
]
|
|
791
|
+
}));
|
|
792
|
+
this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
793
|
+
const { uri } = request.params;
|
|
794
|
+
try {
|
|
795
|
+
if (uri === "memory:///recent") {
|
|
796
|
+
const response = await this.client.listMemories(20, 0);
|
|
797
|
+
return {
|
|
798
|
+
contents: [
|
|
799
|
+
{
|
|
800
|
+
uri,
|
|
801
|
+
mimeType: "application/json",
|
|
802
|
+
text: JSON.stringify(response, null, 2)
|
|
803
|
+
}
|
|
804
|
+
]
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
const match = uri.match(/^memory:\/\/\/([0-9a-f-]{36})$/);
|
|
808
|
+
if (match) {
|
|
809
|
+
const id = match[1];
|
|
810
|
+
validateUuid(id, "memory_id");
|
|
811
|
+
const memory = await this.client.getMemory(id);
|
|
812
|
+
return {
|
|
813
|
+
contents: [
|
|
814
|
+
{
|
|
815
|
+
uri,
|
|
816
|
+
mimeType: "application/json",
|
|
817
|
+
text: JSON.stringify(memory, null, 2)
|
|
818
|
+
}
|
|
819
|
+
]
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
throw new Error(`Unknown resource: ${uri}`);
|
|
823
|
+
} catch (error) {
|
|
824
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
825
|
+
this.logger.error(`Resource read failed: ${uri}`, { error: message });
|
|
826
|
+
throw error;
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Setup MCP prompt handlers
|
|
832
|
+
*/
|
|
833
|
+
setupPromptHandlers() {
|
|
834
|
+
this.server.setRequestHandler(ListPromptsRequestSchema, async () => ({
|
|
835
|
+
prompts: [
|
|
836
|
+
{
|
|
837
|
+
name: "store_memory",
|
|
838
|
+
description: "Store information as a persistent memory with appropriate metadata",
|
|
839
|
+
arguments: [
|
|
840
|
+
{
|
|
841
|
+
name: "information",
|
|
842
|
+
description: "The information to remember",
|
|
843
|
+
required: true
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
name: "category",
|
|
847
|
+
description: "Category for the memory (e.g., preference, fact, instruction, context)",
|
|
848
|
+
required: false
|
|
849
|
+
}
|
|
850
|
+
]
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
name: "recall_memories",
|
|
854
|
+
description: "Search for and recall relevant memories about a topic",
|
|
855
|
+
arguments: [
|
|
856
|
+
{
|
|
857
|
+
name: "topic",
|
|
858
|
+
description: "The topic or question to search memories for",
|
|
859
|
+
required: true
|
|
860
|
+
}
|
|
861
|
+
]
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
name: "summarize_memories",
|
|
865
|
+
description: "List and summarize all recent memories for context",
|
|
866
|
+
arguments: []
|
|
867
|
+
}
|
|
868
|
+
]
|
|
869
|
+
}));
|
|
870
|
+
this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
871
|
+
const { name, arguments: args } = request.params;
|
|
872
|
+
switch (name) {
|
|
873
|
+
case "store_memory": {
|
|
874
|
+
const information = args?.information ?? "";
|
|
875
|
+
const category = args?.category ?? "";
|
|
876
|
+
const metadataInstruction = category ? ` Attach metadata with category "${category}".` : " Attach appropriate metadata with a category tag.";
|
|
877
|
+
return {
|
|
878
|
+
messages: [
|
|
879
|
+
{
|
|
880
|
+
role: "user",
|
|
881
|
+
content: {
|
|
882
|
+
type: "text",
|
|
883
|
+
text: `Please store the following information as a persistent memory using the memory_store tool.${metadataInstruction}
|
|
884
|
+
|
|
885
|
+
Information to remember:
|
|
886
|
+
${information}`
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
]
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
case "recall_memories": {
|
|
893
|
+
const topic = args?.topic ?? "";
|
|
894
|
+
return {
|
|
895
|
+
messages: [
|
|
896
|
+
{
|
|
897
|
+
role: "user",
|
|
898
|
+
content: {
|
|
899
|
+
type: "text",
|
|
900
|
+
text: `Search my memories for information related to: "${topic}"
|
|
901
|
+
|
|
902
|
+
Use the memory_search tool to find relevant memories, then summarize what you found. If nothing relevant is found, let me know.`
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
]
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
case "summarize_memories": {
|
|
909
|
+
return {
|
|
910
|
+
messages: [
|
|
911
|
+
{
|
|
912
|
+
role: "user",
|
|
913
|
+
content: {
|
|
914
|
+
type: "text",
|
|
915
|
+
text: "List my recent memories using the memory_list tool and provide a brief summary of what has been remembered. Group them by topic or category if possible."
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
]
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
default:
|
|
922
|
+
throw new Error(`Unknown prompt: ${name}`);
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
}
|
|
756
926
|
/**
|
|
757
927
|
* Start the MCP server with STDIO transport
|
|
758
928
|
*/
|
|
@@ -792,7 +962,7 @@ async function main() {
|
|
|
792
962
|
logger2.error("Fatal error:", { message: error.message });
|
|
793
963
|
console.error("\n\u274C Failed to start MemoryRelay MCP server\n");
|
|
794
964
|
console.error(error.message);
|
|
795
|
-
console.error("\nFor help, see: https://github.com/
|
|
965
|
+
console.error("\nFor help, see: https://github.com/memoryrelay/mcp-server#troubleshooting\n");
|
|
796
966
|
} else {
|
|
797
967
|
logger2.error("Fatal error:", { error });
|
|
798
968
|
console.error("\n\u274C An unexpected error occurred\n");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config.ts","../src/logger.ts","../src/server.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["import { z } from 'zod';\n\n/**\n * Configuration schema with security validation\n */\nexport const configSchema = z.object({\n apiKey: z.string()\n .startsWith('mem_', { message: 'API key must start with \"mem_\"' })\n .min(20, { message: 'API key appears to be invalid (too short)' }),\n apiUrl: z.string()\n .url({ message: 'API URL must be a valid URL' })\n .default('https://api.memoryrelay.net'),\n agentId: z.string()\n .optional()\n .describe('Agent identifier - auto-detected if not provided'),\n timeout: z.number()\n .positive({ message: 'Timeout must be positive' })\n .default(30000),\n logLevel: z.enum(['debug', 'info', 'warn', 'error'])\n .default('info'),\n});\n\nexport type Config = z.infer<typeof configSchema>;\n\n/**\n * Load and validate configuration from environment variables\n */\nexport function loadConfig(): Config {\n try {\n const config = configSchema.parse({\n apiKey: process.env.MEMORYRELAY_API_KEY,\n apiUrl: process.env.MEMORYRELAY_API_URL,\n agentId: process.env.MEMORYRELAY_AGENT_ID,\n timeout: process.env.MEMORYRELAY_TIMEOUT \n ? parseInt(process.env.MEMORYRELAY_TIMEOUT, 10) \n : undefined,\n logLevel: process.env.MEMORYRELAY_LOG_LEVEL,\n });\n\n return config;\n } catch (error) {\n if (error instanceof z.ZodError) {\n const issues = error.issues.map(issue => \n ` - ${issue.path.join('.')}: ${issue.message}`\n ).join('\\n');\n \n throw new Error(\n `Configuration validation failed:\\n${issues}\\n\\n` +\n 'Please check your environment variables:\\n' +\n ' - MEMORYRELAY_API_KEY (required, starts with \"mem_\")\\n' +\n ' - MEMORYRELAY_API_URL (optional, default: https://api.memoryrelay.net)\\n' +\n ' - MEMORYRELAY_AGENT_ID (optional, auto-detected)\\n' +\n ' - MEMORYRELAY_TIMEOUT (optional, default: 30000)\\n' +\n ' - MEMORYRELAY_LOG_LEVEL (optional, default: info)'\n );\n }\n throw error;\n }\n}\n\n/**\n * Get or generate agent ID\n */\nexport function getAgentId(config: Config): string {\n if (config.agentId) {\n return config.agentId;\n }\n\n // Auto-generate from hostname\n const hostname = process.env.HOSTNAME || 'unknown';\n return `agent-${hostname.slice(0, 8)}`;\n}\n","/**\n * Security-hardened logger for MCP server\n * \n * - All output to stderr (stdout reserved for MCP protocol)\n * - Automatic masking of API keys (anything starting with \"mem_\")\n * - No internal paths in error messages\n */\n\ntype LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n};\n\nexport class Logger {\n private minLevel: number;\n\n constructor(level: LogLevel = 'info') {\n this.minLevel = LOG_LEVELS[level];\n }\n\n /**\n * Mask sensitive data in log messages\n * - API keys starting with \"mem_\" are masked\n * - Internal paths are sanitized\n */\n private sanitize(message: string): string {\n let sanitized = message;\n\n // Mask API keys (mem_xxx -> mem_****)\n sanitized = sanitized.replace(/mem_[a-zA-Z0-9_-]+/g, 'mem_****');\n\n // Remove internal paths (anything that looks like a file path)\n sanitized = sanitized.replace(/\\/[a-zA-Z0-9_\\-./]+\\.(ts|js|json)/g, '<file>');\n sanitized = sanitized.replace(/at\\s+[^\\s]+\\s+\\([^)]+\\)/g, 'at <location>');\n\n return sanitized;\n }\n\n /**\n * Format log message with timestamp and level\n */\n private format(level: LogLevel, message: string, data?: unknown): string {\n const timestamp = new Date().toISOString();\n const sanitizedMessage = this.sanitize(message);\n \n let output = `[${timestamp}] [${level.toUpperCase()}] ${sanitizedMessage}`;\n \n if (data !== undefined) {\n const sanitizedData = this.sanitize(JSON.stringify(data, null, 2));\n output += `\\n${sanitizedData}`;\n }\n \n return output;\n }\n\n debug(message: string, data?: unknown): void {\n if (this.minLevel <= LOG_LEVELS.debug) {\n console.error(this.format('debug', message, data));\n }\n }\n\n info(message: string, data?: unknown): void {\n if (this.minLevel <= LOG_LEVELS.info) {\n console.error(this.format('info', message, data));\n }\n }\n\n warn(message: string, data?: unknown): void {\n if (this.minLevel <= LOG_LEVELS.warn) {\n console.error(this.format('warn', message, data));\n }\n }\n\n error(message: string, data?: unknown): void {\n if (this.minLevel <= LOG_LEVELS.error) {\n console.error(this.format('error', message, data));\n }\n }\n}\n\n// Export singleton instance\nlet logger: Logger;\n\nexport function initLogger(level: LogLevel = 'info'): Logger {\n logger = new Logger(level);\n return logger;\n}\n\nexport function getLogger(): Logger {\n if (!logger) {\n logger = new Logger();\n }\n return logger;\n}\n","/**\n * MCP Server implementation for MemoryRelay\n */\n\nimport { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js';\nimport { z } from 'zod';\nimport { MemoryRelayClient } from './client.js';\nimport { getLogger } from './logger.js';\nimport type { ClientConfig } from './types.js';\n\n/**\n * HTML-encode string to prevent XSS\n */\nfunction sanitizeHtml(str: string): string {\n return str\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(/\\//g, '/');\n}\n\n/**\n * Validate UUID format\n */\nconst uuidSchema = z.string().uuid();\n\nfunction validateUuid(id: string, fieldName: string = 'id'): void {\n const result = uuidSchema.safeParse(id);\n if (!result.success) {\n throw new Error(`Invalid ${fieldName}: must be a valid UUID`);\n }\n}\n\nexport class MemoryRelayMCPServer {\n private server: Server;\n private client: MemoryRelayClient;\n private logger = getLogger();\n\n constructor(config: ClientConfig) {\n this.client = new MemoryRelayClient(config);\n \n this.server = new Server(\n {\n name: '@memoryrelay/mcp-server',\n version: '0.1.0',\n },\n {\n capabilities: {\n tools: {},\n },\n }\n );\n\n this.setupHandlers();\n this.logger.info('MCP server initialized');\n }\n\n /**\n * Setup MCP protocol handlers\n */\n private setupHandlers(): void {\n // List available tools\n this.server.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: [\n {\n name: 'memory_store',\n description: 'Store a new memory. Use this to save important information, facts, preferences, or context that should be remembered for future conversations.',\n inputSchema: {\n type: 'object',\n properties: {\n content: {\n type: 'string',\n description: 'The memory content to store. Be specific and include relevant context.',\n },\n metadata: {\n type: 'object',\n description: 'Optional key-value metadata to attach to the memory',\n additionalProperties: { type: 'string' },\n },\n },\n required: ['content'],\n },\n },\n {\n name: 'memory_search',\n description: 'Search memories using natural language. Returns the most relevant memories based on semantic similarity to the query.',\n inputSchema: {\n type: 'object',\n properties: {\n query: {\n type: 'string',\n description: 'Natural language search query',\n },\n limit: {\n type: 'number',\n description: 'Maximum number of results to return (1-50)',\n minimum: 1,\n maximum: 50,\n default: 10,\n },\n threshold: {\n type: 'number',\n description: 'Minimum similarity threshold (0-1)',\n minimum: 0,\n maximum: 1,\n default: 0.5,\n },\n },\n required: ['query'],\n },\n },\n {\n name: 'memory_list',\n description: 'List recent memories chronologically. Use to review what has been remembered.',\n inputSchema: {\n type: 'object',\n properties: {\n limit: {\n type: 'number',\n description: 'Number of memories to return (1-100)',\n minimum: 1,\n maximum: 100,\n default: 20,\n },\n offset: {\n type: 'number',\n description: 'Offset for pagination',\n minimum: 0,\n default: 0,\n },\n },\n },\n },\n {\n name: 'memory_get',\n description: 'Retrieve a specific memory by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n description: 'The memory ID (UUID) to retrieve',\n },\n },\n required: ['id'],\n },\n },\n {\n name: 'memory_update',\n description: 'Update the content of an existing memory. Use to correct or expand stored information.',\n inputSchema: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n description: 'The memory ID (UUID) to update',\n },\n content: {\n type: 'string',\n description: 'The new content to replace the existing memory',\n },\n metadata: {\n type: 'object',\n description: 'Updated metadata (replaces existing)',\n additionalProperties: { type: 'string' },\n },\n },\n required: ['id', 'content'],\n },\n },\n {\n name: 'memory_delete',\n description: 'Permanently delete a memory. Use sparingly - memories are valuable context.',\n inputSchema: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n description: 'The memory ID (UUID) to delete',\n },\n },\n required: ['id'],\n },\n },\n {\n name: 'entity_create',\n description: 'Create a named entity (person, place, organization, project, concept) for the knowledge graph. Entities help organize and connect memories.',\n inputSchema: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n minLength: 1,\n maxLength: 200,\n description: 'Entity name (1-200 characters)',\n },\n type: {\n type: 'string',\n enum: ['person', 'place', 'organization', 'project', 'concept', 'other'],\n description: 'Entity type classification',\n },\n metadata: {\n type: 'object',\n description: 'Optional key-value metadata',\n additionalProperties: { type: 'string' },\n },\n },\n required: ['name', 'type'],\n },\n },\n {\n name: 'entity_link',\n description: 'Link an entity to a memory to establish relationships in the knowledge graph.',\n inputSchema: {\n type: 'object',\n properties: {\n entity_id: {\n type: 'string',\n description: 'Entity UUID',\n },\n memory_id: {\n type: 'string',\n description: 'Memory UUID',\n },\n relationship: {\n type: 'string',\n description: 'Relationship type (e.g., \"mentioned_in\", \"created_by\", \"relates_to\")',\n default: 'mentioned_in',\n },\n },\n required: ['entity_id', 'memory_id'],\n },\n },\n {\n name: 'memory_health',\n description: 'Check API connectivity and health status.',\n inputSchema: {\n type: 'object',\n properties: {},\n },\n },\n ],\n }));\n\n // Handle tool calls\n this.server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n this.logger.debug(`Tool called: ${name}`, args);\n\n try {\n switch (name) {\n case 'memory_store': {\n const memory = await this.client.storeMemory(\n args.content as string,\n args.metadata as Record<string, string> | undefined\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(memory, null, 2),\n },\n ],\n };\n }\n\n case 'memory_search': {\n const results = await this.client.searchMemories(\n args.query as string,\n args.limit as number | undefined,\n args.threshold as number | undefined\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n { memories: results, total: results.length },\n null,\n 2\n ),\n },\n ],\n };\n }\n\n case 'memory_list': {\n const response = await this.client.listMemories(\n args.limit as number | undefined,\n args.offset as number | undefined\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(response, null, 2),\n },\n ],\n };\n }\n\n case 'memory_get': {\n const id = args.id as string;\n validateUuid(id, 'memory_id');\n \n const memory = await this.client.getMemory(id);\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(memory, null, 2),\n },\n ],\n };\n }\n\n case 'memory_update': {\n const id = args.id as string;\n validateUuid(id, 'memory_id');\n \n const memory = await this.client.updateMemory(\n id,\n args.content as string,\n args.metadata as Record<string, string> | undefined\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(memory, null, 2),\n },\n ],\n };\n }\n\n case 'memory_delete': {\n const id = args.id as string;\n validateUuid(id, 'memory_id');\n \n await this.client.deleteMemory(id);\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n { success: true, message: 'Memory deleted successfully' },\n null,\n 2\n ),\n },\n ],\n };\n }\n\n case 'entity_create': {\n // Validate input schema\n const entitySchema = z.object({\n name: z.string().min(1).max(200),\n type: z.enum(['person', 'place', 'organization', 'project', 'concept', 'other']),\n metadata: z.record(z.string()).optional(),\n });\n\n const validatedInput = entitySchema.parse(args);\n \n // Sanitize name to prevent XSS\n const sanitizedName = sanitizeHtml(validatedInput.name);\n \n const entity = await this.client.createEntity(\n sanitizedName,\n validatedInput.type,\n validatedInput.metadata\n );\n \n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(entity, null, 2),\n },\n ],\n };\n }\n\n case 'entity_link': {\n // Validate input schema\n const linkSchema = z.object({\n entity_id: z.string().uuid(),\n memory_id: z.string().uuid(),\n relationship: z.string().default('mentioned_in'),\n });\n\n const validatedInput = linkSchema.parse(args);\n \n await this.client.linkEntity(\n validatedInput.entity_id,\n validatedInput.memory_id,\n validatedInput.relationship\n );\n \n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n {\n success: true,\n message: 'Entity linked to memory successfully',\n entity_id: validatedInput.entity_id,\n memory_id: validatedInput.memory_id,\n relationship: validatedInput.relationship,\n },\n null,\n 2\n ),\n },\n ],\n };\n }\n\n case 'memory_health': {\n const health = await this.client.healthCheck();\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(health, null, 2),\n },\n ],\n };\n }\n\n default:\n throw new Error(`Unknown tool: ${name}`);\n }\n } catch (error) {\n let errorMessage = 'Unknown error';\n let errorDetails: unknown = undefined;\n\n if (error instanceof z.ZodError) {\n errorMessage = 'Validation error';\n errorDetails = error.errors;\n } else if (error instanceof Error) {\n errorMessage = error.message;\n }\n\n this.logger.error(`Tool execution failed: ${name}`, {\n error: errorMessage,\n details: errorDetails,\n });\n \n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n {\n error: 'Tool execution failed',\n message: errorMessage,\n details: errorDetails,\n },\n null,\n 2\n ),\n },\n ],\n isError: true,\n };\n }\n });\n }\n\n /**\n * Start the MCP server with STDIO transport\n */\n async start(): Promise<void> {\n const transport = new StdioServerTransport();\n await this.server.connect(transport);\n this.logger.info('MCP server started on STDIO');\n }\n}\n","/**\n * MemoryRelay API client with retry logic and error handling\n */\n\nimport type {\n Memory,\n Entity,\n SearchResult,\n ListResponse,\n ClientConfig,\n EntityType,\n} from './types.js';\nimport { getLogger } from './logger.js';\n\n// Retry configuration\nconst MAX_RETRIES = 3;\nconst INITIAL_DELAY_MS = 1000;\nconst MAX_CONTENT_SIZE = 50 * 1024; // 50KB\n\n/**\n * Exponential backoff retry wrapper\n */\nasync function withRetry<T>(\n fn: () => Promise<T>,\n retries: number = MAX_RETRIES\n): Promise<T> {\n let lastError: Error | undefined;\n \n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n \n // Don't retry on certain errors\n if (\n lastError.message.includes('401') ||\n lastError.message.includes('403') ||\n lastError.message.includes('404') ||\n lastError.message.includes('400')\n ) {\n throw lastError;\n }\n \n // On last attempt, throw the error\n if (attempt === retries) {\n throw lastError;\n }\n \n // Exponential backoff with jitter\n const delay = INITIAL_DELAY_MS * Math.pow(2, attempt);\n const jitter = Math.random() * 0.3 * delay;\n await new Promise(resolve => setTimeout(resolve, delay + jitter));\n }\n }\n \n throw lastError || new Error('Retry failed');\n}\n\n/**\n * Mask API key in error messages for security\n */\nfunction maskApiKey(message: string, apiKey: string): string {\n if (!apiKey) return message;\n const maskedKey = apiKey.substring(0, 8) + '***';\n return message.replace(new RegExp(apiKey, 'g'), maskedKey);\n}\n\nexport class MemoryRelayClient {\n private config: ClientConfig;\n private logger = getLogger();\n\n constructor(config: ClientConfig) {\n this.config = config;\n this.logger.info('MemoryRelay client initialized', {\n apiUrl: config.apiUrl,\n agentId: config.agentId,\n });\n }\n\n /**\n * Make authenticated HTTP request to MemoryRelay API with retry logic\n */\n private async request<T>(\n method: string,\n path: string,\n body?: unknown\n ): Promise<T> {\n return withRetry(async () => {\n const url = `${this.config.apiUrl}${path}`;\n \n this.logger.debug(`API request: ${method} ${path}`);\n\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.config.timeout);\n\n try {\n const response = await fetch(url, {\n method,\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.config.apiKey}`,\n 'User-Agent': '@memoryrelay/mcp-server',\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n if (!response.ok) {\n // Handle rate limiting with retry\n if (response.status === 429) {\n const retryAfter = response.headers.get('Retry-After');\n const waitMs = retryAfter ? parseInt(retryAfter) * 1000 : 5000;\n this.logger.warn(`Rate limited, waiting ${waitMs}ms`);\n await new Promise(resolve => setTimeout(resolve, waitMs));\n throw new Error(`Rate limited: 429 - Retry after ${waitMs}ms`);\n }\n\n const errorData = await response.json().catch(() => ({}));\n const errorMsg = `API request failed: ${response.status} ${response.statusText}` +\n (errorData.message ? ` - ${errorData.message}` : '');\n \n // Mask API key in error message\n throw new Error(maskApiKey(errorMsg, this.config.apiKey));\n }\n\n const data = await response.json();\n this.logger.debug(`API response: ${method} ${path}`, { status: response.status });\n \n return data as T;\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n throw new Error(`Request timeout after ${this.config.timeout}ms`);\n }\n // Mask API key in all error messages\n error.message = maskApiKey(error.message, this.config.apiKey);\n }\n throw error;\n } finally {\n clearTimeout(timeout);\n }\n });\n }\n\n /**\n * Validate content size\n */\n private validateContentSize(content: string): void {\n if (content.length > MAX_CONTENT_SIZE) {\n throw new Error(`Content exceeds maximum size of ${MAX_CONTENT_SIZE} bytes`);\n }\n }\n\n /**\n * Store a new memory\n */\n async storeMemory(content: string, metadata?: Record<string, string>): Promise<Memory> {\n this.validateContentSize(content);\n \n return this.request<Memory>('POST', '/v1/memories/memories', {\n content,\n metadata,\n agent_id: this.config.agentId,\n });\n }\n\n /**\n * Search memories using semantic search\n */\n async searchMemories(\n query: string,\n limit: number = 10,\n threshold: number = 0.5\n ): Promise<SearchResult[]> {\n this.validateContentSize(query);\n \n const response = await this.request<{ data: SearchResult[] }>(\n 'POST',\n '/v1/memories/memories/search',\n { query, limit, threshold, agent_id: this.config.agentId }\n );\n return response.data;\n }\n\n /**\n * List recent memories with pagination\n */\n async listMemories(limit: number = 20, offset: number = 0): Promise<ListResponse<Memory>> {\n return this.request<ListResponse<Memory>>(\n 'GET',\n `/v1/memories/memories?limit=${limit}&offset=${offset}`\n );\n }\n\n /**\n * Get a specific memory by ID\n */\n async getMemory(id: string): Promise<Memory> {\n return this.request<Memory>('GET', `/v1/memories/memories/${id}`);\n }\n\n /**\n * Update an existing memory\n */\n async updateMemory(\n id: string,\n content: string,\n metadata?: Record<string, string>\n ): Promise<Memory> {\n this.validateContentSize(content);\n \n return this.request<Memory>('PATCH', `/v1/memories/memories/${id}`, {\n content,\n metadata,\n });\n }\n\n /**\n * Delete a memory\n */\n async deleteMemory(id: string): Promise<void> {\n await this.request<void>('DELETE', `/v1/memories/memories/${id}`);\n }\n\n /**\n * Create a named entity\n */\n async createEntity(\n name: string,\n type: EntityType,\n metadata?: Record<string, string>\n ): Promise<Entity> {\n this.validateContentSize(name);\n \n return this.request<Entity>('POST', '/v1/entities', {\n name,\n type,\n metadata,\n });\n }\n\n /**\n * Link an entity to a memory\n */\n async linkEntity(\n entityId: string,\n memoryId: string,\n relationship: string = 'mentioned_in'\n ): Promise<void> {\n await this.request<void>('POST', '/v1/entities/links', {\n entity_id: entityId,\n memory_id: memoryId,\n relationship,\n });\n }\n\n /**\n * Get an entity by ID\n */\n async getEntity(id: string): Promise<Entity> {\n return this.request<Entity>('GET', `/v1/entities/${id}`);\n }\n\n /**\n * List entities with pagination\n */\n async listEntities(limit: number = 20, offset: number = 0): Promise<ListResponse<Entity>> {\n return this.request<ListResponse<Entity>>(\n 'GET',\n `/v1/entities?limit=${limit}&offset=${offset}`\n );\n }\n\n /**\n * Delete an entity\n */\n async deleteEntity(id: string): Promise<void> {\n await this.request<void>('DELETE', `/v1/entities/${id}`);\n }\n\n /**\n * Health check - verify API connectivity\n */\n async healthCheck(): Promise<{ status: string; message: string }> {\n try {\n // Simple GET request to check API is reachable\n await this.request<{ status: string }>('GET', '/v1/health');\n return {\n status: 'healthy',\n message: 'API connection successful',\n };\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error';\n return {\n status: 'unhealthy',\n message: `API connection failed: ${errorMsg}`,\n };\n }\n }\n}\n","#!/usr/bin/env node\n/**\n * MemoryRelay MCP Server - Entry Point\n * \n * Provides persistent memory storage for AI agents via Model Context Protocol\n */\n\nimport { loadConfig, getAgentId } from './config.js';\nimport { initLogger, getLogger } from './logger.js';\nimport { MemoryRelayMCPServer } from './server.js';\n\nasync function main() {\n try {\n // Load and validate configuration\n const config = loadConfig();\n \n // Initialize logger with configured level\n initLogger(config.logLevel);\n const logger = getLogger();\n\n logger.info('Starting MemoryRelay MCP server');\n\n // Get or generate agent ID\n const agentId = getAgentId(config);\n\n // Create and start MCP server\n const server = new MemoryRelayMCPServer({\n apiKey: config.apiKey,\n apiUrl: config.apiUrl,\n agentId,\n timeout: config.timeout,\n });\n\n await server.start();\n\n // Keep process alive\n process.on('SIGINT', () => {\n logger.info('Received SIGINT, shutting down gracefully');\n process.exit(0);\n });\n\n process.on('SIGTERM', () => {\n logger.info('Received SIGTERM, shutting down gracefully');\n process.exit(0);\n });\n\n } catch (error) {\n const logger = getLogger();\n \n if (error instanceof Error) {\n logger.error('Fatal error:', { message: error.message });\n \n // Print user-friendly error to stderr\n console.error('\\nā Failed to start MemoryRelay MCP server\\n');\n console.error(error.message);\n console.error('\\nFor help, see: https://github.com/Alteriom/ai-memory-service/tree/main/mcp\\n');\n } else {\n logger.error('Fatal error:', { error });\n console.error('\\nā An unexpected error occurred\\n');\n }\n \n process.exit(1);\n }\n}\n\nmain();\n"],"mappings":";;;AAAA,SAAS,SAAS;AAKX,IAAM,eAAe,EAAE,OAAO;AAAA,EACnC,QAAQ,EAAE,OAAO,EACd,WAAW,QAAQ,EAAE,SAAS,iCAAiC,CAAC,EAChE,IAAI,IAAI,EAAE,SAAS,4CAA4C,CAAC;AAAA,EACnE,QAAQ,EAAE,OAAO,EACd,IAAI,EAAE,SAAS,8BAA8B,CAAC,EAC9C,QAAQ,6BAA6B;AAAA,EACxC,SAAS,EAAE,OAAO,EACf,SAAS,EACT,SAAS,kDAAkD;AAAA,EAC9D,SAAS,EAAE,OAAO,EACf,SAAS,EAAE,SAAS,2BAA2B,CAAC,EAChD,QAAQ,GAAK;AAAA,EAChB,UAAU,EAAE,KAAK,CAAC,SAAS,QAAQ,QAAQ,OAAO,CAAC,EAChD,QAAQ,MAAM;AACnB,CAAC;AAOM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AAED,YAAQ,GAAG,WAAW,MAAM;AAC1B,MAAAA,QAAO,KAAK,4CAA4C;AACxD,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EAEH,SAAS,OAAO;AACd,UAAMA,UAAS,UAAU;AAEzB,QAAI,iBAAiB,OAAO;AAC1B,MAAAA,QAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,QAAQ,CAAC;AAGvD,cAAQ,MAAM,mDAA8C;AAC5D,cAAQ,MAAM,MAAM,OAAO;AAC3B,cAAQ,MAAM,gFAAgF;AAAA,IAChG,OAAO;AACL,MAAAA,QAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC;AACtC,cAAQ,MAAM,yCAAoC;AAAA,IACpD;AAEA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK;","names":["z","z","logger"]}
|
|
1
|
+
{"version":3,"sources":["../src/config.ts","../src/logger.ts","../src/server.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["import { z } from 'zod';\n\n/**\n * Configuration schema with security validation\n */\nexport const configSchema = z.object({\n apiKey: z.string()\n .startsWith('mem_', { message: 'API key must start with \"mem_\"' })\n .min(20, { message: 'API key appears to be invalid (too short)' }),\n apiUrl: z.string()\n .url({ message: 'API URL must be a valid URL' })\n .default('https://api.memoryrelay.net'),\n agentId: z.string()\n .optional()\n .describe('Agent identifier - auto-detected if not provided'),\n timeout: z.number()\n .positive({ message: 'Timeout must be positive' })\n .default(30000),\n logLevel: z.enum(['debug', 'info', 'warn', 'error'])\n .default('info'),\n});\n\nexport type Config = z.infer<typeof configSchema>;\n\n/**\n * Load and validate configuration from environment variables\n */\nexport function loadConfig(): Config {\n try {\n const config = configSchema.parse({\n apiKey: process.env.MEMORYRELAY_API_KEY,\n apiUrl: process.env.MEMORYRELAY_API_URL,\n agentId: process.env.MEMORYRELAY_AGENT_ID,\n timeout: process.env.MEMORYRELAY_TIMEOUT \n ? parseInt(process.env.MEMORYRELAY_TIMEOUT, 10) \n : undefined,\n logLevel: process.env.MEMORYRELAY_LOG_LEVEL,\n });\n\n return config;\n } catch (error) {\n if (error instanceof z.ZodError) {\n const issues = error.issues.map(issue => \n ` - ${issue.path.join('.')}: ${issue.message}`\n ).join('\\n');\n \n throw new Error(\n `Configuration validation failed:\\n${issues}\\n\\n` +\n 'Please check your environment variables:\\n' +\n ' - MEMORYRELAY_API_KEY (required, starts with \"mem_\")\\n' +\n ' - MEMORYRELAY_API_URL (optional, default: https://api.memoryrelay.net)\\n' +\n ' - MEMORYRELAY_AGENT_ID (optional, auto-detected)\\n' +\n ' - MEMORYRELAY_TIMEOUT (optional, default: 30000)\\n' +\n ' - MEMORYRELAY_LOG_LEVEL (optional, default: info)'\n );\n }\n throw error;\n }\n}\n\n/**\n * Get or generate agent ID\n */\nexport function getAgentId(config: Config): string {\n if (config.agentId) {\n return config.agentId;\n }\n\n // Check OpenClaw agent name\n if (process.env.OPENCLAW_AGENT_NAME) {\n return process.env.OPENCLAW_AGENT_NAME;\n }\n\n // Auto-generate from hostname\n const hostname = process.env.HOSTNAME || 'unknown';\n return `agent-${hostname.slice(0, 8)}`;\n}\n","/**\n * Security-hardened logger for MCP server\n * \n * - All output to stderr (stdout reserved for MCP protocol)\n * - Automatic masking of API keys (anything starting with \"mem_\")\n * - No internal paths in error messages\n */\n\ntype LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n};\n\nexport class Logger {\n private minLevel: number;\n\n constructor(level: LogLevel = 'info') {\n this.minLevel = LOG_LEVELS[level];\n }\n\n /**\n * Mask sensitive data in log messages\n * - API keys starting with \"mem_\" are masked\n * - Internal paths are sanitized\n */\n private sanitize(message: string): string {\n let sanitized = message;\n\n // Mask API keys (mem_xxx -> mem_****)\n sanitized = sanitized.replace(/mem_[a-zA-Z0-9_-]+/g, 'mem_****');\n\n // Remove internal paths (anything that looks like a file path)\n sanitized = sanitized.replace(/\\/[a-zA-Z0-9_\\-./]+\\.(ts|js|json)/g, '<file>');\n sanitized = sanitized.replace(/at\\s+[^\\s]+\\s+\\([^)]+\\)/g, 'at <location>');\n\n return sanitized;\n }\n\n /**\n * Format log message with timestamp and level\n */\n private format(level: LogLevel, message: string, data?: unknown): string {\n const timestamp = new Date().toISOString();\n const sanitizedMessage = this.sanitize(message);\n \n let output = `[${timestamp}] [${level.toUpperCase()}] ${sanitizedMessage}`;\n \n if (data !== undefined) {\n const sanitizedData = this.sanitize(JSON.stringify(data, null, 2));\n output += `\\n${sanitizedData}`;\n }\n \n return output;\n }\n\n debug(message: string, data?: unknown): void {\n if (this.minLevel <= LOG_LEVELS.debug) {\n console.error(this.format('debug', message, data));\n }\n }\n\n info(message: string, data?: unknown): void {\n if (this.minLevel <= LOG_LEVELS.info) {\n console.error(this.format('info', message, data));\n }\n }\n\n warn(message: string, data?: unknown): void {\n if (this.minLevel <= LOG_LEVELS.warn) {\n console.error(this.format('warn', message, data));\n }\n }\n\n error(message: string, data?: unknown): void {\n if (this.minLevel <= LOG_LEVELS.error) {\n console.error(this.format('error', message, data));\n }\n }\n}\n\n// Export singleton instance\nlet logger: Logger;\n\nexport function initLogger(level: LogLevel = 'info'): Logger {\n logger = new Logger(level);\n return logger;\n}\n\nexport function getLogger(): Logger {\n if (!logger) {\n logger = new Logger();\n }\n return logger;\n}\n","/**\n * MCP Server implementation for MemoryRelay\n */\n\nimport { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n ListResourcesRequestSchema,\n ListResourceTemplatesRequestSchema,\n ReadResourceRequestSchema,\n ListPromptsRequestSchema,\n GetPromptRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js';\nimport { z } from 'zod';\nimport { MemoryRelayClient } from './client.js';\nimport { getLogger } from './logger.js';\nimport type { ClientConfig } from './types.js';\n\ndeclare const __VERSION__: string;\n\n/**\n * HTML-encode string to prevent XSS\n */\nfunction sanitizeHtml(str: string): string {\n return str\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(/\\//g, '/');\n}\n\n/**\n * Validate UUID format\n */\nconst uuidSchema = z.string().uuid();\n\nfunction validateUuid(id: string, fieldName: string = 'id'): void {\n const result = uuidSchema.safeParse(id);\n if (!result.success) {\n throw new Error(`Invalid ${fieldName}: must be a valid UUID`);\n }\n}\n\nexport class MemoryRelayMCPServer {\n private server: Server;\n private client: MemoryRelayClient;\n private logger = getLogger();\n\n constructor(config: ClientConfig) {\n this.client = new MemoryRelayClient(config);\n \n this.server = new Server(\n {\n name: '@memoryrelay/mcp-server',\n version: __VERSION__,\n },\n {\n capabilities: {\n tools: {},\n resources: {},\n prompts: {},\n },\n }\n );\n\n this.setupToolHandlers();\n this.setupResourceHandlers();\n this.setupPromptHandlers();\n this.logger.info('MCP server initialized');\n }\n\n /**\n * Setup MCP tool handlers\n */\n private setupToolHandlers(): void {\n // List available tools\n this.server.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: [\n {\n name: 'memory_store',\n description: 'Store a new memory. Use this to save important information, facts, preferences, or context that should be remembered for future conversations.',\n inputSchema: {\n type: 'object',\n properties: {\n content: {\n type: 'string',\n description: 'The memory content to store. Be specific and include relevant context.',\n },\n metadata: {\n type: 'object',\n description: 'Optional key-value metadata to attach to the memory',\n additionalProperties: { type: 'string' },\n },\n },\n required: ['content'],\n },\n },\n {\n name: 'memory_search',\n description: 'Search memories using natural language. Returns the most relevant memories based on semantic similarity to the query.',\n inputSchema: {\n type: 'object',\n properties: {\n query: {\n type: 'string',\n description: 'Natural language search query',\n },\n limit: {\n type: 'number',\n description: 'Maximum number of results to return (1-50)',\n minimum: 1,\n maximum: 50,\n default: 10,\n },\n threshold: {\n type: 'number',\n description: 'Minimum similarity threshold (0-1)',\n minimum: 0,\n maximum: 1,\n default: 0.5,\n },\n },\n required: ['query'],\n },\n },\n {\n name: 'memory_list',\n description: 'List recent memories chronologically. Use to review what has been remembered.',\n inputSchema: {\n type: 'object',\n properties: {\n limit: {\n type: 'number',\n description: 'Number of memories to return (1-100)',\n minimum: 1,\n maximum: 100,\n default: 20,\n },\n offset: {\n type: 'number',\n description: 'Offset for pagination',\n minimum: 0,\n default: 0,\n },\n },\n },\n },\n {\n name: 'memory_get',\n description: 'Retrieve a specific memory by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n description: 'The memory ID (UUID) to retrieve',\n },\n },\n required: ['id'],\n },\n },\n {\n name: 'memory_update',\n description: 'Update the content of an existing memory. Use to correct or expand stored information.',\n inputSchema: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n description: 'The memory ID (UUID) to update',\n },\n content: {\n type: 'string',\n description: 'The new content to replace the existing memory',\n },\n metadata: {\n type: 'object',\n description: 'Updated metadata (replaces existing)',\n additionalProperties: { type: 'string' },\n },\n },\n required: ['id', 'content'],\n },\n },\n {\n name: 'memory_delete',\n description: 'Permanently delete a memory. Use sparingly - memories are valuable context.',\n inputSchema: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n description: 'The memory ID (UUID) to delete',\n },\n },\n required: ['id'],\n },\n },\n {\n name: 'entity_create',\n description: 'Create a named entity (person, place, organization, project, concept) for the knowledge graph. Entities help organize and connect memories.',\n inputSchema: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n minLength: 1,\n maxLength: 200,\n description: 'Entity name (1-200 characters)',\n },\n type: {\n type: 'string',\n enum: ['person', 'place', 'organization', 'project', 'concept', 'other'],\n description: 'Entity type classification',\n },\n metadata: {\n type: 'object',\n description: 'Optional key-value metadata',\n additionalProperties: { type: 'string' },\n },\n },\n required: ['name', 'type'],\n },\n },\n {\n name: 'entity_link',\n description: 'Link an entity to a memory to establish relationships in the knowledge graph.',\n inputSchema: {\n type: 'object',\n properties: {\n entity_id: {\n type: 'string',\n description: 'Entity UUID',\n },\n memory_id: {\n type: 'string',\n description: 'Memory UUID',\n },\n relationship: {\n type: 'string',\n description: 'Relationship type (e.g., \"mentioned_in\", \"created_by\", \"relates_to\")',\n default: 'mentioned_in',\n },\n },\n required: ['entity_id', 'memory_id'],\n },\n },\n {\n name: 'memory_health',\n description: 'Check API connectivity and health status.',\n inputSchema: {\n type: 'object',\n properties: {},\n },\n },\n ],\n }));\n\n // Handle tool calls\n this.server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args = {} } = request.params;\n\n this.logger.debug(`Tool called: ${name}`, args);\n\n try {\n switch (name) {\n case 'memory_store': {\n const memory = await this.client.storeMemory(\n args.content as string,\n args.metadata as Record<string, string> | undefined\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(memory, null, 2),\n },\n ],\n };\n }\n\n case 'memory_search': {\n const results = await this.client.searchMemories(\n args.query as string,\n args.limit as number | undefined,\n args.threshold as number | undefined\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n { memories: results, total: results.length },\n null,\n 2\n ),\n },\n ],\n };\n }\n\n case 'memory_list': {\n const response = await this.client.listMemories(\n args.limit as number | undefined,\n args.offset as number | undefined\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(response, null, 2),\n },\n ],\n };\n }\n\n case 'memory_get': {\n const id = args.id as string;\n validateUuid(id, 'memory_id');\n\n const memory = await this.client.getMemory(id);\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(memory, null, 2),\n },\n ],\n };\n }\n\n case 'memory_update': {\n const id = args.id as string;\n validateUuid(id, 'memory_id');\n\n const memory = await this.client.updateMemory(\n id,\n args.content as string,\n args.metadata as Record<string, string> | undefined\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(memory, null, 2),\n },\n ],\n };\n }\n\n case 'memory_delete': {\n const id = args.id as string;\n validateUuid(id, 'memory_id');\n\n await this.client.deleteMemory(id);\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n { success: true, message: 'Memory deleted successfully' },\n null,\n 2\n ),\n },\n ],\n };\n }\n\n case 'entity_create': {\n // Validate input schema\n const entitySchema = z.object({\n name: z.string().min(1).max(200),\n type: z.enum(['person', 'place', 'organization', 'project', 'concept', 'other']),\n metadata: z.record(z.string()).optional(),\n });\n\n const validatedInput = entitySchema.parse(args);\n \n // Sanitize name to prevent XSS\n const sanitizedName = sanitizeHtml(validatedInput.name);\n \n const entity = await this.client.createEntity(\n sanitizedName,\n validatedInput.type,\n validatedInput.metadata\n );\n \n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(entity, null, 2),\n },\n ],\n };\n }\n\n case 'entity_link': {\n // Validate input schema\n const linkSchema = z.object({\n entity_id: z.string().uuid(),\n memory_id: z.string().uuid(),\n relationship: z.string().default('mentioned_in'),\n });\n\n const validatedInput = linkSchema.parse(args);\n \n await this.client.linkEntity(\n validatedInput.entity_id,\n validatedInput.memory_id,\n validatedInput.relationship\n );\n \n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n {\n success: true,\n message: 'Entity linked to memory successfully',\n entity_id: validatedInput.entity_id,\n memory_id: validatedInput.memory_id,\n relationship: validatedInput.relationship,\n },\n null,\n 2\n ),\n },\n ],\n };\n }\n\n case 'memory_health': {\n const health = await this.client.healthCheck();\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(health, null, 2),\n },\n ],\n };\n }\n\n default:\n throw new Error(`Unknown tool: ${name}`);\n }\n } catch (error) {\n let errorMessage = 'Unknown error';\n let errorDetails: unknown = undefined;\n\n if (error instanceof z.ZodError) {\n errorMessage = 'Validation error';\n errorDetails = error.errors;\n } else if (error instanceof Error) {\n errorMessage = error.message;\n }\n\n this.logger.error(`Tool execution failed: ${name}`, {\n error: errorMessage,\n details: errorDetails,\n });\n \n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n {\n error: 'Tool execution failed',\n message: errorMessage,\n details: errorDetails,\n },\n null,\n 2\n ),\n },\n ],\n isError: true,\n };\n }\n });\n }\n\n /**\n * Setup MCP resource handlers\n */\n private setupResourceHandlers(): void {\n // List static resources\n this.server.setRequestHandler(ListResourcesRequestSchema, async () => ({\n resources: [\n {\n uri: 'memory:///recent',\n name: 'Recent Memories',\n description: 'The 20 most recent memories stored in MemoryRelay',\n mimeType: 'application/json',\n },\n ],\n }));\n\n // List resource templates for dynamic access\n this.server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => ({\n resourceTemplates: [\n {\n uriTemplate: 'memory:///{id}',\n name: 'Memory by ID',\n description: 'Retrieve a specific memory by its UUID',\n mimeType: 'application/json',\n },\n ],\n }));\n\n // Read a resource\n this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {\n const { uri } = request.params;\n\n try {\n if (uri === 'memory:///recent') {\n const response = await this.client.listMemories(20, 0);\n return {\n contents: [\n {\n uri,\n mimeType: 'application/json',\n text: JSON.stringify(response, null, 2),\n },\n ],\n };\n }\n\n // Match memory:///{uuid} pattern\n const match = uri.match(/^memory:\\/\\/\\/([0-9a-f-]{36})$/);\n if (match) {\n const id = match[1];\n validateUuid(id, 'memory_id');\n const memory = await this.client.getMemory(id);\n return {\n contents: [\n {\n uri,\n mimeType: 'application/json',\n text: JSON.stringify(memory, null, 2),\n },\n ],\n };\n }\n\n throw new Error(`Unknown resource: ${uri}`);\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unknown error';\n this.logger.error(`Resource read failed: ${uri}`, { error: message });\n throw error;\n }\n });\n }\n\n /**\n * Setup MCP prompt handlers\n */\n private setupPromptHandlers(): void {\n // List available prompts\n this.server.setRequestHandler(ListPromptsRequestSchema, async () => ({\n prompts: [\n {\n name: 'store_memory',\n description: 'Store information as a persistent memory with appropriate metadata',\n arguments: [\n {\n name: 'information',\n description: 'The information to remember',\n required: true,\n },\n {\n name: 'category',\n description: 'Category for the memory (e.g., preference, fact, instruction, context)',\n required: false,\n },\n ],\n },\n {\n name: 'recall_memories',\n description: 'Search for and recall relevant memories about a topic',\n arguments: [\n {\n name: 'topic',\n description: 'The topic or question to search memories for',\n required: true,\n },\n ],\n },\n {\n name: 'summarize_memories',\n description: 'List and summarize all recent memories for context',\n arguments: [],\n },\n ],\n }));\n\n // Get a specific prompt\n this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n switch (name) {\n case 'store_memory': {\n const information = args?.information ?? '';\n const category = args?.category ?? '';\n const metadataInstruction = category\n ? ` Attach metadata with category \"${category}\".`\n : ' Attach appropriate metadata with a category tag.';\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: `Please store the following information as a persistent memory using the memory_store tool.${metadataInstruction}\\n\\nInformation to remember:\\n${information}`,\n },\n },\n ],\n };\n }\n\n case 'recall_memories': {\n const topic = args?.topic ?? '';\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: `Search my memories for information related to: \"${topic}\"\\n\\nUse the memory_search tool to find relevant memories, then summarize what you found. If nothing relevant is found, let me know.`,\n },\n },\n ],\n };\n }\n\n case 'summarize_memories': {\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: 'List my recent memories using the memory_list tool and provide a brief summary of what has been remembered. Group them by topic or category if possible.',\n },\n },\n ],\n };\n }\n\n default:\n throw new Error(`Unknown prompt: ${name}`);\n }\n });\n }\n\n /**\n * Start the MCP server with STDIO transport\n */\n async start(): Promise<void> {\n const transport = new StdioServerTransport();\n await this.server.connect(transport);\n this.logger.info('MCP server started on STDIO');\n }\n}\n","/**\n * MemoryRelay API client with retry logic and error handling\n */\n\nimport type {\n Memory,\n Entity,\n SearchResult,\n ListResponse,\n ClientConfig,\n EntityType,\n} from './types.js';\nimport { getLogger } from './logger.js';\n\n// Retry configuration\nconst MAX_RETRIES = 3;\nconst INITIAL_DELAY_MS = 1000;\nconst MAX_CONTENT_SIZE = 50 * 1024; // 50KB\n\n/**\n * Exponential backoff retry wrapper\n */\nasync function withRetry<T>(\n fn: () => Promise<T>,\n retries: number = MAX_RETRIES\n): Promise<T> {\n let lastError: Error | undefined;\n \n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n \n // Don't retry on certain errors\n if (\n lastError.message.includes('401') ||\n lastError.message.includes('403') ||\n lastError.message.includes('404') ||\n lastError.message.includes('400')\n ) {\n throw lastError;\n }\n \n // On last attempt, throw the error\n if (attempt === retries) {\n throw lastError;\n }\n \n // Exponential backoff with jitter\n const delay = INITIAL_DELAY_MS * Math.pow(2, attempt);\n const jitter = Math.random() * 0.3 * delay;\n await new Promise(resolve => setTimeout(resolve, delay + jitter));\n }\n }\n \n throw lastError || new Error('Retry failed');\n}\n\n/**\n * Mask API key in error messages for security\n */\nfunction maskApiKey(message: string, apiKey: string): string {\n if (!apiKey) return message;\n const maskedKey = apiKey.substring(0, 8) + '***';\n return message.replace(new RegExp(apiKey, 'g'), maskedKey);\n}\n\nexport class MemoryRelayClient {\n private config: ClientConfig;\n private logger = getLogger();\n\n constructor(config: ClientConfig) {\n this.config = config;\n this.logger.info('MemoryRelay client initialized', {\n apiUrl: config.apiUrl,\n agentId: config.agentId,\n });\n }\n\n /**\n * Make authenticated HTTP request to MemoryRelay API with retry logic\n */\n private async request<T>(\n method: string,\n path: string,\n body?: unknown\n ): Promise<T> {\n return withRetry(async () => {\n const url = `${this.config.apiUrl}${path}`;\n \n this.logger.debug(`API request: ${method} ${path}`);\n\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.config.timeout);\n\n try {\n const response = await fetch(url, {\n method,\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.config.apiKey}`,\n 'User-Agent': '@memoryrelay/mcp-server',\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n if (!response.ok) {\n // Handle rate limiting with retry\n if (response.status === 429) {\n const retryAfter = response.headers.get('Retry-After');\n const waitMs = retryAfter ? parseInt(retryAfter) * 1000 : 5000;\n this.logger.warn(`Rate limited, waiting ${waitMs}ms`);\n await new Promise(resolve => setTimeout(resolve, waitMs));\n throw new Error(`Rate limited: 429 - Retry after ${waitMs}ms`);\n }\n\n const errorData = await response.json().catch(() => ({})) as Record<string, unknown>;\n const errorMsg = `API request failed: ${response.status} ${response.statusText}` +\n (errorData.message ? ` - ${errorData.message}` : '');\n \n // Mask API key in error message\n throw new Error(maskApiKey(errorMsg, this.config.apiKey));\n }\n\n const data = await response.json();\n this.logger.debug(`API response: ${method} ${path}`, { status: response.status });\n \n return data as T;\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n throw new Error(`Request timeout after ${this.config.timeout}ms`);\n }\n // Mask API key in all error messages\n error.message = maskApiKey(error.message, this.config.apiKey);\n }\n throw error;\n } finally {\n clearTimeout(timeout);\n }\n });\n }\n\n /**\n * Validate content size\n */\n private validateContentSize(content: string): void {\n if (content.length > MAX_CONTENT_SIZE) {\n throw new Error(`Content exceeds maximum size of ${MAX_CONTENT_SIZE} bytes`);\n }\n }\n\n /**\n * Store a new memory\n */\n async storeMemory(content: string, metadata?: Record<string, string>): Promise<Memory> {\n this.validateContentSize(content);\n \n return this.request<Memory>('POST', '/v1/memories/memories', {\n content,\n metadata,\n agent_id: this.config.agentId,\n });\n }\n\n /**\n * Search memories using semantic search\n */\n async searchMemories(\n query: string,\n limit: number = 10,\n threshold: number = 0.5\n ): Promise<SearchResult[]> {\n this.validateContentSize(query);\n \n const response = await this.request<{ data: SearchResult[] }>(\n 'POST',\n '/v1/memories/memories/search',\n { query, limit, threshold, agent_id: this.config.agentId }\n );\n return response.data;\n }\n\n /**\n * List recent memories with pagination\n */\n async listMemories(limit: number = 20, offset: number = 0): Promise<ListResponse<Memory>> {\n return this.request<ListResponse<Memory>>(\n 'GET',\n `/v1/memories/memories?limit=${limit}&offset=${offset}`\n );\n }\n\n /**\n * Get a specific memory by ID\n */\n async getMemory(id: string): Promise<Memory> {\n return this.request<Memory>('GET', `/v1/memories/memories/${id}`);\n }\n\n /**\n * Update an existing memory\n */\n async updateMemory(\n id: string,\n content: string,\n metadata?: Record<string, string>\n ): Promise<Memory> {\n this.validateContentSize(content);\n \n return this.request<Memory>('PATCH', `/v1/memories/memories/${id}`, {\n content,\n metadata,\n });\n }\n\n /**\n * Delete a memory\n */\n async deleteMemory(id: string): Promise<void> {\n await this.request<void>('DELETE', `/v1/memories/memories/${id}`);\n }\n\n /**\n * Create a named entity\n */\n async createEntity(\n name: string,\n type: EntityType,\n metadata?: Record<string, string>\n ): Promise<Entity> {\n this.validateContentSize(name);\n \n return this.request<Entity>('POST', '/v1/entities', {\n name,\n type,\n metadata,\n });\n }\n\n /**\n * Link an entity to a memory\n */\n async linkEntity(\n entityId: string,\n memoryId: string,\n relationship: string = 'mentioned_in'\n ): Promise<void> {\n await this.request<void>('POST', '/v1/entities/links', {\n entity_id: entityId,\n memory_id: memoryId,\n relationship,\n });\n }\n\n /**\n * Get an entity by ID\n */\n async getEntity(id: string): Promise<Entity> {\n return this.request<Entity>('GET', `/v1/entities/${id}`);\n }\n\n /**\n * List entities with pagination\n */\n async listEntities(limit: number = 20, offset: number = 0): Promise<ListResponse<Entity>> {\n return this.request<ListResponse<Entity>>(\n 'GET',\n `/v1/entities?limit=${limit}&offset=${offset}`\n );\n }\n\n /**\n * Delete an entity\n */\n async deleteEntity(id: string): Promise<void> {\n await this.request<void>('DELETE', `/v1/entities/${id}`);\n }\n\n /**\n * Health check - verify API connectivity\n */\n async healthCheck(): Promise<{ status: string; message: string }> {\n try {\n // Simple GET request to check API is reachable\n await this.request<{ status: string }>('GET', '/v1/health');\n return {\n status: 'healthy',\n message: 'API connection successful',\n };\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error';\n return {\n status: 'unhealthy',\n message: `API connection failed: ${errorMsg}`,\n };\n }\n }\n}\n","#!/usr/bin/env node\n/**\n * MemoryRelay MCP Server - Entry Point\n * \n * Provides persistent memory storage for AI agents via Model Context Protocol\n */\n\nimport { loadConfig, getAgentId } from './config.js';\nimport { initLogger, getLogger } from './logger.js';\nimport { MemoryRelayMCPServer } from './server.js';\n\nasync function main() {\n try {\n // Load and validate configuration\n const config = loadConfig();\n \n // Initialize logger with configured level\n initLogger(config.logLevel);\n const logger = getLogger();\n\n logger.info('Starting MemoryRelay MCP server');\n\n // Get or generate agent ID\n const agentId = getAgentId(config);\n\n // Create and start MCP server\n const server = new MemoryRelayMCPServer({\n apiKey: config.apiKey,\n apiUrl: config.apiUrl,\n agentId,\n timeout: config.timeout,\n });\n\n await server.start();\n\n // Keep process alive\n process.on('SIGINT', () => {\n logger.info('Received SIGINT, shutting down gracefully');\n process.exit(0);\n });\n\n process.on('SIGTERM', () => {\n logger.info('Received SIGTERM, shutting down gracefully');\n process.exit(0);\n });\n\n } catch (error) {\n const logger = getLogger();\n \n if (error instanceof Error) {\n logger.error('Fatal error:', { message: error.message });\n \n // Print user-friendly error to stderr\n console.error('\\nā Failed to start MemoryRelay MCP server\\n');\n console.error(error.message);\n console.error('\\nFor help, see: https://github.com/memoryrelay/mcp-server#troubleshooting\\n');\n } else {\n logger.error('Fatal error:', { error });\n console.error('\\nā An unexpected error occurred\\n');\n }\n \n process.exit(1);\n }\n}\n\nmain();\n"],"mappings":";;;AAAA,SAAS,SAAS;AAKX,IAAM,eAAe,EAAE,OAAO;AAAA,EACnC,QAAQ,EAAE,OAAO,EACd,WAAW,QAAQ,EAAE,SAAS,iCAAiC,CAAC,EAChE,IAAI,IAAI,EAAE,SAAS,4CAA4C,CAAC;AAAA,EACnE,QAAQ,EAAE,OAAO,EACd,IAAI,EAAE,SAAS,8BAA8B,CAAC,EAC9C,QAAQ,6BAA6B;AAAA,EACxC,SAAS,EAAE,OAAO,EACf,SAAS,EACT,SAAS,kDAAkD;AAAA,EAC9D,SAAS,EAAE,OAAO,EACf,SAAS,EAAE,SAAS,2BAA2B,CAAC,EAChD,QAAQ,GAAK;AAAA,EAChB,UAAU,EAAE,KAAK,CAAC,SAAS,QAAQ,QA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AEA,KAAK;","names":["z","z","logger"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memoryrelay/mcp-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "MCP server for MemoryRelay - persistent memory for AI agents",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
|
-
"memoryrelay-mcp-server": "dist/index.js"
|
|
9
|
+
"memoryrelay-mcp-server": "dist/index.js",
|
|
10
|
+
"mcp-server": "dist/index.js"
|
|
10
11
|
},
|
|
11
12
|
"files": [
|
|
12
13
|
"dist",
|