Skip to main content
Glama

searchCards

Search and retrieve specific cards from Heptabase backups using queries, tags, whiteboard IDs, content types, or date ranges for organized data access.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentTypeNo
dateRangeNo
queryNo
tagsNo
whiteboardIdNo

Implementation Reference

  • Primary handler for the 'searchCards' MCP tool. Processes input parameters, constructs search query, delegates to HeptabaseDataService.searchCards, and formats results as MCP text response.
    handler: async (params) => {
      await this.ensureDataServiceInitialized();
    
      const searchQuery: any = {};
      
      if (params.query) {
        searchQuery.query = params.query;
      }
      
      if (params.tags) {
        searchQuery.tags = params.tags;
      }
      
      if (params.whiteboardId) {
        searchQuery.whiteboardId = params.whiteboardId;
      }
      
      if (params.contentType) {
        searchQuery.contentType = params.contentType;
      }
      
      if (params.dateRange) {
        searchQuery.dateRange = {
          start: new Date(params.dateRange.start),
          end: new Date(params.dateRange.end)
        };
      }
    
      const results = await this.dataService!.searchCards(searchQuery);
      
      // Due to MCP response size limits, only show basic info in search results
      // Use getCard for full content
      const text = `Found ${results.length} cards:\n` +
        results.map(card => {
          return `- ${card.title || 'Untitled'} (ID: ${card.id})`;
        }).join('\n') +
        '\n\nUse getCard with specific card ID to get full content.';
    
      return {
        content: [{
          type: 'text',
          text
        }]
      };
    }
  • Zod schema defining the input parameters for the searchCards tool.
    const searchCardsSchema = z.object({
      query: z.string().optional(),
      tags: z.array(z.string()).optional(),
      whiteboardId: z.string().optional(),
      contentType: z.enum(['text', 'image', 'link']).optional(),
      dateRange: z.object({
        start: z.string(),
        end: z.string()
      }).optional()
    });
  • src/server.ts:400-402 (registration)
    MCP server tool registration for 'searchCards', linking schema and handler.
    this.server.tool('searchCards', searchCardsSchema.shape, async (params) => {
      return this.tools.searchCards.handler(params);
    });
  • Core implementation of card search logic, including caching, filtering by query, tags (though tags not implemented in filter?), whiteboard, contentType (not in filter?), and date range.
    async searchCards(query: SearchQuery): Promise<Card[]> {
      const cacheKey = `cards:${JSON.stringify(query)}`;
      
      if (this.config.cacheEnabled) {
        const cached = this.getFromCache(cacheKey);
        if (cached) return cached;
      }
    
      const results = Object.values(this.data.cards).filter(card => {
        // Filter out trashed cards
        if (card.isTrashed) return false;
    
        // Search by query in title and content
        if (query.query) {
          const searchTerm = query.query.toLowerCase();
          const titleMatch = card.title?.toLowerCase().includes(searchTerm) || false;
          const contentMatch = card.content.toLowerCase().includes(searchTerm);
          if (!titleMatch && !contentMatch) {
            return false;
          }
        }
    
        // Filter by whiteboard
        if (query.whiteboardId) {
          const hasInstance = Object.values(this.data.cardInstances).some(
            instance => instance.cardId === card.id && instance.whiteboardId === query.whiteboardId
          );
          if (!hasInstance) return false;
        }
    
        // Filter by date range
        if (query.dateRange) {
          const createdDate = new Date(card.createdTime);
          if (createdDate < query.dateRange.start || createdDate > query.dateRange.end) {
            return false;
          }
        }
    
        return true;
      });
    
      if (this.config.cacheEnabled) {
        this.setCache(cacheKey, results);
      }
    
      return results;
    }
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/LarryStanley/heptabase-mcp'

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