terminal_get_output
Retrieve output from a terminal session in an Electron application to access command results programmatically.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes |
Implementation Reference
- index.js:331-358 (registration)Registration of the 'terminal_get_output' MCP tool, including input schema (sessionId: string) and inline handler function that fetches terminal output from the Electron backend API, cleans it, and returns formatted content.server.tool( "terminal_get_output", { sessionId: z.string() }, async ({ sessionId }) => { try { // Check if server is running, start if not if (!(await isServerRunning())) { await startElectronProcess(); } const response = await axios.get(`${apiBaseUrl}/output/${sessionId}`); const result = response.data; // Clean up terminal output using strip-ansi const cleanOutput = stripAnsi(result.output); return { content: [{ type: "text", text: `Session ID: ${result.sessionId}\n\n ${cleanOutput}`, exitCode: result.exitCode }] }; } catch (error) { return formatErrorResponse(error, sessionId); } } );
- index.js:337-357 (handler)Handler logic for 'terminal_get_output': Ensures Electron server is running, GETs output for sessionId from /output/{sessionId}, strips ANSI, formats response with session ID and exit code, handles errors.try { // Check if server is running, start if not if (!(await isServerRunning())) { await startElectronProcess(); } const response = await axios.get(`${apiBaseUrl}/output/${sessionId}`); const result = response.data; // Clean up terminal output using strip-ansi const cleanOutput = stripAnsi(result.output); return { content: [{ type: "text", text: `Session ID: ${result.sessionId}\n\n ${cleanOutput}`, exitCode: result.exitCode }] }; } catch (error) { return formatErrorResponse(error, sessionId); } } );
- index.js:334-336 (schema)Input schema for 'terminal_get_output' tool: requires a string sessionId.sessionId: z.string() }, async ({ sessionId }) => {