delete_function
Remove a deployed function from a project by specifying the project ID and function name. This tool helps manage serverless infrastructure by deleting functions no longer needed.
Instructions
Delete a deployed function from a project.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | The project ID | |
| name | Yes | Function name to delete |
Implementation Reference
- src/tools/delete-function.ts:11-38 (handler)The handleDeleteFunction async function implements the delete_function tool. It validates the project exists via getProject(), makes a DELETE API request to /admin/v1/projects/{project_id}/functions/{name}, and returns a success message or error.
export async function handleDeleteFunction(args: { project_id: string; name: string; }): Promise<{ content: Array<{ type: "text"; text: string }>; isError?: boolean }> { const project = getProject(args.project_id); if (!project) return projectNotFound(args.project_id); const res = await apiRequest( `/admin/v1/projects/${args.project_id}/functions/${encodeURIComponent(args.name)}`, { method: "DELETE", headers: { Authorization: `Bearer ${project.service_key}`, }, }, ); if (!res.ok) return formatApiError(res, "deleting function"); return { content: [ { type: "text", text: `Function \`${args.name}\` deleted from project \`${args.project_id}\`.`, }, ], }; } - src/tools/delete-function.ts:6-9 (schema)The deleteFunctionSchema defines the input validation using Zod: project_id (string) and name (string) for the function to delete.
export const deleteFunctionSchema = { project_id: z.string().describe("The project ID"), name: z.string().describe("Function name to delete"), }; - src/index.ts:167-172 (registration)Registration of the delete_function tool with the MCP server, providing the tool name, description, schema, and handler function.
server.tool( "delete_function", "Delete a deployed function from a project.", deleteFunctionSchema, async (args) => handleDeleteFunction(args), );