pi-mcp-client 0.3.0 → 0.3.2
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/dist/index.js +20 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30,6 +30,8 @@ function diagnostic(code, context) {
|
|
|
30
30
|
cancelled: "Start the operation again when ready.",
|
|
31
31
|
connection_failed: `Check the URL or executable, working directory, network, and TLS setup; then run /mcp reconnect ${target}.`,
|
|
32
32
|
protocol_error: "Check the server's MCP compatibility and protocol setting. Only stdio and Streamable HTTP are supported.",
|
|
33
|
+
server_unknown: "Choose a configured MCP server from the capability directory or run /mcp to list servers. Omit server in mcp_tools to search all enabled servers.",
|
|
34
|
+
server_disabled: `Run /mcp enable ${target}, or omit server in mcp_tools to search all enabled servers.`,
|
|
33
35
|
tool_changed: "Check server filters and use mcp_tools with activate and the exact identifier to activate the current tool definition. Reload Pi if the connection configuration changed.",
|
|
34
36
|
tool_error: "Review the server's tool result and inputs. Verify the outcome before retrying.",
|
|
35
37
|
oauth_failed: `Check OAuth support and browser access to the local callback, then run /mcp auth ${target}.`,
|
|
@@ -137,6 +139,8 @@ var init_diagnostics = __esm({
|
|
|
137
139
|
cancelled: "The operation was cancelled.",
|
|
138
140
|
connection_failed: "The server connection failed.",
|
|
139
141
|
protocol_error: "The server response or protocol is not supported.",
|
|
142
|
+
server_unknown: "The MCP server is not configured.",
|
|
143
|
+
server_disabled: "The MCP server is disabled.",
|
|
140
144
|
tool_changed: "The tool is unavailable or its configuration or schema changed.",
|
|
141
145
|
tool_error: "The tool reported an error.",
|
|
142
146
|
oauth_failed: "OAuth authentication did not complete.",
|
|
@@ -3024,7 +3028,14 @@ var McpRuntime = class {
|
|
|
3024
3028
|
return waitFor(state.listing, signal);
|
|
3025
3029
|
}
|
|
3026
3030
|
async discover(server, signal) {
|
|
3027
|
-
if (typeof server === "string")
|
|
3031
|
+
if (typeof server === "string") {
|
|
3032
|
+
const config = Object.hasOwn(this.config, server) ? this.config[server] : void 0;
|
|
3033
|
+
if (!config || config.disabled)
|
|
3034
|
+
throw new DiagnosticError(diagnostic(
|
|
3035
|
+
config ? "server_disabled" : "server_unknown",
|
|
3036
|
+
{ server, operation: "search" }
|
|
3037
|
+
));
|
|
3038
|
+
}
|
|
3028
3039
|
const names = Array.isArray(server) ? [...new Set(server)] : server ? [server] : Object.keys(this.config).filter((name) => !this.config[name].disabled).sort();
|
|
3029
3040
|
const result = {
|
|
3030
3041
|
tools: [],
|
|
@@ -3481,27 +3492,31 @@ function renderResult(result, options, theme, isError) {
|
|
|
3481
3492
|
state: isError ? "failed" : options.isPartial ? "running" : "done"
|
|
3482
3493
|
}
|
|
3483
3494
|
];
|
|
3495
|
+
const bodyInRow = details?.rows.length === 1 && details.rows[0].state === "failed" && details.rows[0].label === text && !/[\r\n]/.test(text);
|
|
3484
3496
|
let formattedOutput;
|
|
3485
3497
|
return {
|
|
3486
3498
|
render(width) {
|
|
3487
3499
|
if (width <= 0) return [];
|
|
3488
3500
|
const lines = rows.flatMap((row) => {
|
|
3489
3501
|
const status = states[row.state] ?? states.failed;
|
|
3490
|
-
const value = theme.fg(status.color, status.glyph) + " " + theme.fg("accent", line(row.label)) + (row.inlineDescription ? theme.fg("dim", ` ${line(row.inlineDescription)}`) : "");
|
|
3502
|
+
const value = theme.fg(status.color, status.glyph) + " " + theme.fg(status === states.failed ? "error" : "accent", line(row.label)) + (row.inlineDescription ? theme.fg(status === states.failed ? "error" : "dim", ` ${line(row.inlineDescription)}`) : "");
|
|
3491
3503
|
const rendered = options.expanded && (!details?.searchNotes || row.state === "failed") ? new Text(value, 0, 0).render(width).map((x) => truncateToWidth2(x, width)) : [truncateToWidth2(value, width)];
|
|
3492
3504
|
if (options.expanded && row.description)
|
|
3493
3505
|
rendered.push(truncateToWidth2(
|
|
3494
|
-
theme.fg("dim", ` ${line(row.description)}`),
|
|
3506
|
+
theme.fg(status === states.failed ? "error" : "dim", ` ${line(row.description)}`),
|
|
3495
3507
|
width
|
|
3496
3508
|
));
|
|
3497
3509
|
return rendered;
|
|
3498
3510
|
});
|
|
3499
3511
|
for (const note of details?.searchNotes ?? [])
|
|
3500
3512
|
lines.push(...(options.expanded ? new Text(theme.fg("warning", plain(note)), 0, 0).render(width) : [theme.fg("warning", line(note))]).map((row) => truncateToWidth2(row, width)));
|
|
3501
|
-
if (options.expanded && !options.isPartial && text && !details?.searchNotes)
|
|
3513
|
+
if (options.expanded && !options.isPartial && text && !details?.searchNotes && !bodyInRow)
|
|
3502
3514
|
lines.push(
|
|
3503
3515
|
...new Text(
|
|
3504
|
-
formattedOutput ??=
|
|
3516
|
+
formattedOutput ??= (() => {
|
|
3517
|
+
const output = validation ? formatValidation(body, theme) : formatOutput(body, details?.displayBlocks, theme);
|
|
3518
|
+
return isError || details?.failed ? theme.fg("error", output) : output;
|
|
3519
|
+
})(),
|
|
3505
3520
|
0,
|
|
3506
3521
|
0
|
|
3507
3522
|
).render(width).map((x) => truncateToWidth2(x, width))
|