cancelDeployment
Stop an active deployment by specifying the deployment ID using this tool. It ensures resource efficiency and prevents unnecessary processes by halting deployments in progress.
Instructions
Cancels a deployment
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deploymentId | Yes | The ID of the deployment to cancel | |
| slug | No | Slug | |
| teamId | No | Team ID |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"deploymentId": {
"description": "The ID of the deployment to cancel",
"type": "string"
},
"slug": {
"description": "Slug",
"type": "string"
},
"teamId": {
"description": "Team ID",
"type": "string"
}
},
"required": [
"deploymentId"
],
"type": "object"
}
Implementation Reference
- src/index.ts:147-172 (handler)The MCP tool handler function for 'cancelDeployment'. It constructs the environment with API key, calls the cancelDeployment helper, and returns the result or error in MCP format.async ({ deploymentId, ...options }) => { try { const env = { VERCEL_API_TOKEN: apiKey } const result = await cancelDeployment(env, deploymentId, options) return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] } } catch (error: unknown) { console.error("Error canceling deployment:", error) const errorMessage = error instanceof Error ? error.message : String(error) return { content: [ { type: "text", text: `Error canceling deployment: ${errorMessage}` } ] } } }
- src/index.ts:143-146 (schema)Zod input schema defining parameters for the cancelDeployment tool: deploymentId (required), teamId and slug (optional).deploymentId: z.string().describe("The ID of the deployment to cancel"), teamId: z.string().optional().describe("Team ID"), slug: z.string().optional().describe("Slug") },
- src/index.ts:139-173 (registration)Registration of the 'cancelDeployment' tool on the MCP server, including name, description, input schema, and handler function.server.tool( "cancelDeployment", "Cancels a deployment", { deploymentId: z.string().describe("The ID of the deployment to cancel"), teamId: z.string().optional().describe("Team ID"), slug: z.string().optional().describe("Slug") }, async ({ deploymentId, ...options }) => { try { const env = { VERCEL_API_TOKEN: apiKey } const result = await cancelDeployment(env, deploymentId, options) return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] } } catch (error: unknown) { console.error("Error canceling deployment:", error) const errorMessage = error instanceof Error ? error.message : String(error) return { content: [ { type: "text", text: `Error canceling deployment: ${errorMessage}` } ] } } } )
- src/vercel/deployments.ts:99-117 (helper)Helper function that initializes the Vercel SDK client using the API token and calls the SDK's cancelDeployment method, wrapping the response with MCPResponse.export async function cancelDeployment( env: Env, deploymentId: string, options?: { teamId?: string slug?: string } ) { const vercel = new Vercel({ bearerToken: env.VERCEL_API_TOKEN }) const response = await vercel.deployments.cancelDeployment({ id: deploymentId, ...options }) return MCPResponse(response) }