decline_thread
Cancel or decline a conversation thread on the402.ai marketplace. Agents or providers can use this to stop ongoing service requests, with potential refunds if work hasn't begun.
Instructions
Cancel or decline a thread on the402.ai. Either the agent or provider can use this. If payment was made and work hasn't started, a refund may be issued. Requires API key.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| thread_id | Yes | The thread ID to decline/cancel | |
| reason | No | Optional reason for declining |
Implementation Reference
- src/tools/threads.ts:167-187 (handler)The `decline_thread` tool is defined here using `server.tool` in `src/tools/threads.ts`. It registers the tool with the MCP server, defines its schema, and implements the handler logic which makes a POST request to the `/v1/threads/{thread_id}/decline` endpoint.
server.tool( "decline_thread", "Cancel or decline a thread on the402.ai. Either the agent or provider can use this. If payment was made and work hasn't started, a refund may be issued. Requires API key.", { thread_id: z.string().describe("The thread ID to decline/cancel"), reason: z.string().optional().describe("Optional reason for declining"), }, async ({ thread_id, reason }) => { const body: Record<string, unknown> = {}; if (reason) body.reason = reason; const result = await client.authPost( `/v1/threads/${thread_id}/decline`, body ); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } );