@memoraone/mcp 0.1.1 → 0.1.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/dist/client/memoraClient.js +22 -22
- package/dist/runContext.js +2 -2
- package/package.json +2 -2
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
async function postJson(url, headers, body) {
|
|
2
|
+
const { default: fetch } = await import('node-fetch');
|
|
3
|
+
const res = await fetch(url, {
|
|
4
|
+
method: 'POST',
|
|
5
|
+
headers,
|
|
6
|
+
body: JSON.stringify(body ?? {}),
|
|
7
|
+
});
|
|
8
|
+
const text = await res.text();
|
|
9
|
+
return {
|
|
10
|
+
status: res.status,
|
|
11
|
+
statusText: res.statusText,
|
|
12
|
+
ok: res.ok,
|
|
13
|
+
text,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
3
16
|
export class MemoraOneHttpError extends Error {
|
|
4
17
|
constructor(status, statusText, body) {
|
|
5
18
|
super(`MemoraOne request failed: ${status} ${statusText}`);
|
|
@@ -17,28 +30,15 @@ export class MemoraClient {
|
|
|
17
30
|
async post(path, body) {
|
|
18
31
|
const url = `${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`;
|
|
19
32
|
process.stderr.write(`[memoraone-mcp] http url=${url} projectId=${this.projectId} apiKeyPrefix=${String(this.apiKey).slice(0, 8)} apiKeyLen=${String(this.apiKey).length}\n`);
|
|
20
|
-
const res = await
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'x-memora-project-id': this.projectId,
|
|
26
|
-
},
|
|
27
|
-
body: JSON.stringify(body ?? {}),
|
|
28
|
-
});
|
|
29
|
-
const text = await res.text();
|
|
30
|
-
const parsedBody = (() => {
|
|
31
|
-
try {
|
|
32
|
-
return text ? JSON.parse(text) : null;
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return text;
|
|
36
|
-
}
|
|
37
|
-
})();
|
|
33
|
+
const res = await postJson(url, {
|
|
34
|
+
'content-type': 'application/json',
|
|
35
|
+
'x-api-key': this.apiKey,
|
|
36
|
+
'x-memora-project-id': this.projectId,
|
|
37
|
+
}, body);
|
|
38
38
|
if (!res.ok) {
|
|
39
|
-
throw new MemoraOneHttpError(res.status, res.statusText,
|
|
39
|
+
throw new MemoraOneHttpError(res.status, res.statusText, res.text);
|
|
40
40
|
}
|
|
41
|
-
return
|
|
41
|
+
return res.text ? JSON.parse(res.text) : null;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
export default MemoraClient;
|
package/dist/runContext.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/mcp/src/runContext.ts
|
|
2
|
-
import
|
|
2
|
+
import * as crypto from 'crypto';
|
|
3
3
|
let currentRunId = null;
|
|
4
4
|
export function getCurrentRunId() {
|
|
5
5
|
return currentRunId;
|
|
@@ -14,5 +14,5 @@ export function resolveRunId(passed) {
|
|
|
14
14
|
return currentRunId;
|
|
15
15
|
}
|
|
16
16
|
export function generateRunId() {
|
|
17
|
-
return
|
|
17
|
+
return crypto.randomBytes(16).toString('hex');
|
|
18
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memoraone/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"memoraone-mcp": "dist/cli.js"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
19
19
|
"dotenv": "^16.4.5",
|
|
20
|
-
"
|
|
20
|
+
"node-fetch": "2",
|
|
21
21
|
"zod": "^4.0.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|