Skip to content

Commit 55720d4

Browse files
committed
Return compact JSON from exec_command
1 parent a9d3bbd commit 55720d4

2 files changed

Lines changed: 7 additions & 20 deletions

File tree

‎src/lib/mcp/tools/browsers.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,6 @@ async function readBrowserTelemetry(
346346
if (rawError) return errorResponse(`error: ${rawError}`);
347347
}
348348

349-
// Single-line JSON rather than the pretty-printed house helpers: a page
350-
// carries up to 100 events and indentation would inflate the token cost.
351349
const serializedResponse = JSON.stringify(response);
352350
if (
353351
params.compact === false &&

‎src/lib/mcp/tools/shell.ts‎

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
type McpDependencies,
66
} from "@/lib/mcp/dependencies";
77
import { longOperationOptions } from "@/lib/mcp/request-options";
8-
import { throwToolError } from "@/lib/mcp/responses";
8+
import { jsonResponse, throwToolError } from "@/lib/mcp/responses";
99
import {
1010
projectForOperation,
1111
projectSelectionInputSchema,
@@ -102,23 +102,12 @@ export function registerShellTool(
102102
? Buffer.from(result.stderr_b64, "base64").toString("utf-8")
103103
: "";
104104

105-
return {
106-
content: [
107-
{
108-
type: "text",
109-
text: JSON.stringify(
110-
{
111-
exit_code: result.exit_code,
112-
duration_ms: result.duration_ms,
113-
stdout,
114-
stderr,
115-
},
116-
null,
117-
2,
118-
),
119-
},
120-
],
121-
};
105+
return jsonResponse({
106+
exit_code: result.exit_code,
107+
duration_ms: result.duration_ms,
108+
stdout,
109+
stderr,
110+
});
122111
} catch (error) {
123112
throwToolError("exec_command", "exec", error);
124113
}

0 commit comments

Comments
 (0)