Skip to main content
Glama

deleteProject

Remove a specific project from the DeepWriter MCP Server by providing the project ID and API key for secure deletion.

Instructions

Delete a project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
api_keyYesThe DeepWriter API key for authentication.
project_idYesThe ID of the project to delete.

Implementation Reference

  • The primary handler for the 'deleteProject' MCP tool. This function executes the tool logic: validates inputs, retrieves API key from env, calls the DeepWriter API client to delete the project, transforms the response to MCP format, and handles errors.
    export const deleteProjectTool = {
      name: "deleteProject",
      description: "Delete a project",
      // TODO: Add input/output schema validation if needed
      async execute(args: DeleteProjectInputArgs): Promise<DeleteProjectMcpOutput> {
        console.error(`Executing deleteProject tool for project ID: ${args.project_id}...`);
    
        // Get API key from environment
        const apiKey = process.env.DEEPWRITER_API_KEY;
        if (!apiKey) {
          throw new Error("DEEPWRITER_API_KEY environment variable is required");
        }
        if (!args.project_id) {
          throw new Error("Missing required argument: project_id");
        }
    
        try {
          // Call the actual API client function
          const apiResponse = await apiClient.deleteProject(apiKey, args.project_id);
          console.error(`API call successful for deleteProject.`);
    
          // Transform the API response into MCP format
          const mcpResponse: DeleteProjectMcpOutput = {
            content: [
              // Use the message from the API response
              { type: 'text', text: apiResponse.message }
            ]
          };
    
          return mcpResponse; // Return the MCP-compliant structure
        } catch (error) {
          console.error(`Error executing deleteProject tool: ${error}`);
          // Format error for MCP response
          const errorMessage = error instanceof Error ? error.message : String(error);
          throw new Error(`Failed to delete project ID ${args.project_id}: ${errorMessage}`);
        }
      }
    };
  • src/index.ts:291-310 (registration)
    Registration of the deleteProject tool with the MCP server. Wraps the tool's execute function, provides Zod input schema validation, and adds annotations indicating it's destructive.
    server.tool(
      deleteProjectTool.name,
      deleteProjectTool.description,
      {
        project_id: z.string().describe("The ID of the project to delete.")
      },
      async ({ project_id }: DeleteProjectParams) => {
        console.error(`SDK invoking ${deleteProjectTool.name}...`);
        const result = await deleteProjectTool.execute({ project_id });
        return {
          content: result.content,
          annotations: {
            title: "Delete Project",
            readOnlyHint: false,
            destructiveHint: true, // This is a destructive operation
            idempotentHint: true, // Deleting already deleted project is safe
            openWorldHint: false
          }
        };
      }
  • TypeScript interfaces defining the input arguments and MCP output structure for the deleteProject tool.
    interface DeleteProjectInputArgs {
      project_id: string;
    }
    
    // Define the MCP-compliant output structure
    interface DeleteProjectMcpOutput {
      content: { type: 'text'; text: string }[];
    }
  • Zod schema for input validation of deleteProject tool parameters, used during MCP server registration.
    const deleteProjectInputSchema = z.object({
      project_id: z.string().describe("The ID of the project to delete.")
    });
  • Helper function in the API client that performs the actual HTTP DELETE request to the DeepWriter API endpoint for deleting a project, including response handling for 204 No Content.
    export interface DeleteProjectResponse {
      message: string; // Success message
    }
    
    export async function deleteProject(apiKey: string, projectId: string): Promise<DeleteProjectResponse> {
      console.error(`Calling actual deleteProject API for project ID: ${projectId}`);
      if (!apiKey) {
        throw new Error("API key is required for deleteProject");
      }
      if (!projectId) {
        throw new Error("Project ID is required for deleteProject");
      }
    
      const endpoint = `/api/deleteProject?projectId=${encodeURIComponent(projectId)}`;
      // Use a temporary type that allows for an empty object from makeApiRequest on 204
      type TempDeleteResponse = DeleteProjectResponse | {};
      const response = await makeApiRequest<TempDeleteResponse>(endpoint, apiKey, 'DELETE');
    
      // If API returns 204 (empty object), construct the standard success message
      if (typeof response === 'object' && Object.keys(response).length === 0) {
          return { message: `Project ${projectId} deleted successfully.` };
      }
      // Otherwise, assume the API returned the expected { message: ... } structure
      return response as DeleteProjectResponse;
    }
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/deepwriter-ai/Deepwriter-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server