Skip to main content
Glama

read_output

Retrieve process output from MalwareAnalyzerMCP by specifying the process ID. Enables monitoring or analysis of terminal command results during malware investigation.

Instructions

Read output from a running or completed process.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYesThe process ID to read output from

Implementation Reference

  • Zod schema defining the input parameters for the read_output tool: requires a numeric 'pid'.
    const readOutputSchema = z.object({ pid: z.number().int().describe("The process ID to read output from") });
  • serverMCP.js:105-109 (registration)
    Tool registration in the MCP listToolsRequestSchema handler, specifying name, description, and input schema.
    { name: 'read_output', description: 'Read output from a running or completed process.', inputSchema: zodToJsonSchema(readOutputSchema), },
  • The MCP server request handler case for 'read_output': validates input, calls terminalManager.readOutput, and formats response.
    case 'read_output': try { // Type-check and validate arguments if (!args || typeof args.pid !== 'number') { return { content: [{ type: "text", text: "Error: Invalid PID parameter" }], isError: true, }; } console.error(`Reading output for PID: ${args.pid}`); const result = terminalManager.readOutput(args.pid); return { content: [{ type: "text", text: JSON.stringify(result) }], }; } catch (error) { console.error('Error reading output:', error); return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; }
  • Core implementation of read_output: retrieves output from active or completed terminal sessions by PID, handling both streaming and final outputs.
    readOutput(pid) { // First check active sessions const session = this.sessions.get(pid); if (session) { const output = session.lastOutput; session.lastOutput = ''; // Clear the buffer after reading return { output }; } // Then check completed sessions const completedSession = this.completedSessions.get(pid); if (completedSession) { // Format completion message with exit code and runtime const runtime = (completedSession.endTime.getTime() - completedSession.startTime.getTime()) / 1000; const outputStr = `Process completed with exit code ${completedSession.exitCode}\nRuntime: ${runtime.toFixed(2)}s\nFinal output:\n${completedSession.output}`; // Remove from completed sessions as we've delivered the final output this.completedSessions.delete(pid); return { output: outputStr }; } // Return null if PID not found return { output: null }; }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/abdessamad-elamrani/MalwareAnalyzerMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server