recallium 1.2.3

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/bin/recallium ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../src/index.js';
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "recallium",
3
+ "version": "1.2.3",
4
+ "description": "MCP client for connecting Cursor/VS Code to Recallium AI Memory Server",
5
+ "author": "Recallium Team",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "bin": {
9
+ "recallium": "./bin/recallium"
10
+ },
11
+ "main": "src/index.js",
12
+ "files": [
13
+ "bin/",
14
+ "src/",
15
+ "README.md"
16
+ ],
17
+ "scripts": {
18
+ "test": "node src/index.js"
19
+ },
20
+ "dependencies": {
21
+ "@modelcontextprotocol/sdk": "^1.13.0",
22
+ "node-fetch": "^3.3.2"
23
+ },
24
+ "engines": {
25
+ "node": ">=18"
26
+ },
27
+ "keywords": [
28
+ "mcp",
29
+ "cursor",
30
+ "ai",
31
+ "memory",
32
+ "recallium",
33
+ "model-context-protocol"
34
+ ],
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/recallium/recallium.git"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ }
42
+ }
package/src/index.js ADDED
@@ -0,0 +1,177 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import {
4
+ ListToolsRequestSchema,
5
+ CallToolRequestSchema,
6
+ ListResourcesRequestSchema,
7
+ ReadResourceRequestSchema,
8
+ ListPromptsRequestSchema,
9
+ GetPromptRequestSchema,
10
+ ListRootsRequestSchema,
11
+ CreateMessageRequestSchema
12
+ } from '@modelcontextprotocol/sdk/types.js';
13
+ import fetch from 'node-fetch';
14
+
15
+ // Server configuration
16
+ const RECALLIUM_SERVER_URL = process.env.RECALLIUM_SERVER_URL || 'http://localhost:8000/mcp';
17
+ const DEBUG = process.env.RECALLIUM_DEBUG === 'true';
18
+
19
+ // Logging helper
20
+ function log(...args) {
21
+ if (DEBUG) {
22
+ console.error('[Recallium MCP Client]', ...args);
23
+ }
24
+ }
25
+
26
+ // Create the MCP server that communicates via stdio with Cursor
27
+ const server = new Server({
28
+ name: "recallium",
29
+ version: "1.0.0"
30
+ }, {
31
+ capabilities: {
32
+ tools: {},
33
+ resources: {},
34
+ prompts: {},
35
+ sampling: {},
36
+ roots: {
37
+ listChanged: true
38
+ }
39
+ }
40
+ });
41
+
42
+ // Helper to make HTTP requests to Recallium server
43
+ async function callRecalliumServer(method, params = {}) {
44
+ const requestBody = {
45
+ jsonrpc: "2.0",
46
+ method: method,
47
+ params: params,
48
+ id: Date.now().toString()
49
+ };
50
+
51
+ log(`Calling Recallium server: ${method}`, params);
52
+
53
+ try {
54
+ const response = await fetch(RECALLIUM_SERVER_URL, {
55
+ method: 'POST',
56
+ headers: {
57
+ 'Content-Type': 'application/json',
58
+ 'Accept': 'application/json, text/event-stream',
59
+ 'User-Agent': 'Recallium-MCP-Client/1.0'
60
+ },
61
+ body: JSON.stringify(requestBody)
62
+ });
63
+
64
+ if (!response.ok) {
65
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
66
+ }
67
+
68
+ const result = await response.json();
69
+
70
+ if (result.error) {
71
+ throw new Error(result.error.message || 'Unknown error');
72
+ }
73
+
74
+ log(`Response from Recallium:`, result.result);
75
+ return result.result;
76
+ } catch (error) {
77
+ log(`Error calling Recallium:`, error);
78
+ throw error;
79
+ }
80
+ }
81
+
82
+ // Handle tool discovery
83
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
84
+ log('Handling tools/list request');
85
+ return await callRecalliumServer('tools/list');
86
+ });
87
+
88
+ // Handle tool execution
89
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
90
+ const { name, arguments: args } = request.params;
91
+ log(`Handling tools/call request: ${name}`, args);
92
+ return await callRecalliumServer('tools/call', { name, arguments: args });
93
+ });
94
+
95
+ // Handle resource listing
96
+ server.setRequestHandler(ListResourcesRequestSchema, async () => {
97
+ log('Handling resources/list request');
98
+ return await callRecalliumServer('resources/list');
99
+ });
100
+
101
+ // Handle resource reading
102
+ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
103
+ const { uri } = request.params;
104
+ log(`Handling resources/read request: ${uri}`);
105
+ return await callRecalliumServer('resources/read', { uri });
106
+ });
107
+
108
+ // Handle prompt listing
109
+ server.setRequestHandler(ListPromptsRequestSchema, async () => {
110
+ log('Handling prompts/list request');
111
+ return await callRecalliumServer('prompts/list');
112
+ });
113
+
114
+ // Handle prompt retrieval
115
+ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
116
+ const { name, arguments: args } = request.params;
117
+ log(`Handling prompts/get request: ${name}`, args);
118
+ return await callRecalliumServer('prompts/get', { name, arguments: args });
119
+ });
120
+
121
+ // Handle sampling requests
122
+ server.setRequestHandler(CreateMessageRequestSchema, async (request) => {
123
+ log('Handling sampling/createMessage request');
124
+ return await callRecalliumServer('sampling/createMessage', request.params);
125
+ });
126
+
127
+ // Handle roots listing
128
+ server.setRequestHandler(ListRootsRequestSchema, async () => {
129
+ log('Handling roots/list request');
130
+ return await callRecalliumServer('roots/list');
131
+ });
132
+
133
+ // Start the stdio transport
134
+ async function start() {
135
+ log(`Starting Recallium MCP Client`);
136
+ log(`Connecting to Recallium server at: ${RECALLIUM_SERVER_URL}`);
137
+
138
+ // Test connection to Recallium server
139
+ try {
140
+ // Extract base URL (remove /mcp if present)
141
+ const baseUrl = RECALLIUM_SERVER_URL.replace(/\/mcp$/, '');
142
+ const response = await fetch(`${baseUrl}/health`);
143
+ if (!response.ok) {
144
+ console.error(`Warning: Recallium server at ${baseUrl} is not responding`);
145
+ console.error(`Make sure your Docker container is running: docker run -p 8000:8000 recallium`);
146
+ } else {
147
+ log('Successfully connected to Recallium server');
148
+ }
149
+ } catch (error) {
150
+ const baseUrl = RECALLIUM_SERVER_URL.replace(/\/mcp$/, '');
151
+ console.error(`Warning: Cannot connect to Recallium server at ${baseUrl}`);
152
+ console.error(`Error: ${error.message}`);
153
+ console.error(`Make sure your Docker container is running: docker run -p 8000:8000 recallium`);
154
+ }
155
+
156
+ const transport = new StdioServerTransport();
157
+ await server.connect(transport);
158
+
159
+ log('MCP stdio transport connected');
160
+ }
161
+
162
+ // Handle errors gracefully
163
+ process.on('uncaughtException', (error) => {
164
+ console.error('Uncaught exception:', error);
165
+ process.exit(1);
166
+ });
167
+
168
+ process.on('unhandledRejection', (reason, promise) => {
169
+ console.error('Unhandled rejection at:', promise, 'reason:', reason);
170
+ process.exit(1);
171
+ });
172
+
173
+ // Start the server
174
+ start().catch(error => {
175
+ console.error('Failed to start Recallium MCP Client:', error);
176
+ process.exit(1);
177
+ });