Skip to main content
Glama
DollhouseMCP

DollhouseMCP

Official

search_collection_enhanced

Search and filter collection content by type, category, and relevance with paginated results for precise discovery.

Instructions

Enhanced search for collection content with pagination, filtering, and sorting. Use this for advanced searches when users need specific content types or want to browse results in pages.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query for finding content. Examples: 'creative writer', 'explain like I'm five', 'coding assistant'.
elementTypeNoFilter by content type: personas, skills, agents, templates, tools, memories, prompts
categoryNoFilter by category: creative, professional, educational, personal, gaming
pageNoPage number for paginated results (default: 1)
pageSizeNoNumber of results per page (default: 25, max: 100)
sortByNoSort results by relevance, name, or date

Implementation Reference

  • Tool registration for 'search_collection_enhanced' including full input schema and thin handler that passes arguments to server.searchCollectionEnhanced
    {
      tool: {
        name: "search_collection_enhanced",
        description: "Enhanced search for collection content with pagination, filtering, and sorting. Use this for advanced searches when users need specific content types or want to browse results in pages.",
        inputSchema: {
          type: "object",
          properties: {
            query: {
              type: "string",
              description: "Search query for finding content. Examples: 'creative writer', 'explain like I'm five', 'coding assistant'.",
            },
            elementType: {
              type: "string",
              description: "Filter by content type: personas, skills, agents, templates, tools, memories, prompts",
              enum: ["personas", "skills", "agents", "templates", "tools", "memories", "prompts"]
            },
            category: {
              type: "string",
              description: "Filter by category: creative, professional, educational, personal, gaming",
              enum: ["creative", "professional", "educational", "personal", "gaming"]
            },
            page: {
              type: "number",
              description: "Page number for paginated results (default: 1)",
              minimum: 1
            },
            pageSize: {
              type: "number", 
              description: "Number of results per page (default: 25, max: 100)",
              minimum: 1,
              maximum: 100
            },
            sortBy: {
              type: "string",
              description: "Sort results by relevance, name, or date",
              enum: ["relevance", "name", "date"]
            }
          },
          required: ["query"],
        },
      },
      handler: (args: any) => server.searchCollectionEnhanced(args.query, {
        elementType: args.elementType,
        category: args.category,
        page: args.page,
        pageSize: args.pageSize,
        sortBy: args.sortBy
      })
    },
  • TypeScript interface definition for the server.searchCollectionEnhanced method signature used by the tool handler
    searchCollectionEnhanced(query: string, options?: any): Promise<any>;
  • Core handler logic for enhanced collection search: validates query, attempts index-based search with filtering/pagination/sorting, falls back to legacy GitHub API/cache/seed search, converts results to consistent format
    async searchCollectionWithOptions(query: string, options: SearchOptions = {}): Promise<SearchResults> {
      const startTime = Date.now();
      logger.debug(`CollectionSearch.searchCollectionWithOptions called with query: "${query}"`, options);
      
      // Validate search query for security
      try {
        validateSearchQuery(query, 1000);
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        logger.error('Search query validation failed:', { query, error: errorMessage });
        ErrorHandler.logError('CollectionSearch.searchWithOptions.validateQuery', error, { query });
        return this.createEmptySearchResults(query, options);
      }
      
      try {
        // Try index-based search first
        const indexResults = await this.searchFromIndex(query, options);
        const searchTime = Date.now() - startTime;
        
        logger.debug(`Index search completed in ${searchTime}ms with ${indexResults.items.length} results`);
        return { ...indexResults, searchTime };
      } catch (error) {
        logger.debug('Index search failed, falling back to legacy search:', error);
        
        // Fallback to legacy search
        const legacyResults = await this.searchCollection(query);
        const searchTime = Date.now() - startTime;
        
        // Convert legacy results to new format
        return this.convertLegacyResults(legacyResults, query, options, searchTime);
      }
    }
  • Index-based search helper: loads collection index, applies elementType/category filters, performs text matching across name/description/path/tags, sorts by relevance/name/date, applies pagination
    /**
     * Search from collection index with full featured search and pagination
     */
    private async searchFromIndex(query: string, options: SearchOptions): Promise<SearchResults> {
      const index = await this.indexCache.getIndex();
      const allEntries = this.flattenIndexEntries(index);
      
      // Filter by element type if specified
      let filteredEntries = allEntries;
      if (options.elementType) {
        filteredEntries = allEntries.filter(entry => entry.type === options.elementType);
      }
      
      // Filter by category if specified
      if (options.category) {
        filteredEntries = filteredEntries.filter(entry => entry.category === options.category);
      }
      
      // Search matching
      const matchedEntries = this.performIndexSearch(query, filteredEntries);
      
      // Sort results
      const sortedEntries = this.sortSearchResults(matchedEntries, options.sortBy || 'relevance', query);
      
      // Apply pagination
      const page = options.page || 1;
      const pageSize = options.pageSize || 25;
      const startIndex = (page - 1) * pageSize;
      const endIndex = startIndex + pageSize;
      const paginatedEntries = sortedEntries.slice(startIndex, endIndex);
      
      return {
        items: paginatedEntries,
        total: sortedEntries.length,
        page,
        pageSize,
        hasMore: endIndex < sortedEntries.length,
        query,
        searchTime: 0 // Will be set by caller
      };
    }
  • Helper for formatting enhanced search results with pagination indicators, content type icons, detailed metadata, and tool call suggestions
    formatSearchResultsWithPagination(results: SearchResults, personaIndicator: string = ''): string {
      if (results.total === 0) {
        return `${personaIndicator}🔍 No content found for query: "${results.query}"`;
      }
      
      const startItem = (results.page - 1) * results.pageSize + 1;
      const endItem = Math.min(results.page * results.pageSize, results.total);
      
      const textParts = [
        `${personaIndicator}🔍 **Search Results for "${results.query}"**\n`,
        `📊 Showing ${startItem}-${endItem} of ${results.total} results (Page ${results.page})\n`,
        `⚡ Search time: ${results.searchTime}ms\n\n`
      ];
      
      results.items.forEach((item: IndexEntry) => {
        const contentIcons: { [key: string]: string } = {
          'personas': '🎭',
          'skills': '🛠️',
          'agents': '🤖',
          'prompts': '💬',
          'templates': '📄',
          'tools': '🔧',
          'ensembles': '🎼',
          'memories': '🧠'
        };
        const icon = contentIcons[item.type] || '📄';
        
        textParts.push(
          `   ${icon} **${item.name}** (${item.type})\n`,
          `      📝 ${item.description}\n`,
          `      🏷️ Tags: ${item.tags.join(', ')}\n`,
          `      📂 Path: ${item.path}\n`,
          `      📥 Install: \`install_collection_content "${item.path}"\`\n`,
          `      👁️ Details: \`get_collection_content "${item.path}"\`\n\n`
        );
      });
      
      // Add pagination info
      if (results.hasMore) {
        const nextPage = results.page + 1;
        textParts.push(`📄 More results available. Use page ${nextPage} to see next ${results.pageSize} items.\n`);
      }
      
      return textParts.join('');
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions pagination, filtering, and sorting as features, but lacks details on critical behaviors like rate limits, authentication requirements, error handling, or the format of returned results. For a search tool with no annotation coverage, this leaves significant gaps in understanding how the tool operates beyond basic functionality.

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

Conciseness5/5

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

The description is concise and well-structured with two sentences: the first states the purpose and key features, and the second provides usage guidelines. Every sentence earns its place by adding value without redundancy, making it easy to scan and understand quickly.

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?

Given the tool's complexity (6 parameters, no annotations, no output schema), the description is somewhat incomplete. It covers the high-level purpose and usage but lacks details on behavioral aspects like result format, error cases, or performance characteristics. While the schema handles parameters well, the absence of output schema and annotations means the description should do more to compensate, which it only partially achieves.

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 input schema already documents all parameters thoroughly with descriptions, examples, enums, and defaults. The description adds minimal value beyond the schema by implying the tool supports filtering and sorting, but doesn't provide additional semantic context or usage examples that aren't already covered in the structured fields.

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's purpose as 'Enhanced search for collection content with pagination, filtering, and sorting,' which specifies the verb (search), resource (collection content), and key features. However, it doesn't explicitly differentiate from sibling tools like 'search_collection' or 'search_all,' which appear to be similar search operations, leaving some ambiguity about when to choose this specific enhanced version.

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

Usage Guidelines4/5

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

The description provides clear usage context: 'Use this for advanced searches when users need specific content types or want to browse results in pages.' This gives guidance on when to use it (advanced searches with filtering/pagination) but doesn't specify when NOT to use it or name explicit alternatives among the many sibling search tools, such as 'search_collection' or 'search_all,' which could help avoid confusion.

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/DollhouseMCP/mcp-server'

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