get_job
Get the current state of a public Job: status, budget, transactions, evaluation outcome. No authentication required.
Instructions
Get the current state of a Job (status, budget, transactions, evaluation outcome). No authentication required — Job state is public.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| jobId | Yes | Job ID (job_...) |
Implementation Reference
- src/index.ts:305-320 (registration)Registration of the 'get_job' tool using server.tool() on the MCP server, with description and schema.
server.tool( "get_job", "Get the current state of a Job (status, budget, transactions, evaluation outcome). No authentication required — Job state is public.", { jobId: z.string().describe("Job ID (job_...)"), }, async ({ jobId }) => { try { const res = await callApi("GET", `/jobs/${jobId}`, undefined, false); if (!res.ok) return errorResponse("Get job failed", res); return successResponse(res.json); } catch (e) { return { content: [{ type: "text" as const, text: `Get job error: ${e}` }], isError: true }; } }, ); - src/index.ts:308-310 (schema)Input schema requiring a single 'jobId' string parameter validated by Zod (z.string()).
{ jobId: z.string().describe("Job ID (job_...)"), }, - src/index.ts:311-319 (handler)Handler function that calls the API GET /jobs/{jobId} (no auth), returns formatted success/error response.
async ({ jobId }) => { try { const res = await callApi("GET", `/jobs/${jobId}`, undefined, false); if (!res.ok) return errorResponse("Get job failed", res); return successResponse(res.json); } catch (e) { return { content: [{ type: "text" as const, text: `Get job error: ${e}` }], isError: true }; } }, - src/index.ts:33-62 (helper)callApi helper used by the handler to make HTTP requests to the CardZero API.
async function callApi( method: "GET" | "POST", path: string, body?: Record<string, unknown>, auth = true, ): Promise<ApiResult> { if (auth && !API_KEY) { return { ok: false, status: 401, json: { error: "config_missing", message: "CARDZERO_API_KEY is not set. Get one at https://cardzero.ai", }, }; } const headers: Record<string, string> = {}; if (auth) headers["Authorization"] = `Bearer ${API_KEY}`; if (body) headers["Content-Type"] = "application/json"; const res = await fetch(`${API_URL}${path}`, { method, headers, body: body ? JSON.stringify(body) : undefined, }); const json = await res.json() as Record<string, unknown>; return { ok: res.ok, status: res.status, json }; } - src/index.ts:76-89 (helper)successResponse and errorResponse helper functions used to format tool output.
function errorResponse(label: string, result: ApiResult) { const code = result.json.error || result.status; const msg = result.json.message || "Unknown error"; return { content: [{ type: "text" as const, text: `${label}: [${code}] ${msg}` }], isError: true, }; } function successResponse(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; }