cancel_bounty
Cancel a draft bounty that has not been funded. Use this tool to remove an unfunded draft from the marketplace.
Instructions
Cancels an unfunded draft. Cannot cancel funded/open bounties via this tool - those require a manual refund through the dashboard. Requires TASKBOUNTY_API_KEY.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes | The draft task id to cancel. |
Implementation Reference
- src/index.ts:256-267 (registration)Tool registration and input schema for cancel_bounty. Defines the tool name, description, and that it requires a task_id (draft task id).
{ name: "cancel_bounty", description: "Cancels an unfunded draft. Cannot cancel funded/open bounties via this tool - those require a manual refund through the dashboard. Requires TASKBOUNTY_API_KEY.", inputSchema: { type: "object", properties: { task_id: { type: "string", description: "The draft task id to cancel." }, }, required: ["task_id"], }, }, - src/index.ts:441-454 (handler)Handler for cancel_bounty. Extracts task_id from arguments, validates it's present, then makes an authenticated POST request to /tasks/{taskId}/cancel to cancel the draft bounty.
case "cancel_bounty": { const taskId = String(a.task_id ?? ""); if (!taskId) { return { content: [{ type: "text", text: "task_id is required" }], isError: true, }; } return await tbFetch(`/tasks/${encodeURIComponent(taskId)}/cancel`, { method: "POST", body: JSON.stringify({}), requireAuth: true, }); } - src/index.ts:23-77 (helper)Helper function tbFetch used to make all authenticated API calls to the TaskBounty API, including the cancel_bounty handler.
async function tbFetch( path: string, init: RequestInit & { requireAuth?: boolean } = {}, ): Promise<ToolResult> { const { requireAuth, headers, ...rest } = init; if (requireAuth && !API_KEY) { return { content: [ { type: "text", text: "Missing TASKBOUNTY_API_KEY environment variable. Set it to your tb_live_* key from https://www.task-bounty.com/dashboard/api-keys.", }, ], isError: true, }; } const url = `${API_BASE}${path}`; const finalHeaders: Record<string, string> = { Accept: "application/json", ...(headers as Record<string, string> | undefined), }; if (API_KEY) finalHeaders["Authorization"] = `Bearer ${API_KEY}`; if (rest.body && !finalHeaders["Content-Type"]) { finalHeaders["Content-Type"] = "application/json"; } let res: Response; try { res = await fetch(url, { ...rest, headers: finalHeaders }); } catch (err) { return { content: [ { type: "text", text: `Network error calling ${url}: ${err instanceof Error ? err.message : String(err)}`, }, ], isError: true, }; } const text = await res.text(); if (!res.ok) { return { content: [ { type: "text", text: `HTTP ${res.status} ${res.statusText} from ${url}\n\n${text}`, }, ], isError: true, }; } return { content: [{ type: "text", text }] }; }