Skip to main content
Glama

create_patterns

Add multiple coding patterns to a database for AI agents to reference, enabling personalized code generation and project refactoring based on user-specific styles and conventions.

Instructions

Create multiple new coding patterns in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternsYes

Implementation Reference

  • The createPatterns method in PatternsManager class - this is the actual handler that executes the tool logic. It loads the database, filters out duplicates, adds new patterns, saves the database, and returns the newly created patterns.
    async createPatterns(patterns: Pattern[]): Promise<Pattern[]> {
      const database = await this.loadDatabase();
      const newPatterns = patterns.filter(p =>
        !database.patterns.some(existingPattern => existingPattern.name === p.name));
      database.patterns.push(...newPatterns);
      await this.saveDatabase(database);
      return newPatterns;
    }
  • The Pattern interface defines the type/structure for pattern objects, including name, category, description, use_cases, technologies, and code_examples fields.
    interface Pattern {
      name: string;
      category: string;
      description: string;
      use_cases: string[];
      technologies: string[];
      code_examples: { [language: string]: string };
    }
  • src/index.ts:159-195 (registration)
    Tool registration in the ListToolsRequestSchema handler. Defines the tool name 'create_patterns', its description, and the complete inputSchema with validation for the patterns array and all required fields.
    {
      name: "create_patterns",
      description: "Create multiple new coding patterns in the database",
      inputSchema: {
        type: "object",
        properties: {
          patterns: {
            type: "array",
            items: {
              type: "object",
              properties: {
                name: { type: "string", description: "The unique name of the pattern" },
                category: { type: "string", description: "The category of the pattern (e.g., Backend, Frontend, Database)" },
                description: { type: "string", description: "A description of what this pattern does" },
                use_cases: { 
                  type: "array", 
                  items: { type: "string" },
                  description: "An array of use cases where this pattern applies"
                },
                technologies: { 
                  type: "array", 
                  items: { type: "string" },
                  description: "An array of technologies this pattern uses"
                },
                code_examples: {
                  type: "object",
                  additionalProperties: { type: "string" },
                  description: "Code examples keyed by programming language"
                },
              },
              required: ["name", "category", "description", "use_cases", "technologies", "code_examples"],
            },
          },
        },
        required: ["patterns"],
      },
    },
  • The switch case handler in CallToolRequestSchema that routes 'create_patterns' tool calls to the patternsManager.createPatterns method and returns the result as JSON.
    switch (name) {
      case "create_patterns":
        return { content: [{ type: "text", text: JSON.stringify(await patternsManager.createPatterns(args.patterns as Pattern[]), null, 2) }] };
Behavior2/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. While 'Create multiple new' implies a write operation, it doesn't address permissions needed, whether this is idempotent, what happens on partial failures, or how conflicts with existing patterns are handled. The description lacks crucial behavioral context for a database mutation tool.

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 communicates the core purpose without unnecessary words. It's appropriately front-loaded with the main action and scope, making it easy to parse quickly.

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?

For a database mutation tool with 6 required nested properties, no annotations, no output schema, and 0% schema description coverage, this description is inadequate. It doesn't explain what happens after creation, how to handle errors, or provide any context about the pattern structure beyond what's minimally implied by the tool name.

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?

Schema description coverage is 0%, meaning none of the 6 nested properties within the 'patterns' array have descriptions in the schema. The description adds no parameter information beyond the name 'patterns' - it doesn't explain what constitutes a valid pattern, required fields, or format expectations. This fails to compensate for the complete lack of schema documentation.

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 action ('Create multiple new coding patterns') and resource ('in the database'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'add_code_examples' or 'open_patterns' which might have overlapping functionality.

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 like 'add_code_examples' or 'read_patterns'. There's no mention of prerequisites, constraints, or appropriate contexts for bulk creation versus individual operations.

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