Skip to main content
Glama
DollhouseMCP

DollhouseMCP

Official

search_portfolio

Search your local portfolio elements by name, keywords, tags, or descriptions to quickly find personas, skills, templates, agents, memories, or ensembles using metadata-based lookups.

Instructions

Search your local portfolio by content name, metadata, keywords, tags, or description. This searches your local elements using the portfolio index for fast metadata-based lookups.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query. Can match element names, keywords, tags, triggers, or descriptions. Examples: 'creative writer', 'debug', 'code review', 'research'.
typeNoLimit search to specific element type. If not specified, searches all types.
fuzzy_matchNoEnable fuzzy matching for approximate name matches. Defaults to true.
max_resultsNoMaximum number of results to return. Defaults to 20.
include_keywordsNoInclude keyword matching in search. Defaults to true.
include_tagsNoInclude tag matching in search. Defaults to true.
include_triggersNoInclude trigger word matching in search (for personas). Defaults to true.
include_descriptionsNoInclude description text matching in search. Defaults to true.

Implementation Reference

  • Defines and registers the 'search_portfolio' MCP tool, including full input schema, description, and handler that delegates to the server's searchPortfolio method.
      tool: {
        name: "search_portfolio",
        description: "Search your local portfolio by content name, metadata, keywords, tags, or description. This searches your local elements using the portfolio index for fast metadata-based lookups.",
        inputSchema: {
          type: "object",
          properties: {
            query: {
              type: "string",
              description: "Search query. Can match element names, keywords, tags, triggers, or descriptions. Examples: 'creative writer', 'debug', 'code review', 'research'.",
            },
            type: {
              type: "string",
              enum: ["personas", "skills", "templates", "agents", "memories", "ensembles"],
              description: "Limit search to specific element type. If not specified, searches all types.",
            },
            fuzzy_match: {
              type: "boolean",
              description: "Enable fuzzy matching for approximate name matches. Defaults to true.",
            },
            max_results: {
              type: "number",
              description: "Maximum number of results to return. Defaults to 20.",
            },
            include_keywords: {
              type: "boolean",
              description: "Include keyword matching in search. Defaults to true.",
            },
            include_tags: {
              type: "boolean",
              description: "Include tag matching in search. Defaults to true.",
            },
            include_triggers: {
              type: "boolean",
              description: "Include trigger word matching in search (for personas). Defaults to true.",
            },
            include_descriptions: {
              type: "boolean",
              description: "Include description text matching in search. Defaults to true.",
            },
          },
          required: ["query"],
        },
      },
      handler: (args: SearchPortfolioArgs) => server.searchPortfolio({
        query: args.query,
        elementType: args.type as any,
        fuzzyMatch: args.fuzzy_match,
        maxResults: args.max_results,
        includeKeywords: args.include_keywords,
        includeTags: args.include_tags,
        includeTriggers: args.include_triggers,
        includeDescriptions: args.include_descriptions
      })
    },
  • JSON Schema for search_portfolio tool input validation, defining all parameters like query (required), type filter, fuzzy matching, limits, and include flags.
    inputSchema: {
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "Search query. Can match element names, keywords, tags, triggers, or descriptions. Examples: 'creative writer', 'debug', 'code review', 'research'.",
        },
        type: {
          type: "string",
          enum: ["personas", "skills", "templates", "agents", "memories", "ensembles"],
          description: "Limit search to specific element type. If not specified, searches all types.",
        },
        fuzzy_match: {
          type: "boolean",
          description: "Enable fuzzy matching for approximate name matches. Defaults to true.",
        },
        max_results: {
          type: "number",
          description: "Maximum number of results to return. Defaults to 20.",
        },
        include_keywords: {
          type: "boolean",
          description: "Include keyword matching in search. Defaults to true.",
        },
        include_tags: {
          type: "boolean",
          description: "Include tag matching in search. Defaults to true.",
        },
        include_triggers: {
          type: "boolean",
          description: "Include trigger word matching in search (for personas). Defaults to true.",
        },
        include_descriptions: {
          type: "boolean",
          description: "Include description text matching in search. Defaults to true.",
        },
      },
      required: ["query"],
    },
  • Core search handler that implements portfolio search across multiple fields (name, filename, keywords, tags, triggers, descriptions) using tokenized query matching, scoring, deduplication, and optional filters. This is the primary execution logic for search_portfolio.
    public async search(query: string, options: SearchOptions = {}): Promise<SearchResult[]> {
      const index = await this.getIndex();
      
      // Normalize query for security
      const normalizedQuery = UnicodeValidator.normalize(query);
      if (!normalizedQuery.isValid) {
        logger.warn('Invalid Unicode in search query', {
          issues: normalizedQuery.detectedIssues
        });
        return [];
      }
      
      const safeQuery = normalizedQuery.normalizedContent.toLowerCase().trim();
      const queryTokens = safeQuery.split(/\s+/).filter(token => token.length > 0);
      
      if (queryTokens.length === 0) {
        return [];
      }
      
      const results: SearchResult[] = [];
      const seenPaths = new Set<string>();
      const maxResults = options.maxResults || 20;
      
      // Helper to add unique results
      const addResult = (entry: IndexEntry, matchType: SearchResult['matchType'], score: number = 1) => {
        if (!seenPaths.has(entry.filePath) && results.length < maxResults) {
          // Filter by element type if specified
          if (options.elementType && entry.elementType !== options.elementType) {
            return;
          }
          
          seenPaths.add(entry.filePath);
          results.push({ entry, matchType, score });
        }
      };
      
      // 1. Search by name (highest priority)
      for (const [name, entry] of index.byName) {
        if (this.matchesQuery(name, queryTokens)) {
          addResult(entry, 'name', 3);
        }
      }
      
      // 2. Search by filename
      for (const [filename, entry] of index.byFilename) {
        if (this.matchesQuery(filename, queryTokens)) {
          addResult(entry, 'filename', 2.5);
        }
      }
      
      // 3. Search by keywords
      if (options.includeKeywords !== false) {
        for (const [keyword, entries] of index.byKeyword) {
          if (this.matchesQuery(keyword, queryTokens)) {
            for (const entry of entries) {
              addResult(entry, 'keyword', 2);
            }
          }
        }
      }
      
      // 4. Search by tags
      if (options.includeTags !== false) {
        for (const [tag, entries] of index.byTag) {
          if (this.matchesQuery(tag, queryTokens)) {
            for (const entry of entries) {
              addResult(entry, 'tag', 2);
            }
          }
        }
      }
      
      // 5. Search by triggers
      if (options.includeTriggers !== false) {
        for (const [trigger, entries] of index.byTrigger) {
          if (this.matchesQuery(trigger, queryTokens)) {
            for (const entry of entries) {
              addResult(entry, 'trigger', 1.8);
            }
          }
        }
      }
      
      // 6. Search by description
      if (options.includeDescriptions !== false) {
        for (const [_, entry] of index.byName) {
          if (entry.metadata.description && 
              this.matchesQuery(entry.metadata.description.toLowerCase(), queryTokens)) {
            addResult(entry, 'description', 1.5);
          }
        }
      }
      
      // Sort by score (descending)
      results.sort((a, b) => b.score - a.score);
      
      logger.debug('Portfolio search completed', {
        query: safeQuery,
        resultCount: results.length,
        totalIndexed: index.byName.size
      });
      
      return results;
    }
  • TypeScript interface definition for the searchPortfolio method in IToolHandler, specifying exact parameter types and structure used by the MCP tool server.
    searchPortfolio(options: {query: string; elementType?: string; fuzzyMatch?: boolean; maxResults?: number; includeKeywords?: boolean; includeTags?: boolean; includeTriggers?: boolean; includeDescriptions?: boolean}): Promise<any>;
  • Supporting findByName method for exact, filename, and fuzzy name-based lookups, used internally by search and other portfolio operations.
    public async findByName(name: string, options: SearchOptions = {}): Promise<IndexEntry | null> {
      const index = await this.getIndex();
      
      // Normalize input for security
      const normalizedName = UnicodeValidator.normalize(name);
      if (!normalizedName.isValid) {
        logger.warn('Invalid Unicode in search name', {
          issues: normalizedName.detectedIssues
        });
        return null;
      }
      
      const safeName = normalizedName.normalizedContent;
      
      // Try exact match first (case insensitive)
      const exactMatch = index.byName.get(safeName.toLowerCase());
      if (exactMatch) {
        logger.debug('Found exact name match', { name: safeName, filePath: exactMatch.filePath });
        return exactMatch;
      }
      
      // Try filename match
      const filenameMatch = index.byFilename.get(safeName.toLowerCase());
      if (filenameMatch) {
        logger.debug('Found filename match', { name: safeName, filePath: filenameMatch.filePath });
        return filenameMatch;
      }
      
      // Try fuzzy matching if enabled
      if (options.fuzzyMatch !== false) {
        const fuzzyMatch = this.findFuzzyMatch(safeName, index, options);
        if (fuzzyMatch) {
          logger.debug('Found fuzzy match', { 
            name: safeName, 
            matchName: fuzzyMatch.metadata.name,
            filePath: fuzzyMatch.filePath 
          });
          return fuzzyMatch;
        }
      }
      
      logger.debug('No match found for name', { name: safeName });
      return null;
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool searches 'local portfolio' and uses a 'portfolio index for fast metadata-based lookups', which adds useful context about scope and performance. However, it does not cover aspects like error handling, rate limits, or authentication needs, leaving gaps for a tool with 8 parameters.

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 two sentences, front-loaded with the core purpose and followed by a clarifying detail about the search mechanism. It avoids redundancy and waste, though it could be slightly more structured (e.g., separating scope from behavior).

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 (8 parameters, no annotations, no output schema), the description is adequate but incomplete. It covers the purpose and search scope but lacks details on behavioral traits, error cases, or result formatting, which are important for a search tool with multiple toggle parameters.

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 8 parameters thoroughly. The description adds minimal value beyond the schema by listing searchable fields (e.g., content name, metadata, keywords) but does not provide additional syntax or format details. This meets the baseline of 3 when schema coverage is high.

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

Purpose5/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 local portfolio by content name, metadata, keywords, tags, or description, specifying it uses a portfolio index for fast metadata-based lookups. This distinguishes it from siblings like 'search_all', 'search_by_verb', or 'search_collection' by emphasizing local, metadata-focused searching.

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 implies usage for searching local portfolio elements based on metadata, but does not explicitly state when to use this tool versus alternatives like 'search_all' or 'search_collection'. It provides some context (e.g., 'fast metadata-based lookups') but lacks clear exclusions or named alternatives.

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