Skip to main content
Glama

search_patterns

Find coding patterns by searching across names, descriptions, technologies, use cases, and code content with a single query.

Instructions

Search for patterns based on a query across all fields

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query to match against pattern names, descriptions, technologies, use cases, and code content

Implementation Reference

  • The searchPatterns method in the PatternsManager class implements the search logic. It loads the database and filters patterns by searching across all fields (name, category, description, use_cases, technologies, and code_examples) using case-insensitive matching.
    async searchPatterns(query: string): Promise<PatternsDatabase> {
      const database = await this.loadDatabase();
      
      const filteredPatterns = database.patterns.filter(p => 
        p.name.toLowerCase().includes(query.toLowerCase()) ||
        p.category.toLowerCase().includes(query.toLowerCase()) ||
        p.description.toLowerCase().includes(query.toLowerCase()) ||
        p.use_cases.some(uc => uc.toLowerCase().includes(query.toLowerCase())) ||
        p.technologies.some(tech => tech.toLowerCase().includes(query.toLowerCase())) ||
        Object.keys(p.code_examples).some(lang => lang.toLowerCase().includes(query.toLowerCase())) ||
        Object.values(p.code_examples).some(code => code.toLowerCase().includes(query.toLowerCase()))
      );
    
      return { patterns: filteredPatterns };
    }
  • The tool schema definition in the ListToolsRequestSchema handler. Defines the tool name as 'search_patterns', its description, and the input schema requiring a 'query' string parameter.
      name: "search_patterns",
      description: "Search for patterns based on a query across all fields",
      inputSchema: {
        type: "object",
        properties: {
          query: { type: "string", description: "The search query to match against pattern names, descriptions, technologies, use cases, and code content" },
        },
        required: ["query"],
      },
    },
  • src/index.ts:319-320 (registration)
    The case handler in the CallToolRequestSchema that routes 'search_patterns' tool calls to the patternsManager.searchPatterns method, passing the query argument and formatting the result as JSON.
    case "search_patterns":
      return { content: [{ type: "text", text: JSON.stringify(await patternsManager.searchPatterns(args.query as string), null, 2) }] };
  • TypeScript interface definitions for Pattern and PatternsDatabase that define the schema for pattern objects and the database structure used by the search_patterns tool.
    interface Pattern {
      name: string;
      category: string;
      description: string;
      use_cases: string[];
      technologies: string[];
      code_examples: { [language: string]: string };
    }
    
    interface PatternsDatabase {
      patterns: Pattern[];
    }
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 states the tool searches 'across all fields', which adds some context beyond the input schema, but fails to describe critical behaviors like whether results are paginated, sorted, or limited; what the return format looks like; or any performance considerations. For a search tool with zero annotation coverage, this leaves significant gaps.

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 a single, efficient sentence that directly states the tool's function without any redundant or vague language. It is appropriately sized and front-loaded, with every word contributing to understanding the tool's purpose.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete for a search tool. It doesn't explain what the search returns (e.g., list of patterns, metadata, relevance scores), how results are structured, or any behavioral traits like error handling. The agent is left with significant unknowns about the tool's operation and output.

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?

The input schema has 100% description coverage, with the 'query' parameter fully documented in the schema itself. The description adds marginal value by implying the query searches 'across all fields', but doesn't provide additional syntax, format details, or examples beyond what the schema already states. 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 verb 'search' and the resource 'patterns', specifying it searches 'based on a query across all fields'. This distinguishes it from siblings like 'read_patterns' (likely a simple retrieval) and 'create_patterns' (creation). However, it doesn't explicitly contrast with 'open_patterns' or other search-like siblings, keeping it from a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose 'search_patterns' over 'read_patterns' or 'open_patterns', nor does it specify any prerequisites, exclusions, or optimal contexts for usage. The agent must infer usage from the tool name alone.

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/nicholasrubright/MCPatterns'

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