Skip to main content
Glama

configure_custom_patterns

Define custom sensitive patterns to identify and protect confidential information in your codebase during architectural analysis.

Instructions

Configure custom sensitive patterns for a project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesPath to the project directory
existingPatternsNoExisting patterns to consider

Implementation Reference

  • Main handler function that executes the tool logic. Scans the actual project structure, reads and includes truncated contents from key files (package.json, .env, configs, scripts), generates detailed AI prompts for custom pattern configuration, and returns MCP-formatted response with instructions and prompts for JSON output containing regex patterns, replacements, and recommendations.
    /**
     * Configure custom sensitive patterns for a project
     */
    export async function configureCustomPatterns(args: {
      projectPath: string;
      existingPatterns?: string[];
    }): Promise<any> {
      const { projectPath, existingPatterns } = args;
    
      try {
        // Use actual file operations to scan project structure
        const { scanProjectStructure } = await import('../utils/actual-file-operations.js');
    
        // Actually scan project structure
        const projectStructure = await scanProjectStructure(projectPath, {
          readContent: true,
          maxFileSize: 10000,
        });
    
        const customPatternPrompt = `
    # Custom Pattern Configuration Generation
    
    Based on actual project structure analysis, here are the findings:
    
    ## Project Structure
    - **Root Path**: ${projectStructure.rootPath}
    - **Total Files**: ${projectStructure.totalFiles}
    - **Directories**: ${projectStructure.directories.join(', ')}
    
    ## Package Management Files
    ${
      projectStructure.packageFiles.length > 0
        ? projectStructure.packageFiles
            .map(
              f => `
    ### ${f.filename}
    \`\`\`
    ${f.content.slice(0, 500)}${f.content.length > 500 ? '\n... (truncated)' : ''}
    \`\`\`
    `
            )
            .join('\n')
        : '- No package files found'
    }
    
    ## Environment Configuration Files
    ${
      projectStructure.environmentFiles.length > 0
        ? projectStructure.environmentFiles
            .map(
              f => `
    ### ${f.filename}
    \`\`\`
    ${f.content.slice(0, 300)}${f.content.length > 300 ? '\n... (truncated)' : ''}
    \`\`\`
    `
            )
            .join('\n')
        : '- No environment files found'
    }
    
    ## Configuration Files
    ${
      projectStructure.configFiles.length > 0
        ? projectStructure.configFiles
            .map(
              f => `
    ### ${f.filename}
    \`\`\`
    ${f.content.slice(0, 300)}${f.content.length > 300 ? '\n... (truncated)' : ''}
    \`\`\`
    `
            )
            .join('\n')
        : '- No config files found'
    }
    
    ## Script Files
    ${
      projectStructure.scriptFiles.length > 0
        ? projectStructure.scriptFiles
            .map(
              f => `
    ### ${f.filename}
    \`\`\`
    ${f.content.slice(0, 400)}${f.content.length > 400 ? '\n... (truncated)' : ''}
    \`\`\`
    `
            )
            .join('\n')
        : '- No script files found'
    }
    
    ## Existing Patterns Context
    
    ${
      existingPatterns
        ? `
    ### Current Patterns (${existingPatterns.length})
    ${existingPatterns
      .map(
        (pattern, index) => `
    #### ${index + 1}. ${pattern}
    `
      )
      .join('')}
    `
        : 'No existing patterns provided.'
    }
    
    ## Pattern Generation Requirements
    
    1. **Analyze project-specific content types** that need masking based on actual file content
    2. **Identify sensitive data patterns** in code and documentation shown above
    3. **Generate regex patterns** for consistent content masking
    4. **Create appropriate replacements** that maintain context
    5. **Ensure patterns don't conflict** with existing ones
    6. **Provide clear descriptions** for each pattern
    
    ## Required Output Format
    
    Please provide custom pattern configuration in JSON format:
    \`\`\`json
    {
      "patterns": [
        {
          "name": "pattern-name",
          "pattern": "regex-pattern",
          "replacement": "replacement-text",
          "description": "pattern-description",
          "category": "pattern-category"
        }
      ],
      "recommendations": ["list", "of", "recommendations"],
      "conflicts": ["any", "potential", "conflicts"]
    }
    \`\`\`
    `;
    
        const instructions = `
    # Custom Pattern Configuration Instructions
    
    This analysis provides **actual project file contents** for comprehensive pattern generation.
    
    ## Analysis Scope
    - **Project Path**: ${projectPath}
    - **Package Files**: ${projectStructure.packageFiles.length} found
    - **Environment Files**: ${projectStructure.environmentFiles.length} found
    - **Config Files**: ${projectStructure.configFiles.length} found
    - **Script Files**: ${projectStructure.scriptFiles.length} found
    - **Total Files Analyzed**: ${projectStructure.totalFiles}
    - **Existing Patterns**: ${existingPatterns?.length || 0} patterns
    
    ## Next Steps
    1. **Submit the configuration prompt** to an AI agent for pattern analysis
    2. **Parse the JSON response** to get custom patterns and recommendations
    3. **Review generated patterns** for accuracy and completeness
    4. **Implement patterns** in the content masking system
    
    ## Expected AI Response Format
    The AI will return a JSON object with:
    - \`patterns\`: Array of custom pattern configurations
    - \`recommendations\`: Best practices and implementation guidance
    - \`conflicts\`: Potential conflicts with existing patterns
    
    ## Usage Example
    \`\`\`typescript
    const result = await configureCustomPatterns({ projectPath, existingPatterns });
    // Submit result.configurationPrompt to AI agent
    // Parse AI response for custom pattern configuration
    \`\`\`
    `;
    
        const result = {
          configurationPrompt: customPatternPrompt,
          instructions,
          actualData: {
            projectStructure,
            summary: {
              totalFiles: projectStructure.totalFiles,
              packageFiles: projectStructure.packageFiles.length,
              environmentFiles: projectStructure.environmentFiles.length,
              configFiles: projectStructure.configFiles.length,
              scriptFiles: projectStructure.scriptFiles.length,
            },
          },
        };
    
        return {
          content: [
            {
              type: 'text',
              text: `# Custom Pattern Configuration\n\n${result.instructions}\n\n## AI Configuration Prompt\n\n${result.configurationPrompt}`,
            },
          ],
        };
      } catch (error) {
        throw new McpAdrError(
          `Failed to configure custom patterns: ${error instanceof Error ? error.message : String(error)}`,
          'CONFIGURATION_ERROR'
        );
      }
    }
  • TypeScript interface defining the input arguments for the configure_custom_patterns tool: required projectPath and optional existingPatterns array.
    export interface ConfigureCustomPatternsArgs {
      projectPath: string;
      existingPatterns?: string[];
    }
  • Tool listed in the server context generator's hardcoded tool catalog under Content Security category, used for documentation and LLM awareness of available tools.
    name: 'configure_custom_patterns',
    description: 'Configure custom security patterns for content analysis',
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. It states 'configure' which implies a write/mutation operation, but doesn't disclose behavioral traits like whether it overwrites existing patterns, requires specific permissions, has side effects, or how it handles errors. This is inadequate for a tool that likely modifies project settings.

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 purpose without unnecessary words. It's front-loaded and wastes no space, 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?

Given the complexity of configuring sensitive patterns (likely a mutation with security implications), no annotations, and no output schema, the description is incomplete. It lacks crucial details about behavior, effects, and what to expect upon execution, leaving significant gaps for an agent to operate safely and effectively.

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 both parameters ('projectPath' and 'existingPatterns'). The description doesn't add any meaning beyond what the schema provides, such as explaining the purpose of 'existingPatterns' or how patterns are configured. Baseline 3 is appropriate when the schema does the heavy lifting.

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 'configure' and the resource 'custom sensitive patterns for a project', which is specific and actionable. However, it doesn't explicitly differentiate from sibling tools like 'configure_output_masking' or 'generate_content_masking', which might handle related but different aspects of pattern configuration.

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 prerequisites, context, or exclusions, leaving the agent to infer usage from the tool name alone among many siblings.

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/tosin2013/mcp-adr-analysis-server'

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