xmemory 1.0.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.
Files changed (4) hide show
  1. package/README.md +90 -0
  2. package/cli.js +6 -0
  3. package/index.js +11 -0
  4. package/package.json +24 -0
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # `xmemory`
2
+
3
+ Integration code with `xmemory`.
4
+
5
+ For now just the Mastra prompt.
6
+
7
+ First, create a local Mastra instance:
8
+
9
+ ```
10
+ npm create mastra@latest mastra-with-xmemory
11
+ ```
12
+
13
+ From within this example `mastra-with-xmemory` directory, first give it some LLM key:
14
+
15
+ ```
16
+ echo "export ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY_FOR_MASTRA" >>.env
17
+ ```
18
+
19
+ Then you may want to add MCP support to Mastra first, for its hot reload to pick up `xmemory` right away.
20
+
21
+ ```
22
+ npm i @mastra/mcp
23
+ ```
24
+
25
+ Then fire up the AI-assisted IDE of your choice and give it this prompt.
26
+
27
+ ```
28
+ We need to integrate the `xmemory` MCP server with the Mastra instance running from this directory.
29
+
30
+ To do this we need to add the `xmemory` Agent, alongside the Weather Agent, and the `xmemory` MCP server to use the Tools from it.
31
+
32
+ The `xmemory` Agent setup is straightforward, just clone what the Weather Agent has, with `xmemory`-specific instructions. Use the following instructions:
33
+
34
+ ~ ~ ~
35
+
36
+ > You are the xmemory assistant. You help users manage and query their xmemory instance:
37
+ > - Create and configure new instances, generate or enhance schemas, connect and disconnect from instances.
38
+ > - Use the xmemory_admin_* tools to perform administrative and schema operations as requested.
39
+ > - Be concise and confirm what you did after each action.
40
+
41
+ ~ ~ ~
42
+
43
+ For the MCP server, you need to add `@mastra/mcp` into `package.json` if it's not already there.
44
+
45
+ And then make changes along these lines:
46
+
47
+ new file mode 100644
48
+ --- /dev/null
49
+ +++ b/src/mastra/mcp-clients.ts
50
+ @@ -0,0 +1,19 @@
51
+ +import { MCPClient } from '@mastra/mcp';
52
+ +
53
+ +if (!process.env.XMEM_MCP_BEARER_TOKEN) {
54
+ + throw new Error('XMEM_MCP_BEARER_TOKEN environment variable is required');
55
+ +}
56
+ +
57
+ +export const xmemoryMcp = new MCPClient({
58
+ + id: 'xmemory',
59
+ + servers: {
60
+ + xmemory: {
61
+ + url: new URL('https://dk-mcp.xmemory.ai'),
62
+ + requestInit: {
63
+ + headers: {
64
+ + Authorization: `Bearer ${process.env.XMEM_MCP_BEARER_TOKEN}`,
65
+ + },
66
+ + },
67
+ + },
68
+ + },
69
+ +});
70
+
71
+
72
+ new file mode 100644
73
+ --- /dev/null
74
+ +++ b/src/mastra/xmemory-tools.ts
75
+ @@ -0,0 +1,10 @@
76
+ +import { xmemoryMcp } from './mcp-clients';
77
+ +
78
+ +let xmemoryTools: Record<string, any> = {};
79
+ +try {
80
+ + xmemoryTools = await xmemoryMcp.listTools();
81
+ +} catch (err) {
82
+ + console.error('Failed to load xmemory MCP tools:', err);
83
+ +}
84
+ +
85
+ +export { xmemoryTools };
86
+
87
+ ~ ~ ~
88
+
89
+ Commit the above as "Added `xmemory` to Mastra."
90
+ ```
package/cli.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+
3
+ const greet = require("./index");
4
+
5
+ const name = process.argv[2];
6
+ console.log(greet(name));
package/index.js ADDED
@@ -0,0 +1,11 @@
1
+ // NOTE(dkorolev): There will be more to this module.
2
+ // For now it's just the prompt to connect `xmemory` to Mastra.
3
+
4
+ function greet(name) {
5
+ if (name) {
6
+ return `Hello, ${name}!`;
7
+ }
8
+ return "Hello, xmemory!";
9
+ }
10
+
11
+ module.exports = greet;
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "xmemory",
3
+ "version": "1.0.0",
4
+ "description": "xmemory",
5
+ "keywords": [ "xmemory" ],
6
+ "homepage": "https://github.com/xmemory-ai/xmemory-npm",
7
+ "bugs": {
8
+ "url": "https://github.com/xmemory-ai/xmemory-npm/issues"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/xmemory-ai/xmemory-npm.git"
13
+ },
14
+ "license": "MIT",
15
+ "author": "Dima Korolev",
16
+ "type": "commonjs",
17
+ "main": "index.js",
18
+ "bin": {
19
+ "xmemory": "cli.js"
20
+ },
21
+ "scripts": {
22
+ "test": "echo \"Error: no test specified\" && exit 1"
23
+ }
24
+ }