pi-mcp-adapter 1.3.0 → 1.4.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/CHANGELOG.md +10 -0
- package/index.ts +54 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.4.0] - 2026-01-19
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **Non-blocking startup** - Pi starts immediately, MCP servers connect in background. First MCP call waits only if init isn't done yet.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Tool metadata now includes `inputSchema` after `/mcp reconnect` (was missing, breaking describe and error hints)
|
|
17
|
+
|
|
8
18
|
## [1.3.0] - 2026-01-19
|
|
9
19
|
|
|
10
20
|
### Changed
|
package/index.ts
CHANGED
|
@@ -55,25 +55,33 @@ export default function mcpAdapter(pi: ExtensionAPI) {
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
pi.on("session_start", async (_event, ctx) => {
|
|
58
|
+
// Non-blocking init - Pi starts immediately, MCP connects in background
|
|
58
59
|
initPromise = initializeMcp(pi, ctx);
|
|
59
|
-
state = await initPromise;
|
|
60
|
-
initPromise = null;
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
initPromise.then(s => {
|
|
62
|
+
state = s;
|
|
63
|
+
initPromise = null;
|
|
64
|
+
|
|
65
|
+
// Set up callback for auto-reconnect to update metadata
|
|
66
|
+
s.lifecycle.setReconnectCallback((serverName) => {
|
|
67
|
+
if (state) {
|
|
68
|
+
updateServerMetadata(state, serverName);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Update status bar when ready
|
|
73
|
+
if (ctx.hasUI) {
|
|
74
|
+
const totalTools = [...s.registeredTools.values()].flat().length;
|
|
75
|
+
if (totalTools > 0) {
|
|
76
|
+
ctx.ui.setStatus("mcp", ctx.ui.theme.fg("accent", `MCP: ${totalTools} tools`));
|
|
77
|
+
} else {
|
|
78
|
+
ctx.ui.setStatus("mcp", "");
|
|
79
|
+
}
|
|
66
80
|
}
|
|
81
|
+
}).catch(err => {
|
|
82
|
+
console.error("MCP initialization failed:", err);
|
|
83
|
+
initPromise = null;
|
|
67
84
|
});
|
|
68
|
-
|
|
69
|
-
if (ctx.hasUI) {
|
|
70
|
-
const totalTools = [...state.registeredTools.values()].flat().length;
|
|
71
|
-
if (totalTools > 0) {
|
|
72
|
-
ctx.ui.setStatus("mcp", ctx.ui.theme.fg("accent", `MCP: ${totalTools} tools`));
|
|
73
|
-
} else {
|
|
74
|
-
ctx.ui.setStatus("mcp", "");
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
85
|
});
|
|
78
86
|
|
|
79
87
|
pi.on("session_shutdown", async () => {
|
|
@@ -95,6 +103,15 @@ export default function mcpAdapter(pi: ExtensionAPI) {
|
|
|
95
103
|
pi.registerCommand("mcp", {
|
|
96
104
|
description: "Show MCP server status",
|
|
97
105
|
handler: async (args, ctx) => {
|
|
106
|
+
// Wait for init if still in progress
|
|
107
|
+
if (!state && initPromise) {
|
|
108
|
+
try {
|
|
109
|
+
state = await initPromise;
|
|
110
|
+
} catch {
|
|
111
|
+
if (ctx.hasUI) ctx.ui.notify("MCP initialization failed", "error");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
98
115
|
if (!state) {
|
|
99
116
|
if (ctx.hasUI) ctx.ui.notify("MCP not initialized", "error");
|
|
100
117
|
return;
|
|
@@ -128,6 +145,15 @@ export default function mcpAdapter(pi: ExtensionAPI) {
|
|
|
128
145
|
return;
|
|
129
146
|
}
|
|
130
147
|
|
|
148
|
+
// Wait for init if still in progress
|
|
149
|
+
if (!state && initPromise) {
|
|
150
|
+
try {
|
|
151
|
+
state = await initPromise;
|
|
152
|
+
} catch {
|
|
153
|
+
if (ctx.hasUI) ctx.ui.notify("MCP initialization failed", "error");
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
131
157
|
if (!state) {
|
|
132
158
|
if (ctx.hasUI) ctx.ui.notify("MCP not initialized", "error");
|
|
133
159
|
return;
|
|
@@ -173,6 +199,17 @@ Mode: tool (call) > describe > search > server (list) > nothing (status)`,
|
|
|
173
199
|
includeSchemas?: boolean;
|
|
174
200
|
server?: string;
|
|
175
201
|
}) {
|
|
202
|
+
// Wait for init if still in progress
|
|
203
|
+
if (!state && initPromise) {
|
|
204
|
+
try {
|
|
205
|
+
state = await initPromise;
|
|
206
|
+
} catch {
|
|
207
|
+
return {
|
|
208
|
+
content: [{ type: "text", text: "MCP initialization failed" }],
|
|
209
|
+
details: { error: "init_failed" },
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
176
213
|
if (!state) {
|
|
177
214
|
return {
|
|
178
215
|
content: [{ type: "text", text: "MCP not initialized" }],
|
|
@@ -827,11 +864,12 @@ async function reconnectServers(
|
|
|
827
864
|
|
|
828
865
|
state.registeredTools.set(name, toolNames);
|
|
829
866
|
|
|
830
|
-
// Update tool metadata for searching
|
|
867
|
+
// Update tool metadata for searching (include inputSchema for describe/errors)
|
|
831
868
|
const metadata: ToolMetadata[] = connection.tools.map(tool => ({
|
|
832
869
|
name: formatToolName(tool.name, name, prefix),
|
|
833
870
|
originalName: tool.name,
|
|
834
871
|
description: tool.description ?? "",
|
|
872
|
+
inputSchema: tool.inputSchema,
|
|
835
873
|
}));
|
|
836
874
|
for (const resource of connection.resources) {
|
|
837
875
|
if (definition.exposeResources !== false) {
|