Skip to main content
Glama
dylan-gluck

MCP Background Job Server

by dylan-gluck

get_job_output

Retrieve the complete stdout and stderr output from a background job by providing its job ID. This tool enables monitoring and analysis of command execution results.

Instructions

Get the complete stdout and stderr output of a job.

Args: job_id: The UUID of the job to get output from

Returns: ProcessOutput containing the complete stdout and stderr content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_idYesJob ID to get output from

Implementation Reference

  • MCP tool handler for 'get_job_output', decorated with @mcp.tool(). Validates input with Pydantic Field, delegates to JobManager service, handles errors with ToolError.
    @mcp.tool()
    async def get_job_output(
        job_id: str = Field(..., description="Job ID to get output from"),
    ) -> ProcessOutput:
        """Get the complete stdout and stderr output of a job.
    
        Args:
            job_id: The UUID of the job to get output from
    
        Returns:
            ProcessOutput containing the complete stdout and stderr content
        """
        try:
            job_manager = get_job_manager()
            job_output = await job_manager.get_job_output(job_id)
            return job_output
        except KeyError:
            raise ToolError(f"Job {job_id} not found")
        except Exception as e:
            logger.error(f"Error getting job output for {job_id}: {e}")
            raise ToolError(f"Failed to get job output: {str(e)}")
  • Pydantic BaseModel defining the output schema for the tool, with stdout and stderr fields.
    class ProcessOutput(BaseModel):
        """Structured stdout/stderr output from a process."""
    
        stdout: str = Field(..., description="Standard output content")
        stderr: str = Field(..., description="Standard error content")
  • JobManager method implementing the core logic to fetch complete process output via ProcessWrapper for the specified job.
    async def get_job_output(self, job_id: str) -> ProcessOutput:
        """Get full stdout/stderr output.
    
        Args:
            job_id: Job identifier
    
        Returns:
            ProcessOutput with complete stdout and stderr
    
        Raises:
            KeyError: If job_id doesn't exist
        """
        if job_id not in self._jobs:
            raise KeyError(f"Job {job_id} not found")
    
        process_wrapper = self._processes.get(job_id)
        if process_wrapper is None:
            return ProcessOutput(stdout="", stderr="")
    
        return process_wrapper.get_output()

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/dylan-gluck/mcp-background-job'

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