Skip to main content
Glama
benzkittisak

codex-async-mcp

by benzkittisak

codex_cancel

Stop a running codex job by sending SIGTERM to its subprocess. Provide the job ID from codex_start to cancel the task.

Instructions

Cancel a running codex job by sending SIGTERM to the subprocess.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_idYesThe job_id returned by codex_start.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler for 'codex_cancel'. Decorated with @mcp.tool(), it receives a job_id and delegates to cancel_job().
    @mcp.tool()
    def codex_cancel(job_id: str) -> dict:
        """
        Cancel a running codex job by sending SIGTERM to the subprocess.
    
        Args:
            job_id: The job_id returned by codex_start.
        """
        return cancel_job(job_id)
  • The @mcp.tool() decorator registers 'codex_cancel' as a tool with the FastMCP server.
    @mcp.tool()
  • Type signature: accepts a string job_id and returns a dict (the schema for inputs/outputs).
    def codex_cancel(job_id: str) -> dict:
  • The actual cancel logic: looks up the job, terminates the subprocess (via Popen.terminate() or os.kill with SIGTERM), updates the meta status to 'cancelled', and returns the result.
    def cancel_job(job_id: str) -> dict:
        meta = _read_meta(job_id)
        if meta is None:
            return {"error": f"Job '{job_id}' not found"}
    
        if meta["status"] != "running":
            return {"job_id": job_id, "status": meta["status"], "message": "Job is not running"}
    
        with _lock:
            proc = _active_procs.get(job_id)
    
        killed = False
        if proc is not None:
            proc.terminate()
            killed = True
        else:
            pid = meta.get("pid")
            if pid and _is_pid_alive(pid):
                os.kill(pid, 15)  # SIGTERM
                killed = True
    
        with _lock:
            meta["status"] = "cancelled"
            meta["finished_at"] = datetime.now(timezone.utc).isoformat()
            _write_meta(job_id, meta)
            _active_procs.pop(job_id, None)
    
        return {"job_id": job_id, "status": "cancelled", "killed": killed}
  • Imports subprocess module used by cancel_job for process management.
    import subprocess
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses that cancellation is done by sending SIGTERM to the subprocess, which is a key behavioral trait. It does not cover edge cases like job already finished, but the main behavior is well communicated.

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 a single 12-word sentence, front-loaded with the action, and contains no wasted words.

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

Completeness4/5

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

Given the tool's simplicity (one parameter, single action), the description is nearly complete. It could mention what happens if the job is not running, but the output schema likely handles error responses.

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

Parameters3/5

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

The input schema already describes the only parameter (job_id) with 100% coverage. The description adds no new semantic information beyond what the schema provides.

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 uses a specific verb ('Cancel') and resource ('running codex job'), and clearly distinguishes from siblings like codex_list, codex_poll, and codex_start.

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

Usage Guidelines4/5

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

The description implicitly states when to use (to cancel a running job with a job_id from codex_start) but does not explicitly state when not to use or provide alternative scenarios. However, the simplicity of the action mitigates the need for extensive guidelines.

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/benzkittisak/claude-codex-mcp'

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