@memoraone/mcp 0.1.2 → 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.
@@ -1,5 +1,18 @@
1
- //packages/mcp/src/client/memoraClient.ts
2
- import { fetch } from 'undici';
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 fetch(url, {
21
- method: 'POST',
22
- headers: {
23
- 'content-type': 'application/json',
24
- 'x-api-key': this.apiKey,
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, parsedBody);
39
+ throw new MemoraOneHttpError(res.status, res.statusText, res.text);
40
40
  }
41
- return parsedBody;
41
+ return res.text ? JSON.parse(res.text) : null;
42
42
  }
43
43
  }
44
44
  export default MemoraClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memoraone/mcp",
3
- "version": "0.1.2",
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
- "undici": "^7.16.0",
20
+ "node-fetch": "2",
21
21
  "zod": "^4.0.0"
22
22
  },
23
23
  "devDependencies": {