list_jobs
Retrieve and filter job listings in the Unstructured API by workflow ID or status. Simplify job management and monitoring by accessing relevant job data efficiently.
Instructions
List jobs via the Unstructured API.
Args:
workflow_id: Optional workflow ID to filter by
status: Optional job status to filter by
Returns:
String containing the list of jobs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | ||
| workflow_id | No |
Implementation Reference
- uns_mcp/server.py:464-507 (handler)The main handler function for the 'list_jobs' MCP tool. It uses the UnstructuredClient to fetch jobs optionally filtered by workflow_id and status, sorts them by creation time, and formats a list of job IDs for output.@mcp.tool() async def list_jobs( ctx: Context, workflow_id: Optional[str] = None, status: Optional[JobStatus | str] = None, ) -> str: """ List jobs via the Unstructured API. Args: workflow_id: Optional workflow ID to filter by status: Optional job status to filter by Returns: String containing the list of jobs """ client = ctx.request_context.lifespan_context.client request = ListJobsRequest(workflow_id=workflow_id, status=status) if status: try: status = JobStatus(status) if isinstance(status, str) else status request.status = status except KeyError: return f"Invalid job status: {status}" response = await client.jobs.list_jobs_async(request=request) # Sort jobs by name sorted_jobs = sorted( response.response_list_jobs, key=lambda job: job.created_at, ) if not sorted_jobs: return "No Jobs found" # Format response result = ["Available Jobs by created time:"] for job in sorted_jobs: result.append(f"- JOB ID: {job.id}") return "\n".join(result)
- uns_mcp/server.py:21-35 (schema)Imports from unstructured_client.models.operations including ListJobsRequest, which defines the request schema used internally by the list_jobs handler.from unstructured_client.models.operations import ( CancelJobRequest, CreateWorkflowRequest, DeleteWorkflowRequest, GetDestinationRequest, GetJobRequest, GetSourceRequest, GetWorkflowRequest, ListDestinationsRequest, ListJobsRequest, ListSourcesRequest, ListWorkflowsRequest, RunWorkflowRequest, UpdateWorkflowRequest, )
- uns_mcp/server.py:464-464 (registration)The @mcp.tool() decorator registers the list_jobs function as an MCP tool.@mcp.tool()