pi-soly 1.9.3 → 1.11.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/ask/index.ts +12 -11
- package/ask/picker.ts +356 -76
- package/ask/prompt.ts +6 -2
- package/ask/tests/picker.test.ts +273 -82
- package/codemap.ts +276 -0
- package/hotreload.ts +239 -0
- package/init.ts +302 -0
- package/mcp/CHANGELOG.md +384 -0
- package/mcp/LICENSE +21 -0
- package/mcp/OAUTH.md +355 -0
- package/mcp/README.md +410 -0
- package/mcp/__tests__/agent-dir-paths.upstream-test.ts +80 -0
- package/mcp/__tests__/cli.upstream-test.ts +97 -0
- package/mcp/__tests__/commands-onboarding.upstream-test.ts +157 -0
- package/mcp/__tests__/config.upstream-test.ts +303 -0
- package/mcp/__tests__/consent-manager.upstream-test.ts +151 -0
- package/mcp/__tests__/direct-tools-auto-auth.upstream-test.ts +218 -0
- package/mcp/__tests__/direct-tools.upstream-test.ts +299 -0
- package/mcp/__tests__/elicitation-handler.upstream-test.ts +346 -0
- package/mcp/__tests__/elicitation-sdk-integration.upstream-test.ts +140 -0
- package/mcp/__tests__/errors.upstream-test.ts +218 -0
- package/mcp/__tests__/fixtures/elicitation-server.mjs +98 -0
- package/mcp/__tests__/host-html-template.upstream-test.ts +278 -0
- package/mcp/__tests__/index-lifecycle.upstream-test.ts +484 -0
- package/mcp/__tests__/init-elicitation.upstream-test.ts +86 -0
- package/mcp/__tests__/interactive-visualizer-server.upstream-test.ts +28 -0
- package/mcp/__tests__/logger.upstream-test.ts +175 -0
- package/mcp/__tests__/mcp-auth-flow-client-credentials.upstream-test.ts +612 -0
- package/mcp/__tests__/mcp-auth-storage.upstream-test.ts +47 -0
- package/mcp/__tests__/mcp-callback-server-unref.upstream-test.ts +264 -0
- package/mcp/__tests__/mcp-oauth-provider.upstream-test.ts +216 -0
- package/mcp/__tests__/mcp-panel-auth.upstream-test.ts +206 -0
- package/mcp/__tests__/mcp-panel-exclude-tools.upstream-test.ts +69 -0
- package/mcp/__tests__/mcp-panel-keybindings.upstream-test.ts +186 -0
- package/mcp/__tests__/npx-resolver.upstream-test.ts +54 -0
- package/mcp/__tests__/oauth-handler.upstream-test.ts +77 -0
- package/mcp/__tests__/onboarding-state.upstream-test.ts +52 -0
- package/mcp/__tests__/package-manifest.upstream-test.ts +22 -0
- package/mcp/__tests__/proxy-modes-auto-auth.upstream-test.ts +253 -0
- package/mcp/__tests__/proxy-modes-discovery.upstream-test.ts +84 -0
- package/mcp/__tests__/proxy-modes-manual-auth.upstream-test.ts +91 -0
- package/mcp/__tests__/proxy-modes-ui-messages.upstream-test.ts +72 -0
- package/mcp/__tests__/sampling-handler.upstream-test.ts +285 -0
- package/mcp/__tests__/server-manager-http-auth.upstream-test.ts +144 -0
- package/mcp/__tests__/server-manager-sampling.upstream-test.ts +236 -0
- package/mcp/__tests__/tool-metadata.upstream-test.ts +111 -0
- package/mcp/__tests__/tool-result-renderer.upstream-test.ts +147 -0
- package/mcp/__tests__/ui-integration.upstream-test.ts +551 -0
- package/mcp/__tests__/ui-resource-handler.upstream-test.ts +303 -0
- package/mcp/__tests__/ui-server.upstream-test.ts +967 -0
- package/mcp/__tests__/ui-session-messages.upstream-test.ts +72 -0
- package/mcp/__tests__/ui-streaming.upstream-test.ts +543 -0
- package/mcp/agent-dir.ts +20 -0
- package/mcp/app-bridge.bundle.js +67 -0
- package/mcp/cli.js +184 -0
- package/mcp/commands.ts +422 -0
- package/mcp/config.ts +666 -0
- package/mcp/consent-manager.ts +64 -0
- package/mcp/direct-tools.ts +439 -0
- package/mcp/elicitation-handler.ts +347 -0
- package/mcp/errors.ts +219 -0
- package/mcp/glimpse-ui.ts +80 -0
- package/mcp/host-html-template.ts +427 -0
- package/mcp/index.ts +362 -0
- package/mcp/init.ts +362 -0
- package/mcp/lifecycle.ts +93 -0
- package/mcp/logger.ts +169 -0
- package/mcp/mcp-auth-flow.ts +559 -0
- package/mcp/mcp-auth-flow.upstream-test.ts +259 -0
- package/mcp/mcp-auth.ts +302 -0
- package/mcp/mcp-auth.upstream-test.ts +373 -0
- package/mcp/mcp-callback-server.ts +372 -0
- package/mcp/mcp-callback-server.upstream-test.ts +416 -0
- package/mcp/mcp-oauth-provider.ts +369 -0
- package/mcp/mcp-oauth-provider.upstream-test.ts +518 -0
- package/mcp/mcp-panel.ts +829 -0
- package/mcp/mcp-setup-panel.ts +580 -0
- package/mcp/metadata-cache.ts +201 -0
- package/mcp/notify.ts +111 -0
- package/mcp/npx-resolver.ts +424 -0
- package/mcp/oauth-handler.ts +57 -0
- package/mcp/onboarding-state.ts +68 -0
- package/mcp/package.json +106 -0
- package/mcp/panel-keys.ts +37 -0
- package/mcp/proxy-modes.ts +949 -0
- package/mcp/resource-tools.ts +17 -0
- package/mcp/sampling-handler.ts +268 -0
- package/mcp/server-manager.ts +545 -0
- package/mcp/state.ts +41 -0
- package/mcp/tool-metadata.ts +216 -0
- package/mcp/tool-registrar.ts +46 -0
- package/mcp/tool-result-renderer.ts +161 -0
- package/mcp/types.ts +448 -0
- package/mcp/ui-resource-handler.ts +146 -0
- package/mcp/ui-server.ts +623 -0
- package/mcp/ui-session.ts +386 -0
- package/mcp/ui-stream-types.ts +89 -0
- package/mcp/utils.ts +129 -0
- package/mcp/vitest.config.ts +14 -0
- package/migrate.ts +258 -0
- package/notification.ts +218 -0
- package/notifications-log.ts +83 -0
- package/package.json +20 -3
- package/status.ts +140 -0
package/mcp/index.ts
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
// @ts-nocheck — upstream MCP code with pre-existing strict-mode issues
|
|
2
|
+
import type { ExtensionAPI, ToolInfo } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import type { McpExtensionState } from "./state.ts";
|
|
4
|
+
import { Type } from "typebox";
|
|
5
|
+
import { showStatus, showTools, reconnectServers, authenticateServer, logoutServer, openMcpAuthPanel, openMcpPanel, openMcpSetup } from "./commands.ts";
|
|
6
|
+
import { loadMcpConfig } from "./config.ts";
|
|
7
|
+
import { buildProxyDescription, createDirectToolExecutor, getMissingConfiguredDirectToolServers, resolveDirectTools } from "./direct-tools.ts";
|
|
8
|
+
import { flushMetadataCache, initializeMcp, updateStatusBar } from "./init.ts";
|
|
9
|
+
import { loadMetadataCache } from "./metadata-cache.ts";
|
|
10
|
+
import { executeAuthComplete, executeAuthStart, executeCall, executeConnect, executeDescribe, executeList, executeSearch, executeStatus, executeUiMessages } from "./proxy-modes.ts";
|
|
11
|
+
import { getConfigPathFromArgv, truncateAtWord } from "./utils.ts";
|
|
12
|
+
import { initializeOAuth, shutdownOAuth } from "./mcp-auth-flow.ts";
|
|
13
|
+
import { createMcpDirectToolCallRenderer, renderMcpProxyToolCall, renderMcpToolResult } from "./tool-result-renderer.ts";
|
|
14
|
+
|
|
15
|
+
export default function mcpAdapter(pi: ExtensionAPI) {
|
|
16
|
+
let state: McpExtensionState | null = null;
|
|
17
|
+
let initPromise: Promise<McpExtensionState> | null = null;
|
|
18
|
+
let lifecycleGeneration = 0;
|
|
19
|
+
|
|
20
|
+
async function shutdownState(currentState: McpExtensionState | null, reason: string): Promise<void> {
|
|
21
|
+
if (!currentState) return;
|
|
22
|
+
|
|
23
|
+
if (currentState.uiServer) {
|
|
24
|
+
currentState.uiServer.close(reason);
|
|
25
|
+
currentState.uiServer = null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let flushError: unknown;
|
|
29
|
+
try {
|
|
30
|
+
flushMetadataCache(currentState);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
flushError = error;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
await currentState.lifecycle.gracefulShutdown();
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (flushError) {
|
|
39
|
+
console.error("MCP: graceful shutdown failed after metadata flush error", error);
|
|
40
|
+
} else {
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (flushError) {
|
|
46
|
+
throw flushError;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const earlyConfigPath = getConfigPathFromArgv();
|
|
51
|
+
const earlyConfig = loadMcpConfig(earlyConfigPath);
|
|
52
|
+
const earlyCache = loadMetadataCache();
|
|
53
|
+
const prefix = earlyConfig.settings?.toolPrefix ?? "server";
|
|
54
|
+
|
|
55
|
+
const envRaw = process.env.MCP_DIRECT_TOOLS;
|
|
56
|
+
const directSpecs = envRaw === "__none__"
|
|
57
|
+
? []
|
|
58
|
+
: resolveDirectTools(
|
|
59
|
+
earlyConfig,
|
|
60
|
+
earlyCache,
|
|
61
|
+
prefix,
|
|
62
|
+
envRaw?.split(",").map(s => s.trim()).filter(Boolean),
|
|
63
|
+
);
|
|
64
|
+
const missingConfiguredDirectToolServers = getMissingConfiguredDirectToolServers(earlyConfig, earlyCache);
|
|
65
|
+
const shouldRegisterProxyTool =
|
|
66
|
+
earlyConfig.settings?.disableProxyTool !== true
|
|
67
|
+
|| directSpecs.length === 0
|
|
68
|
+
|| missingConfiguredDirectToolServers.length > 0;
|
|
69
|
+
|
|
70
|
+
for (const spec of directSpecs) {
|
|
71
|
+
(pi.registerTool as (tool: unknown) => unknown)({
|
|
72
|
+
name: spec.prefixedName,
|
|
73
|
+
label: `MCP: ${spec.originalName}`,
|
|
74
|
+
description: spec.description || "(no description)",
|
|
75
|
+
promptSnippet: truncateAtWord(spec.description, 100) || `MCP tool from ${spec.serverName}`,
|
|
76
|
+
parameters: Type.Unsafe((spec.inputSchema || { type: "object", properties: {} }) as never),
|
|
77
|
+
execute: createDirectToolExecutor(() => state, () => initPromise, spec),
|
|
78
|
+
renderCall: createMcpDirectToolCallRenderer(spec.prefixedName),
|
|
79
|
+
renderResult: renderMcpToolResult,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const getPiTools = (): ToolInfo[] => pi.getAllTools();
|
|
84
|
+
|
|
85
|
+
pi.registerFlag("mcp-config", {
|
|
86
|
+
description: "Path to MCP config file",
|
|
87
|
+
type: "string",
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
91
|
+
const generation = ++lifecycleGeneration;
|
|
92
|
+
const previousState = state;
|
|
93
|
+
state = null;
|
|
94
|
+
initPromise = null;
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
await Promise.all([
|
|
98
|
+
shutdownState(previousState, "session_restart"),
|
|
99
|
+
shutdownOAuth(),
|
|
100
|
+
]);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error("MCP: failed to shut down previous session state", error);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (generation !== lifecycleGeneration) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
await initializeOAuth().catch(err => {
|
|
110
|
+
console.error("MCP OAuth initialization failed:", err);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const promise = initializeMcp(pi, ctx);
|
|
114
|
+
initPromise = promise;
|
|
115
|
+
|
|
116
|
+
promise.then(async (nextState) => {
|
|
117
|
+
if (generation !== lifecycleGeneration || initPromise !== promise) {
|
|
118
|
+
try {
|
|
119
|
+
await shutdownState(nextState, "stale_session_start");
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error("MCP: failed to clean stale session state", error);
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
state = nextState;
|
|
127
|
+
updateStatusBar(nextState);
|
|
128
|
+
initPromise = null;
|
|
129
|
+
}).catch(err => {
|
|
130
|
+
if (generation !== lifecycleGeneration) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (initPromise !== promise && initPromise !== null) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
console.error("MCP initialization failed:", err);
|
|
137
|
+
initPromise = null;
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
pi.on("session_shutdown", async () => {
|
|
142
|
+
++lifecycleGeneration;
|
|
143
|
+
const currentState = state;
|
|
144
|
+
state = null;
|
|
145
|
+
initPromise = null;
|
|
146
|
+
|
|
147
|
+
try {
|
|
148
|
+
await Promise.all([
|
|
149
|
+
shutdownState(currentState, "session_shutdown"),
|
|
150
|
+
shutdownOAuth(),
|
|
151
|
+
]);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.error("MCP: session shutdown cleanup failed", error);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
pi.registerCommand("mcp", {
|
|
158
|
+
description: "Show MCP server status",
|
|
159
|
+
handler: async (args, ctx) => {
|
|
160
|
+
if (!state && initPromise) {
|
|
161
|
+
try {
|
|
162
|
+
state = await initPromise;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
165
|
+
if (ctx.hasUI) ctx.ui.notify(`MCP initialization failed: ${message}`, "error");
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (!state) {
|
|
170
|
+
if (ctx.hasUI) ctx.ui.notify("MCP not initialized", "error");
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const parts = args?.trim()?.split(/\s+/) ?? [];
|
|
175
|
+
const subcommand = parts[0] ?? "";
|
|
176
|
+
const targetServer = parts[1];
|
|
177
|
+
const rest = parts.slice(1).join(" ");
|
|
178
|
+
|
|
179
|
+
switch (subcommand) {
|
|
180
|
+
case "reconnect":
|
|
181
|
+
await reconnectServers(state, ctx, targetServer);
|
|
182
|
+
break;
|
|
183
|
+
case "tools":
|
|
184
|
+
await showTools(state, ctx);
|
|
185
|
+
break;
|
|
186
|
+
case "setup": {
|
|
187
|
+
const result = await openMcpSetup(state, pi, ctx, earlyConfigPath, "setup");
|
|
188
|
+
if (result?.configChanged) {
|
|
189
|
+
await ctx.reload();
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
case "logout": {
|
|
195
|
+
const serverName = rest;
|
|
196
|
+
if (!serverName) {
|
|
197
|
+
if (ctx.hasUI) ctx.ui.notify("Usage: /mcp logout <server>", "error");
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
await logoutServer(serverName, state, ctx);
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
case "status":
|
|
204
|
+
case "":
|
|
205
|
+
default:
|
|
206
|
+
if (ctx.hasUI) {
|
|
207
|
+
const result = await openMcpPanel(state, pi, ctx, earlyConfigPath);
|
|
208
|
+
if (result?.configChanged) {
|
|
209
|
+
await ctx.reload();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
await showStatus(state, ctx);
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
pi.registerCommand("mcp-auth", {
|
|
221
|
+
description: "Authenticate with an MCP server (OAuth)",
|
|
222
|
+
handler: async (args, ctx) => {
|
|
223
|
+
const serverName = args?.trim();
|
|
224
|
+
if (!serverName && !ctx.hasUI) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (!state && initPromise) {
|
|
229
|
+
try {
|
|
230
|
+
state = await initPromise;
|
|
231
|
+
} catch (error) {
|
|
232
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
233
|
+
if (ctx.hasUI) ctx.ui.notify(`MCP initialization failed: ${message}`, "error");
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (!state) {
|
|
238
|
+
if (ctx.hasUI) ctx.ui.notify("MCP not initialized", "error");
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (!serverName) {
|
|
243
|
+
await openMcpAuthPanel(state, pi, ctx, earlyConfigPath);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
await authenticateServer(serverName, state.config, ctx);
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
if (shouldRegisterProxyTool) {
|
|
252
|
+
(pi.registerTool as (tool: unknown) => unknown)({
|
|
253
|
+
name: "mcp",
|
|
254
|
+
label: "MCP",
|
|
255
|
+
description: buildProxyDescription(earlyConfig, earlyCache, directSpecs),
|
|
256
|
+
promptSnippet: "MCP gateway - connect to MCP servers and call their tools",
|
|
257
|
+
renderCall: renderMcpProxyToolCall,
|
|
258
|
+
parameters: Type.Object({
|
|
259
|
+
tool: Type.Optional(Type.String({ description: "Tool name to call (e.g., 'xcodebuild_list_sims')" })),
|
|
260
|
+
args: Type.Optional(Type.String({ description: "Arguments as JSON string (e.g., '{\"key\": \"value\"}')" })),
|
|
261
|
+
connect: Type.Optional(Type.String({ description: "Server name to connect (lazy connect + metadata refresh)" })),
|
|
262
|
+
describe: Type.Optional(Type.String({ description: "Tool name to describe (shows parameters)" })),
|
|
263
|
+
search: Type.Optional(Type.String({ description: "Search tools by name/description" })),
|
|
264
|
+
regex: Type.Optional(Type.Boolean({ description: "Treat search as regex (default: substring match)" })),
|
|
265
|
+
includeSchemas: Type.Optional(Type.Boolean({ description: "Include parameter schemas in search results (default: true)" })),
|
|
266
|
+
server: Type.Optional(Type.String({ description: "Filter to specific server (also disambiguates tool calls)" })),
|
|
267
|
+
action: Type.Optional(Type.String({ description: "Action: 'ui-messages', 'auth-start', or 'auth-complete'" })),
|
|
268
|
+
}),
|
|
269
|
+
renderResult: renderMcpToolResult,
|
|
270
|
+
async execute(_toolCallId: string, params: {
|
|
271
|
+
tool?: string;
|
|
272
|
+
args?: string;
|
|
273
|
+
connect?: string;
|
|
274
|
+
describe?: string;
|
|
275
|
+
search?: string;
|
|
276
|
+
regex?: boolean;
|
|
277
|
+
includeSchemas?: boolean;
|
|
278
|
+
server?: string;
|
|
279
|
+
action?: string;
|
|
280
|
+
}, _signal: AbortSignal | undefined, _onUpdate: unknown, _ctx: unknown) {
|
|
281
|
+
let parsedArgs: Record<string, unknown> | undefined;
|
|
282
|
+
if (params.args) {
|
|
283
|
+
try {
|
|
284
|
+
parsedArgs = JSON.parse(params.args);
|
|
285
|
+
if (typeof parsedArgs !== "object" || parsedArgs === null || Array.isArray(parsedArgs)) {
|
|
286
|
+
const gotType = Array.isArray(parsedArgs) ? "array" : parsedArgs === null ? "null" : typeof parsedArgs;
|
|
287
|
+
throw new Error(`Invalid args: expected a JSON object, got ${gotType}`);
|
|
288
|
+
}
|
|
289
|
+
} catch (error) {
|
|
290
|
+
if (error instanceof SyntaxError) {
|
|
291
|
+
throw new Error(`Invalid args JSON: ${error.message}`, { cause: error });
|
|
292
|
+
}
|
|
293
|
+
throw error;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (!state && initPromise) {
|
|
298
|
+
try {
|
|
299
|
+
state = await initPromise;
|
|
300
|
+
} catch (error) {
|
|
301
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
302
|
+
return {
|
|
303
|
+
content: [{ type: "text" as const, text: `MCP initialization failed: ${message}` }],
|
|
304
|
+
details: { error: "init_failed", message },
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (!state) {
|
|
309
|
+
return {
|
|
310
|
+
content: [{ type: "text" as const, text: "MCP not initialized" }],
|
|
311
|
+
details: { error: "not_initialized" },
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (params.action === "ui-messages") {
|
|
316
|
+
return executeUiMessages(state);
|
|
317
|
+
}
|
|
318
|
+
if (params.action === "auth-start") {
|
|
319
|
+
if (!params.server) {
|
|
320
|
+
return {
|
|
321
|
+
content: [{ type: "text" as const, text: "auth-start requires `server`. Example: mcp({ action: \"auth-start\", server: \"linear-server\" })" }],
|
|
322
|
+
details: { mode: "auth-start", error: "missing_server" },
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
return executeAuthStart(state, params.server);
|
|
326
|
+
}
|
|
327
|
+
if (params.action === "auth-complete") {
|
|
328
|
+
if (!params.server) {
|
|
329
|
+
return {
|
|
330
|
+
content: [{ type: "text" as const, text: "auth-complete requires `server`." }],
|
|
331
|
+
details: { mode: "auth-complete", error: "missing_server" },
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
const input = parsedArgs?.redirectUrl ?? parsedArgs?.code ?? parsedArgs?.input;
|
|
335
|
+
if (typeof input !== "string" || input.trim().length === 0) {
|
|
336
|
+
return {
|
|
337
|
+
content: [{ type: "text" as const, text: "auth-complete requires args with `redirectUrl`, `code`, or `input`." }],
|
|
338
|
+
details: { mode: "auth-complete", error: "missing_input" },
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
return executeAuthComplete(state, params.server, input);
|
|
342
|
+
}
|
|
343
|
+
if (params.tool) {
|
|
344
|
+
return executeCall(state, params.tool, parsedArgs, params.server, getPiTools);
|
|
345
|
+
}
|
|
346
|
+
if (params.connect) {
|
|
347
|
+
return executeConnect(state, params.connect);
|
|
348
|
+
}
|
|
349
|
+
if (params.describe) {
|
|
350
|
+
return executeDescribe(state, params.describe);
|
|
351
|
+
}
|
|
352
|
+
if (params.search) {
|
|
353
|
+
return executeSearch(state, params.search, params.regex, params.server, params.includeSchemas);
|
|
354
|
+
}
|
|
355
|
+
if (params.server) {
|
|
356
|
+
return executeList(state, params.server);
|
|
357
|
+
}
|
|
358
|
+
return executeStatus(state);
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
}
|