Skip to main content
Glama
Unstructured-IO

Unstructured API MCP Server

Official

cancel_job

Delete a specific job by its ID to stop processing and manage resources in the Unstructured API workflow system.

Instructions

Delete a specific job.

Args:
    job_id: ID of the job to cancel

Returns:
    String containing the response from the job cancellation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main MCP tool handler for 'cancel_job'. It cancels a job using the UnstructuredClient's jobs.cancel_job_async method with a CancelJobRequest.
    @mcp.tool()
    async def cancel_job(ctx: Context, job_id: str) -> str:
        """Delete a specific job.
    
        Args:
            job_id: ID of the job to cancel
    
        Returns:
            String containing the response from the job cancellation
        """
        client = ctx.request_context.lifespan_context.client
    
        try:
            response = await client.jobs.cancel_job_async(
                request=CancelJobRequest(job_id=job_id),
            )
            return f"Job canceled successfully: {response.raw_response}"
        except Exception as e:
            return f"Error canceling job: {str(e)}"
  • Import of CancelJobRequest schema used internally by the cancel_job handler for the client API request.
    CancelJobRequest,
  • The @mcp.tool() decorator registers this function as an MCP tool named 'cancel_job'.
    @mcp.tool()
  • Helper function _cancel_job in Firecrawl connector for canceling specific Firecrawl jobs (crawlhtml/llmfulltxt), referenced in tests but not an MCP tool.
    async def _cancel_job(
        job_id: str,
        job_type: Firecrawl_JobType,
    ) -> Dict[str, Any]:
        """Generic function to cancel a Firecrawl job.
    
        Args:
            job_id: ID of the job to cancel
            job_type: Type of job ('crawlhtml' or 'llmtxt')
    
        Returns:
            Dictionary containing the result of the cancellation
        """
        # Get configuration with API key
        config = _prepare_firecrawl_config()
    
        # Check if config contains an error
        if "error" in config:
            return {"error": config["error"]}
    
        # Special case for LLM text generation jobs - not supported
        if job_type == "llmfulltxt":
            return {
                "id": job_id,
                "status": "error",
                "message": (
                    "Cancelling LLM text generation jobs is not supported." " The job must complete."
                ),
                "details": {"status": "error", "reason": "unsupported_operation"},
            }
        else:
            try:
                # Initialize the Firecrawl client
                firecrawl = FirecrawlApp(api_key=config["api_key"])
    
                # Cancel the job
                result = firecrawl.cancel_crawl(job_id)
    
                # Check if the cancellation was successful (result has 'status': 'cancelled')
                is_successful = result.get("status") == "cancelled"
    
                # Return a user-friendly response
                return {
                    "id": job_id,
                    "status": "cancelled" if is_successful else "error",
                    "message": f"Firecrawl {job_type} job cancelled successfully"
                    if is_successful
                    else "Failed to cancel job",
                    "details": result,
                }
            except Exception as e:
                return {"error": f"Error cancelling {job_type} job: {str(e)}"}
Behavior2/5

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

With no annotations, the description carries full burden but only states it 'deletes' a job and returns a response string. It lacks critical behavioral details: whether cancellation is reversible, what happens to associated resources, permission requirements, error conditions (e.g., invalid job_id), or side effects. This is inadequate for a destructive operation.

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 efficiently structured with a clear purpose statement followed by Args and Returns sections. Every sentence earns its place: the first states the action, and the next two clarify input and output without redundancy. It's front-loaded and appropriately sized for a simple tool.

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 1 parameter with 0% schema coverage and an output schema (implied by 'Returns'), the description adds basic parameter semantics but lacks behavioral context for a destructive tool. It's minimally viable but has clear gaps in usage guidelines and transparency, making it incomplete for safe agent operation.

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?

Schema description coverage is 0%, but the description explicitly documents the single parameter 'job_id' with its purpose ('ID of the job to cancel'), adding essential meaning beyond the bare schema. Since there's only one parameter, this nearly compensates for the coverage gap, though format examples (e.g., numeric vs. string) would improve it.

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

Purpose4/5

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

The description clearly states the verb 'Delete' and the resource 'a specific job', making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'delete_workflow' or 'delete_source_connector' which also delete resources, nor does it clarify what type of job this refers to in the context of the server.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., job must be running), exclusions (e.g., cannot cancel completed jobs), or relationships to siblings like 'check_crawlhtml_status' or 'list_jobs' that might help select jobs to cancel.

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/Unstructured-IO/UNS-MCP'

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