@pi-archimedes/mcp 2.3.0 → 2.5.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/package.json +4 -4
- package/src/default-export.test.ts +33 -0
- package/src/index.ts +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-archimedes/mcp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
18
18
|
"@napi-rs/keyring": "^1.3.0",
|
|
19
19
|
"open": "^10.2.0",
|
|
20
|
-
"@pi-archimedes/core": "2.
|
|
20
|
+
"@pi-archimedes/core": "2.5.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@earendil-works/pi-coding-agent": ">=0.1.0",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"typebox": ">=1.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@earendil-works/pi-coding-agent": "^0.84.
|
|
29
|
-
"@earendil-works/pi-tui": "^0.84.
|
|
28
|
+
"@earendil-works/pi-coding-agent": "^0.84.4",
|
|
29
|
+
"@earendil-works/pi-tui": "^0.84.4",
|
|
30
30
|
"@types/node": "^22.0.0",
|
|
31
31
|
"typebox": "^1.1.38",
|
|
32
32
|
"typescript": "^6.0.3"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import defaultExport from "./index.js";
|
|
3
|
+
|
|
4
|
+
describe("mcp default export (standalone factory)", () => {
|
|
5
|
+
it("is a function that registers the mcp extension (registerMcp subscribes its own session events)", () => {
|
|
6
|
+
expect(typeof defaultExport).toBe("function");
|
|
7
|
+
|
|
8
|
+
const handlers: Record<string, Array<(...args: unknown[]) => unknown>> = {};
|
|
9
|
+
const tools: Array<{ name: string }> = [];
|
|
10
|
+
const commands: Record<string, unknown> = {};
|
|
11
|
+
const pi = {
|
|
12
|
+
on: (name: string, fn: (...args: unknown[]) => unknown) => {
|
|
13
|
+
(handlers[name] ??= []).push(fn);
|
|
14
|
+
},
|
|
15
|
+
registerTool: (def: { name: string }) => {
|
|
16
|
+
tools.push(def);
|
|
17
|
+
},
|
|
18
|
+
registerCommand: (name: string, def: unknown) => {
|
|
19
|
+
commands[name] = def;
|
|
20
|
+
},
|
|
21
|
+
} as any;
|
|
22
|
+
|
|
23
|
+
defaultExport(pi);
|
|
24
|
+
|
|
25
|
+
// session lifecycle handled inside registerMcp
|
|
26
|
+
expect(handlers["session_start"]?.length).toBeGreaterThan(0);
|
|
27
|
+
expect(handlers["session_shutdown"]?.length).toBeGreaterThan(0);
|
|
28
|
+
|
|
29
|
+
// mcp proxy tool + /mcp command registered
|
|
30
|
+
expect(tools.some((t) => t.name === "mcp")).toBe(true);
|
|
31
|
+
expect(commands["mcp"]).toBeDefined();
|
|
32
|
+
});
|
|
33
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -144,3 +144,12 @@ export function registerMcp(pi: ExtensionAPI): void {
|
|
|
144
144
|
}),
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
+
|
|
148
|
+
// ── Default export (for standalone pi.extensions loading) ─────────────────
|
|
149
|
+
|
|
150
|
+
// registerMcp subscribes its own session_start/session_shutdown handlers
|
|
151
|
+
// internally (top-level, per AGENTS.md), so the default factory just
|
|
152
|
+
// registers it.
|
|
153
|
+
export default function (pi: ExtensionAPI): void {
|
|
154
|
+
registerMcp(pi);
|
|
155
|
+
}
|