@belcore/mcp 0.0.0-stage → 0.1.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.
- package/README.md +2 -2
- package/dist/index.d.ts +13 -0
- package/dist/index.js +58 -0
- package/package.json +41 -3
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @belcore/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
See the [Belcore integrations README](https://github.com/terracore-kr/belcore-integrations#readme).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @belcore/mcp — MCP server (stdio) exposing Belcore to any MCP client.
|
|
4
|
+
*
|
|
5
|
+
* BELCORE_API_KEY=sk_live_... npx @belcore/mcp
|
|
6
|
+
*
|
|
7
|
+
* Tools:
|
|
8
|
+
* belcore_chat one turn with long-term context selection over the history you pass
|
|
9
|
+
* belcore_export_memory download what Belcore holds for an end user (endUserId mode only)
|
|
10
|
+
*/
|
|
11
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
12
|
+
import { Belcore } from "@belcore/sdk";
|
|
13
|
+
export declare function buildServer(client: Belcore): McpServer;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @belcore/mcp — MCP server (stdio) exposing Belcore to any MCP client.
|
|
4
|
+
*
|
|
5
|
+
* BELCORE_API_KEY=sk_live_... npx @belcore/mcp
|
|
6
|
+
*
|
|
7
|
+
* Tools:
|
|
8
|
+
* belcore_chat one turn with long-term context selection over the history you pass
|
|
9
|
+
* belcore_export_memory download what Belcore holds for an end user (endUserId mode only)
|
|
10
|
+
*/
|
|
11
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
12
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
13
|
+
import { realpathSync } from "node:fs";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { Belcore } from "@belcore/sdk";
|
|
17
|
+
export function buildServer(client) {
|
|
18
|
+
const server = new McpServer({ name: "belcore", version: "0.1.0" });
|
|
19
|
+
const emotion = z.object({ longing: z.number(), sulkiness: z.number(), emotionUpdatedAt: z.number() }).partial();
|
|
20
|
+
server.registerTool("belcore_chat", {
|
|
21
|
+
description: "Ask Belcore for one reply. Pass the full conversation history; Belcore selects the relevant long-term context and returns the reply plus updated emotion state. Belcore does not store conversation text.",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
messages: z.array(z.object({ role: z.enum(["user", "assistant"]), content: z.string() })).min(1),
|
|
24
|
+
system: z.string().optional(),
|
|
25
|
+
model: z.string().optional(),
|
|
26
|
+
emotion: emotion.optional(),
|
|
27
|
+
endUserId: z.string().optional(),
|
|
28
|
+
subjectId: z.string().optional(),
|
|
29
|
+
},
|
|
30
|
+
}, async (args) => {
|
|
31
|
+
const res = await client.chat(args);
|
|
32
|
+
return {
|
|
33
|
+
content: [{ type: "text", text: res.reply }],
|
|
34
|
+
structuredContent: { reply: res.reply, emotion: res.emotion ?? null, memory: res.memory ?? null, degraded: res.degraded ?? false },
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
server.registerTool("belcore_export_memory", {
|
|
38
|
+
description: "Export the numeric state Belcore holds for an end user (only exists if you used endUserId mode).",
|
|
39
|
+
inputSchema: { endUserId: z.string(), subjectId: z.string().optional() },
|
|
40
|
+
}, async ({ endUserId, subjectId }) => {
|
|
41
|
+
const data = await client.exportMemory(endUserId, { subjectId });
|
|
42
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
43
|
+
});
|
|
44
|
+
return server;
|
|
45
|
+
}
|
|
46
|
+
// True when this file is the program being run (also through the npx bin symlink), false when imported.
|
|
47
|
+
const isMain = (() => {
|
|
48
|
+
try {
|
|
49
|
+
return realpathSync(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
})();
|
|
55
|
+
if (isMain) {
|
|
56
|
+
const server = buildServer(new Belcore());
|
|
57
|
+
await server.connect(new StdioServerTransport());
|
|
58
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@belcore/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for Belcore (stdio)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"model-context-protocol",
|
|
8
|
+
"memory",
|
|
9
|
+
"belcore"
|
|
10
|
+
],
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"belcore-mcp": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@belcore/sdk": "0.1.0",
|
|
26
|
+
"@modelcontextprotocol/sdk": "^1.32.0",
|
|
27
|
+
"zod": "^3.25.0 || ^4.0.0"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -p tsconfig.build.json"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://belcore.xyz",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/terracore-kr/belcore-integrations"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
}
|
|
6
44
|
}
|