Skip to main content
Glama
dylan-gluck

MCP Background Job Server

by dylan-gluck

kill_job

Terminate a running background job by its UUID to stop processes and manage system resources.

Instructions

Kill a running background job.

Args: job_id: The UUID of the job to terminate

Returns: KillOutput indicating the result of the kill operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_idYesJob ID to kill

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusYesKill result: 'killed', 'already_terminated', or 'not_found'

Implementation Reference

  • FastMCP tool handler for 'kill_job': validates job_id input using Pydantic Field, calls JobManager.kill_job, returns KillOutput with result status.
    @mcp.tool()
    async def kill_job(
        job_id: str = Field(..., description="Job ID to kill"),
    ) -> KillOutput:
        """Kill a running background job.
    
        Args:
            job_id: The UUID of the job to terminate
    
        Returns:
            KillOutput indicating the result of the kill operation
        """
        try:
            job_manager = get_job_manager()
            kill_result = await job_manager.kill_job(job_id)
            return KillOutput(status=kill_result)
        except Exception as e:
            logger.error(f"Error killing job {job_id}: {e}")
            raise ToolError(f"Failed to kill job: {str(e)}")
  • Pydantic schemas for kill_job tool: KillInput defines the job_id parameter, KillOutput defines the status response field with possible values.
    class KillInput(BaseModel):
        """Input for kill tool."""
    
        job_id: str = Field(..., description="Job ID to kill")
    
    
    class KillOutput(BaseModel):
        """Output from kill tool."""
    
        status: str = Field(
            ..., description="Kill result: 'killed', 'already_terminated', or 'not_found'"
        )
  • Core JobManager.kill_job implementation: checks if job exists and is running, terminates the process using ProcessWrapper.kill(), updates job status and metadata, returns result status string.
    async def kill_job(self, job_id: str) -> str:
        """Kill running job.
    
        Args:
            job_id: Job identifier
    
        Returns:
            Kill result: 'killed', 'already_terminated', or 'not_found'
        """
        if job_id not in self._jobs:
            return "not_found"
    
        job = self._jobs[job_id]
        process_wrapper = self._processes.get(job_id)
    
        # Update status first
        await self._update_job_status(job_id)
    
        if job.status in [JobStatus.COMPLETED, JobStatus.FAILED, JobStatus.KILLED]:
            return "already_terminated"
    
        if process_wrapper is None:
            job.status = JobStatus.FAILED
            return "already_terminated"
    
        # Kill the process
        if process_wrapper.kill():
            job.status = JobStatus.KILLED
            job.completed = datetime.now(timezone.utc)
            job.exit_code = process_wrapper.get_exit_code()
            logger.info(f"Killed job {job_id}")
            return "killed"
        else:
            return "already_terminated"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action is to 'terminate' a job, implying a destructive operation, but doesn't clarify critical aspects like whether the kill is reversible, what permissions are required, or potential side effects (e.g., data loss). This leaves significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and well-structured: a clear purpose statement followed by brief sections for Args and Returns. Every sentence earns its place, with no redundant information, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a destructive operation) and the presence of an output schema (which handles return values), the description is moderately complete. It covers the basic purpose and parameter, but lacks behavioral details like safety warnings or prerequisites, which are important for a kill operation with no annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents the job_id parameter. The description adds minimal value by restating it as 'The UUID of the job to terminate', which slightly reinforces the parameter's purpose but doesn't provide additional syntax or format details beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Kill') and target resource ('a running background job'), distinguishing it from sibling tools like get_job_status, list_jobs, or get_job_output. It precisely communicates the tool's function without ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying 'a running background job', suggesting this tool is for active jobs rather than completed ones. However, it lacks explicit guidance on when to use it versus alternatives like interact_with_job or when not to use it (e.g., for non-running jobs).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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