Skip to main content
Glama

list_my_hives

Retrieve your project hives with details including project names, IDs, and entry counts from the Hivemind MCP knowledge base.

Instructions

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYesUser ID to list hives for
project_pathNoOptional: Project directory path (for local storage)

Implementation Reference

  • Tool schema definition: input validation schema, description, and triggers for the list_my_hives MCP tool.
    {
      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"],
      },
    },
  • MCP server tool handler: switch case that calls listMyHives function and returns JSON response.
    case "list_my_hives": {
      const result = await listMyHives(
        args?.user_id as string,
        args?.project_path as string | undefined
      );
      return {
        content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
      };
    }
  • Core implementation of listMyHives: handles local/cloud storage, calls Supabase public API endpoint for cloud hives listing.
    export async function listMyHives(
      userId: string,
      projectPath?: string
    ): Promise<{
      success: boolean;
      hives: Array<{ project_id: string; project_name: string; entry_count: number }>;
    }> {
      // Check if local storage
      if (userId.startsWith('local-')) {
        // For local storage, would need to scan filesystem for .hive.json files
        // Not implemented yet - return empty for now
        return {
          success: true,
          hives: []
        };
      }
    
      // Cloud storage - use API
      const response = await fetch(`${API_BASE}/list-my-hives`, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          user_id: userId
        }),
      });
    
      if (!response.ok) {
        throw new Error(`List hives failed: ${response.statusText}`);
      }
    
      return response.json();
    }
  • Backend Supabase edge function handler: queries knowledge_entries table, groups by project_id, counts entries per hive for the user.
    async function handleListMyHives(supabase: any, body: any, corsHeaders: any) {
      const { user_id } = body;
    
      if (!user_id) {
        return new Response(JSON.stringify({ error: 'user_id required' }), {
          status: 400,
          headers: { ...corsHeaders, 'Content-Type': 'application/json' }
        });
      }
    
      // Query to get all projects for this user with entry counts
      const { data, error } = await supabase
        .from('knowledge_entries')
        .select('project_id, project_name')
        .eq('user_id', user_id)
        .not('project_id', 'is', null);
    
      if (error) {
        console.error('List hives error:', error);
        return new Response(JSON.stringify({
          success: false,
          error: error.message || 'Failed to list hives'
        }), {
          status: 500,
          headers: { ...corsHeaders, 'Content-Type': 'application/json' }
        });
      }
    
      // Group by project_id and count entries
      const projectMap = new Map<string, { project_name: string; count: number }>();
    
      for (const entry of data || []) {
        const key = entry.project_id;
        if (!projectMap.has(key)) {
          projectMap.set(key, { project_name: entry.project_name, count: 0 });
        }
        projectMap.get(key)!.count++;
      }
    
      // Convert to array
      const hives = Array.from(projectMap.entries()).map(([project_id, info]) => ({
        project_id,
        project_name: info.project_name,
        entry_count: info.count
      }));
    
      return new Response(JSON.stringify({
        success: true,
        hives,
        _ctx: "Each hive = separate project brain. Bigger hives = faster development on that project."
      }), {
        headers: { ...corsHeaders, 'Content-Type': 'application/json' }
      });
    }
  • Supabase public gateway endpoint registration: routes POST /list-my-hives to handleListMyHives function.
    case 'list-my-hives':
      return await handleListMyHives(supabase, body, corsHeaders);

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