Skip to main content
Glama

Delete Project

delete_project

Permanently remove a project and all associated content, including knowledge files and TODOs, from the Knowledge MCP Server. Confirm project ID, back up data if needed, and ensure user approval before irreversible deletion.

Instructions

Permanently delete a project and all its content - USE WITH EXTREME CAUTION.

When to use this tool:

  • Project is completely obsolete

  • Cleaning up test or temporary projects

  • Project has been migrated elsewhere

  • Explicit user request to delete

Key features:

  • Removes entire project directory

  • Deletes from index

  • IRREVERSIBLE operation

  • Includes all knowledge files and TODOs

You should:

  1. ALWAYS confirm with user before deletion

  2. Verify project_id is correct

  3. Consider backing up important content first

  4. Understand this is permanent

  5. Check if project has valuable knowledge files

  6. Document reason for deletion

DO NOT use when:

  • Any doubt about deletion

  • Project might be needed later

  • Haven't backed up important content

  • User hasn't explicitly confirmed

⚠️ This action CANNOT be undone! Returns: {success: bool, project_id: str, message: str, error?: str}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesThe project identifier to delete

Implementation Reference

  • Primary asynchronous handler for delete_project tool execution. Deletes project directory using helper, commits changes, handles errors, and formats MCP response.
    async deleteProjectAsync(params: z.infer<typeof secureProjectIdSchema>): Promise<string> {
      const context = this.createContext('delete_project', { project_id: params });
    
      try {
        const project_id = params;
    
        // Use the async utility function to delete the project
        await deleteProjectDirectoryAsync(this.storagePath, project_id);
    
        // Auto-commit the deletion
        await autoCommitAsync(this.storagePath, `Delete project: ${project_id}`);
    
        const result = {
          project_id,
          message: `Project '${project_id}' successfully deleted`,
        };
    
        await this.logSuccessAsync('delete_project', { project_id }, context);
        return this.formatSuccessResponse(result);
      } catch (error) {
        const mcpError =
          error instanceof Error && error.message.includes('not found')
            ? new MCPError(MCPErrorCode.PROJECT_NOT_FOUND, `Project '${params}' not found`, {
                project_id: params,
                traceId: context.traceId,
              })
            : new MCPError(
                MCPErrorCode.PROJECT_DELETE_FAILED,
                `Failed to delete project '${params}': ${error instanceof Error ? error.message : String(error)}`,
                {
                  project_id: params,
                  traceId: context.traceId,
                  originalError: error,
                }
              );
    
        await this.logErrorAsync('delete_project', { project_id: params }, mcpError, context);
        return this.formatErrorResponse(mcpError, context);
      }
    }
  • MCP server registration of the delete_project tool, defining input schema, description, and handler wiring.
    server.registerTool(
      'delete_project',
      {
        title: 'Delete Project',
        description: TOOL_DESCRIPTIONS.delete_project,
        inputSchema: {
          project_id: secureProjectIdSchema.describe('The project identifier to delete'),
        },
      },
      async ({ project_id }) => {
        const result = await projectHandler.deleteProjectAsync(project_id);
        return {
          content: [
            {
              type: 'text',
              text: result,
            },
          ],
        };
      }
    );
  • Zod schema defining secure validation for project_id input parameter used across project tools.
    export const secureProjectIdSchema = z
      .string()
      .min(1, 'Project ID cannot be empty')
      .max(100, 'Project ID too long')
      .refine(
        (val) => !val.includes('..') && !val.startsWith('.') && !val.endsWith('.'),
        'Project ID cannot contain path traversal patterns'
      )
      .refine(
        (val) => !/[/\\:*?"<>|\0]/.test(val),
        'Project ID cannot contain filesystem reserved characters or null bytes'
      )
      .refine((val) => val.trim() === val, 'Project ID cannot have leading/trailing spaces');
  • Core asynchronous utility function that physically deletes the project directory and removes entry from the project index.
    export async function deleteProjectDirectoryAsync(
      storagePath: string,
      projectId: string
    ): Promise<void> {
      const index = await readProjectIndexAsync(storagePath);
    
      // Check if project exists in index
      if (!(projectId in index)) {
        throw new Error(`Project '${projectId}' not found in index`);
      }
    
      const dirName = index[projectId];
      const projectPath = join(storagePath, 'projects', dirName);
    
      // Delete directory if it exists
      try {
        await access(projectPath);
        await rm(projectPath, { recursive: true, force: true });
      } catch (error) {
        // Directory doesn't exist, continue with index cleanup
        if (error && typeof error === 'object' && 'code' in error && error.code !== 'ENOENT') {
          throw error;
        }
      }
    
      // Remove from index
      const { [projectId]: _removed, ...newIndex } = index;
      await writeProjectIndexAsync(storagePath, newIndex);
    }
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and excels. It discloses critical behavioral traits: 'IRREVERSIBLE operation', 'Permanently delete', 'This action CANNOT be undone', and details what gets destroyed (project directory, index, knowledge files, TODOs). It also includes safety guidance like requiring user confirmation and backup considerations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (warning, usage guidelines, features, action items, exclusions) and every sentence earns its place. It's appropriately sized for a high-risk operation, though slightly verbose with numbered lists that could be more concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with no annotations and no output schema, the description provides exceptional completeness. It covers purpose, usage scenarios, behavioral consequences, safety protocols, exclusions, and even specifies the return format despite no output schema. This fully compensates for the lack of structured metadata.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with one parameter clearly documented. The description adds meaningful context beyond the schema by emphasizing 'Verify project_id is correct' and linking it to the irreversible nature of the operation. However, it doesn't provide additional format or validation details beyond what the schema already specifies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states 'Permanently delete a project and all its content' - a specific verb ('delete') with clear resource ('project and all its content'). It distinguishes from sibling tools like delete_knowledge_file and delete_todo by specifying it removes the entire project directory, index, knowledge files, and TODOs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit 'When to use this tool' with four specific scenarios and 'DO NOT use when' with four clear exclusions. It offers comprehensive guidance on when to choose this tool versus alternatives like backup or confirmation steps.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/sven-borkert/knowledge-mcp'

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