Skip to main content
Glama

search_project

Search your project knowledge base for solutions, patterns, and architecture decisions using your private entries and public community knowledge.

Instructions

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idNoOptional: User ID (auto-detected from .user_id in cwd if not provided)
queryYesSearch query
project_idNoOptional: limit to specific project
include_publicNoInclude public entries in results (default: true)
project_pathNoOptional: Project directory path (required for local storage)

Implementation Reference

  • Core implementation of the search_project tool handler. Performs local keyword search on .hive.json for local storage or forwards to cloud Supabase API for cloud storage.
    export async function searchProject(
      userId: string | null,
      query: string,
      projectId?: string,
      includePublic: boolean = true,
      projectPath?: string
    ): Promise<SearchProjectResult> {
      // 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 hive = await readLocalHive(projectPath);
        if (!hive) {
          return { query, results: [], count: 0, source: 'local (not found)' };
        }
    
        // Simple search: filter entries by query keywords
        const queryLower = query.toLowerCase();
        const results = hive.entries.filter(entry =>
          entry.query.toLowerCase().includes(queryLower) ||
          entry.solution.toLowerCase().includes(queryLower) ||
          entry.category.toLowerCase().includes(queryLower)
        ).map(entry => ({
          query: entry.query,
          solution: entry.solution,
          category: entry.category,
          created_at: entry.created_at
        }));
    
        return {
          query,
          results,
          count: results.length,
          source: `local:${projectId}`
        };
      }
    
      // Cloud storage - use API
      const response = await fetch(`${API_BASE}/search-project`, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          user_id: userId,
          query,
          project_id: projectId,
          include_public: includePublic
        }),
      });
    
      if (!response.ok) {
        throw new Error(`Search project failed: ${response.statusText}`);
      }
    
      return response.json();
    }
  • Input schema and metadata definition for the search_project tool, registered in the MCP ListTools response.
    {
      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"],
      },
    },
  • src/index.ts:434-445 (registration)
    Tool dispatch registration in the MCP CallToolRequestSchema handler switch statement.
    case "search_project": {
      const result = await searchProject(
        args?.user_id as string,
        args?.query as string,
        args?.project_id as string | undefined,
        args?.include_public as boolean | undefined,
        args?.project_path as string | undefined
      );
      return {
        content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
      };
    }
  • TypeScript interface defining the output structure of the search_project tool.
    interface SearchProjectResult {
      query: string;
      results: any[];
      count: number;
      source: string;
  • Helper function to read local hive data from .hive.json file, used in local storage search.
    async function readLocalHive(projectPath: string): Promise<LocalHive | null> {
      const fs = await import('fs/promises');
      const path = await import('path');
    
      try {
        const hivePath = path.join(projectPath, '.hive.json');
        const content = await fs.readFile(hivePath, 'utf-8');
        return JSON.parse(content);
      } catch {
        return null;
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions that searches include private entries and optionally public ones, and describes the type of content returned. However, it doesn't cover important aspects like whether this is a read-only operation, what permissions are needed, how results are formatted/paginated, or any rate limits—leaving significant gaps for a search tool.

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 reasonably concise with two sentences and example triggers. The first sentence states the purpose clearly, and the second adds useful scope and return information. While the trigger examples are helpful, they could be more integrated into the main description rather than listed separately.

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

Completeness3/5

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

For a search tool with 5 parameters, no annotations, and no output schema, the description provides adequate basic information about purpose and scope. However, it lacks details about the return format, error conditions, authentication needs, or how it differs from sibling search tools—making it incomplete for optimal agent understanding.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all 5 parameters thoroughly. The description adds minimal value beyond the schema—it implies the 'query' parameter is central and mentions public/private scope, but doesn't provide additional syntax, format, or usage details for parameters. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the tool searches a 'project hive for knowledge' and returns specific content types like solutions and architecture decisions, which is a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'search_kb' or 'search_skills', leaving some ambiguity about when to use this particular search tool.

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

Usage Guidelines3/5

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

The description provides example triggers that imply usage for searching personal knowledge bases, and mentions searching 'private entries + optionally public entries', giving some context. However, it lacks explicit guidance on when to use this tool versus alternatives like 'search_kb' or 'search_skills', and doesn't mention any exclusions or prerequisites.

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

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