Skip to main content
Glama

delete_hive

Remove a project's knowledge base and all associated entries from Hivemind MCP to start fresh or completely delete project data.

Instructions

Delete project hive and all associated knowledge entries. Use this to start fresh or remove a project's knowledge base completely.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idNoOptional: User ID (auto-detected from .user_id in cwd if not provided)
project_idYesProject identifier to delete
project_pathNoOptional: Project directory path (required for local storage)

Implementation Reference

  • Main MCP tool handler: deleteHive function implements the core logic. Supports both local storage (deletes .hive.json and .user_id files) and cloud storage (calls Supabase edge function API). Auto-detects user_id from project directory.
    export async function deleteHive( userId: string | null, projectId: string, projectPath?: string ): Promise<DeleteHiveResult> { // Auto-detect user_id if not provided if (!userId) { userId = await getUserId(projectPath); if (!userId) { throw new Error('No .user_id file found. Run init_hive first.'); } } // Check if local storage if (userId.startsWith('local-') && projectPath) { const fs = await import('fs/promises'); const path = await import('path'); const hivePath = path.join(projectPath, '.hive.json'); const userIdPath = path.join(projectPath, '.user_id'); try { // Read hive to count entries before deleting const hive = await readLocalHive(projectPath); const deletedEntries = hive?.entries.length || 0; // Delete both .hive.json and .user_id files await fs.unlink(hivePath).catch(() => {}); await fs.unlink(userIdPath).catch(() => {}); return { success: true, deleted_entries: deletedEntries, message: 'Hive deleted. All knowledge entries removed.', user_deleted: false }; } catch (error) { throw new Error(`Failed to delete local hive: ${error}`); } } // Cloud storage const response = await fetch(`${API_BASE}/delete-hive`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: userId, project_id: projectId }), }); if (!response.ok) { throw new Error(`Delete hive failed: ${response.statusText}`); } return response.json(); }
  • Input schema definition for the delete_hive tool, specifying parameters: project_id (required), user_id and project_path (optional). Part of the tool registry returned by ListTools.
    { name: "delete_hive", description: "Delete project hive and all associated knowledge entries. Use this to start fresh or remove a project's knowledge base completely.", inputSchema: { type: "object", properties: { user_id: { type: "string", description: "Optional: User ID (auto-detected from .user_id in cwd if not provided)", }, project_id: { type: "string", description: "Project identifier to delete", }, project_path: { type: "string", description: "Optional: Project directory path (required for local storage)", }, }, required: ["project_id"], }, },
  • MCP CallToolRequest handler dispatch: switch case for 'delete_hive' invokes the deleteHive implementation from api.ts and returns JSON response.
    case "delete_hive": { const result = await deleteHive( args?.user_id as string, args?.project_id as string, args?.project_path as string | undefined ); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
  • src/index.ts:23-352 (registration)
    Tool registration: ListToolsRequest handler returns array of available tools including delete_hive with its schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "search_kb", description: "Search the hivemind knowledge base for troubleshooting solutions, error fixes, and best practices. Returns ranked solutions with success rates.", inputSchema: { type: "object", properties: { query: { type: "string", description: "Error message, problem description, or technology to search for.", }, }, required: ["query"], }, }, { name: "report_outcome", description: "Report whether a solution worked or not. Helps improve solution rankings.", inputSchema: { type: "object", properties: { solution_id: { type: "number", description: "The ID of the solution from search results.", }, outcome: { type: "string", enum: ["success", "failure"], description: "Did the solution work?", }, }, required: ["outcome"], }, }, { name: "contribute_solution", description: "Submit a new solution to the hivemind knowledge base.", inputSchema: { type: "object", properties: { query: { type: "string", description: "The error message or problem this solution solves.", }, solution: { type: "string", description: "The solution that worked.", }, category: { type: "string", description: "Category: mcp-troubleshooting, web-automation, security, etc.", }, }, required: ["query", "solution"], }, }, { name: "search_skills", description: "Search for skills by topic/keyword. Returns lightweight summaries - use get_skill() for full details.", inputSchema: { type: "object", properties: { query: { type: "string", description: "Topic or keyword to search for (e.g., 'deployment', 'testing', 'CI/CD')", }, }, required: ["query"], }, }, { name: "get_skill", description: "Get detailed information about a specific skill including full instructions and executable steps.", inputSchema: { type: "object", properties: { skill_id: { type: "number", description: "The ID of the skill to retrieve", }, }, required: ["skill_id"], }, }, { name: "count_skills", description: "Get total count of skills in the database.", inputSchema: { type: "object", properties: {}, }, }, { name: "init_project_kb", description: "Initialize a project-specific knowledge base with cloud storage. Returns user_id to store for future contributions. Cloud storage users get 10x rate limits (1000/hour vs 100/hour).", inputSchema: { type: "object", properties: { project_id: { type: "string", description: "Unique project identifier (e.g., 'hivemind-mcp', 'my-app')", }, project_name: { type: "string", description: "Human-readable project name", }, storage_type: { type: "string", enum: ["cloud", "local"], description: "Storage type: 'cloud' (10x limits) or 'local' (default limits)", }, }, required: ["project_id", "project_name"], }, }, { name: "contribute_project", description: "Add knowledge to project hive. TRIGGERS: 'add to hive', 'update hive', 'contribute to hive', 'store in hive'. When user says 'update hive', analyze recent work and contribute automatically. When user says 'add to hive', ask what they want to store. Stores solutions, patterns, pitfalls, architecture decisions, etc. Private by default, optionally public. Categories are dynamic - user can create any category name.", inputSchema: { type: "object", properties: { user_id: { type: "string", description: "Optional: User ID (auto-detected from .user_id in cwd if not provided)", }, project_id: { type: "string", description: "Project identifier", }, query: { type: "string", description: "Error message or problem description", }, solution: { type: "string", description: "What fixed it", }, category: { type: "string", description: "Optional category (auto-detected if not provided)", }, is_public: { type: "boolean", description: "Make this entry public (default: false/private)", }, project_path: { type: "string", description: "Optional: Project directory path (required for local storage)", }, }, required: ["project_id", "query", "solution"], }, }, { name: "search_project", description: "Search project hive for knowledge. TRIGGERS: 'search my hive for [topic]', 'search hive [query]', 'find in hive [topic]', 'what does my hive know about [topic]'. Searches your private entries + optionally public entries. Returns relevant solutions, patterns, architecture decisions, etc.", inputSchema: { type: "object", properties: { user_id: { type: "string", description: "Optional: User ID (auto-detected from .user_id in cwd if not provided)", }, query: { type: "string", description: "Search query", }, project_id: { type: "string", description: "Optional: limit to specific project", }, include_public: { type: "boolean", description: "Include public entries in results (default: true)", }, project_path: { type: "string", description: "Optional: Project directory path (required for local storage)", }, }, required: ["query"], }, }, { name: "init_hive", description: "Create a new project hive (knowledge base). TRIGGERS: 'create a new hive', 'start a hive', 'initialize hive'. Onboarding flow: First call checks if user ever used Hivemind before. If first time, asks 'Is this your first time using Claude Code?' If yes, creates CLAUDE.md with starter config. Then guides through storage choice (cloud/local). If no project_path provided, creates empty hive with starter categories. IMPORTANT: Display the 'message' field to the user EXACTLY as returned - do not condense, reformat, or summarize it.", inputSchema: { type: "object", properties: { project_id: { type: "string", description: "Project identifier (e.g., from package.json name or directory)", }, project_name: { type: "string", description: "Human-readable project name", }, is_first_time_user: { type: "boolean", description: "Answer to 'Is this your first time using Claude Code?' (only used when onboarding flag not set)", }, storage_choice: { type: "string", enum: ["cloud", "local"], description: "User's storage choice (omit on first call to get options)", }, project_path: { type: "string", description: "Optional: Absolute path to project directory (for scanning). If not provided, creates empty hive with starter categories only.", }, }, required: ["project_id", "project_name"], }, }, { name: "delete_hive", description: "Delete project hive and all associated knowledge entries. Use this to start fresh or remove a project's knowledge base completely.", inputSchema: { type: "object", properties: { user_id: { type: "string", description: "Optional: User ID (auto-detected from .user_id in cwd if not provided)", }, project_id: { type: "string", description: "Project identifier to delete", }, project_path: { type: "string", description: "Optional: Project directory path (required for local storage)", }, }, required: ["project_id"], }, }, { name: "get_hive_overview", description: "Get overview of project hive including total entries, category breakdown, and recent additions. Use when user says 'show me my hive' or 'hive overview'.", inputSchema: { type: "object", properties: { user_id: { type: "string", description: "Optional: User ID (auto-detected from .user_id in cwd if not provided)", }, project_id: { type: "string", description: "Project identifier", }, project_path: { type: "string", description: "Optional: Project directory path (required for local storage)", }, }, required: ["project_id"], }, }, { name: "update_project_entry", description: "Update an existing project hive entry. Can edit query, solution, or category. Only works for project entries (not global hivemind KB).", inputSchema: { type: "object", properties: { user_id: { type: "string", description: "Optional: User ID (auto-detected from .user_id in cwd if not provided)", }, entry_id: { type: "number", description: "ID of the entry to update (from search results)", }, query: { type: "string", description: "Optional: New query text", }, solution: { type: "string", description: "Optional: New solution text", }, category: { type: "string", description: "Optional: New category name", }, project_path: { type: "string", description: "Optional: Project directory path (required for local storage)", }, }, required: ["entry_id"], }, }, { name: "list_my_hives", description: "List all project hives for a user. TRIGGERS: 'show me my hives', 'list my hives', 'what hives do I have', 'all my hives'. Returns project_id, project_name, and entry count for each hive. For local storage, searches current directory for .user_id files.", inputSchema: { type: "object", properties: { user_id: { type: "string", description: "User ID to list hives for", }, project_path: { type: "string", description: "Optional: Project directory path (for local storage)", }, }, required: ["user_id"], }, }, ], }; });
  • Cloud backend handler: handleDeleteHive deletes all knowledge_entries for user_id and project_id from Supabase database, cleans up contributor_tiers if no other projects, returns count of deleted entries.
    async function handleDeleteHive(supabase: any, body: any, corsHeaders: any) { const { user_id, project_id } = body; if (!user_id || !project_id) { return new Response(JSON.stringify({ error: 'user_id and project_id required' }), { status: 400, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }); } // Count entries before deletion const { count: entriesCount } = await supabase .from('knowledge_entries') .select('*', { count: 'exact', head: true }) .eq('user_id', user_id) .eq('project_id', project_id); // Delete all project entries const { error: deleteError } = await supabase .from('knowledge_entries') .delete() .eq('user_id', user_id) .eq('project_id', project_id); if (deleteError) { console.error('Delete entries error:', deleteError); return new Response(JSON.stringify({ success: false, error: 'Failed to delete project entries' }), { status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }); } // Check if user has any other projects const { count: otherProjectsCount } = await supabase .from('knowledge_entries') .select('*', { count: 'exact', head: true }) .eq('user_id', user_id); // If no other projects, delete user from contributor_tiers if (otherProjectsCount === 0) { await supabase .from('contributor_tiers') .delete() .eq('user_id', user_id); } return new Response(JSON.stringify({ success: true, deleted_entries: entriesCount || 0, message: `Deleted ${entriesCount || 0} entries for ${project_id}${otherProjectsCount === 0 ? '. User tier removed.' : ''}`, user_deleted: otherProjectsCount === 0, _ctx: "Hive deleted. All project knowledge removed from this workspace." }), { headers: { ...corsHeaders, 'Content-Type': 'application/json' } }); }

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/Kevthetech143/hivemind-mcp'

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