get-job-status
Check the status of an asynchronous serverless job. Returns current status and output when complete. Supports statuses: IN_QUEUE, IN_PROGRESS, COMPLETED, FAILED, CANCELLED, TIMED_OUT.
Instructions
Check the status of an asynchronous Serverless job. Returns the current status and output when complete. Job statuses: IN_QUEUE, IN_PROGRESS, COMPLETED, FAILED, CANCELLED, TIMED_OUT.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endpointId | Yes | ID of the Serverless endpoint the job belongs to | |
| jobId | Yes | ID of the job to check |
Implementation Reference
- src/index.ts:868-891 (registration)Registration of the 'get-job-status' tool with its description and input schema (endpointId + jobId).
// Get Job Status server.tool( 'get-job-status', 'Check the status of an asynchronous Serverless job. Returns the current status and output when complete. Job statuses: IN_QUEUE, IN_PROGRESS, COMPLETED, FAILED, CANCELLED, TIMED_OUT.', { endpointId: endpointIdSchema.describe('ID of the Serverless endpoint the job belongs to'), jobId: jobIdSchema.describe('ID of the job to check'), }, async (params) => { const result = await serverlessRequest( params.endpointId, `/status/${params.jobId}` ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } ); - src/index.ts:876-891 (handler)Handler function that calls serverlessRequest to GET /status/{jobId} and returns the JSON result.
async (params) => { const result = await serverlessRequest( params.endpointId, `/status/${params.jobId}` ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } ); - src/index.ts:751-753 (schema)Zod schema for jobId validation (alphanumeric string with hyphens/underscores).
const jobIdSchema = z .string() .regex(/^[a-zA-Z0-9_-]+$/, 'Invalid job ID format'); - src/index.ts:747-749 (schema)Zod schema for endpointId validation (alphanumeric string with hyphens/underscores).
const endpointIdSchema = z .string() .regex(/^[a-zA-Z0-9_-]+$/, 'Invalid endpoint ID format'); - src/index.ts:277-318 (helper)Helper function serverlessRequest that makes authenticated HTTP requests to the RunPod Serverless API (base URL: https://api.runpod.ai/v2). Used by get-job-status to call GET /status/{jobId}.
async function serverlessRequest( endpointId: string, path: string, method: string = 'GET', body?: Record<string, unknown> ) { const url = `${SERVERLESS_API_BASE_URL}/${endpointId}${path}`; const headers: Record<string, string> = { Authorization: `Bearer ${API_KEY}`, 'Content-Type': 'application/json', }; const options: NodeFetchRequestInit = { method, headers, }; if (body && (method === 'POST' || method === 'PATCH')) { options.body = JSON.stringify(body); } try { const response = await fetch(url, options); if (!response.ok) { const errorText = await response.text(); throw new Error( `RunPod Serverless API Error: ${response.status} - ${errorText}` ); } const contentType = response.headers.get('content-type'); if (contentType && contentType.includes('application/json')) { return await response.json(); } return { success: true, status: response.status }; } catch (error) { console.error('Error calling RunPod Serverless API:', error); throw error; } }