Skip to main content
Glama

apply_basic_content_masking

Apply basic content masking to protect sensitive information in architectural decision records when AI analysis is unavailable. Supports full, partial, or placeholder masking strategies.

Instructions

Apply basic content masking (fallback when AI is not available)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesContent to mask
maskingStrategyNoStrategy for masking contentfull

Implementation Reference

  • The primary MCP tool handler function for 'apply_basic_content_masking'. It receives arguments, applies basic masking using imported utilities from content-masking.ts, validates the result, and returns a formatted MCP response.
    export async function applyBasicContentMasking(args: {
      content: string;
      maskingStrategy?: 'full' | 'partial' | 'placeholder';
    }): Promise<any> {
      const { content, maskingStrategy = 'full' } = args;
    
      try {
        const { applyBasicMasking, validateMasking } = await import('../utils/content-masking.js');
    
        if (!content || content.trim().length === 0) {
          throw new McpAdrError('Content is required for masking', 'INVALID_INPUT');
        }
    
        const maskedContent = applyBasicMasking(content, maskingStrategy);
        const validation = validateMasking(content, maskedContent);
    
        return {
          content: [
            {
              type: 'text',
              text: `# Basic Content Masking Applied
    
    ## Masking Strategy
    ${maskingStrategy}
    
    ## Original Content Length
    ${content.length} characters
    
    ## Masked Content
    \`\`\`
    ${maskedContent}
    \`\`\`
    
    ## Validation Results
    - **Security Score**: ${(validation.securityScore * 100).toFixed(1)}%
    - **Is Valid**: ${validation.isValid ? '✅ Yes' : '❌ No'}
    
    ${
      validation.issues.length > 0
        ? `## Issues Found
    ${validation.issues.map(issue => `- ${issue}`).join('\n')}`
        : '## ✅ No Issues Found'
    }
    
    ## Recommendations
    - For better security analysis, use AI-powered detection with \`analyze_content_security\`
    - Consider using custom patterns for project-specific sensitive information
    - Review masked content to ensure it maintains necessary functionality
    `,
            },
          ],
        };
      } catch (error) {
        throw new McpAdrError(
          `Failed to apply basic masking: ${error instanceof Error ? error.message : String(error)}`,
          'MASKING_ERROR'
        );
      }
    }
  • Central tool catalog registration including metadata, category, input schema, and CE-MCP directive for the 'apply_basic_content_masking' tool.
    TOOL_CATALOG.set('apply_basic_content_masking', {
      name: 'apply_basic_content_masking',
      shortDescription: 'Apply basic content masking',
      fullDescription: 'Applies basic content masking using predefined patterns.',
      category: 'content-security',
      complexity: 'simple',
      tokenCost: { min: 200, max: 500 },
      hasCEMCPDirective: true, // Phase 4.3: Simple tool - single masking operation
      relatedTools: ['generate_content_masking', 'configure_custom_patterns'],
      keywords: ['masking', 'apply', 'basic', 'content'],
      requiresAI: false,
      inputSchema: {
        type: 'object',
        properties: {
          content: { type: 'string' },
        },
        required: ['content'],
      },
    });
  • TypeScript interface defining the input arguments for the apply_basic_content_masking tool.
    export interface ApplyBasicContentMaskingArgs {
      content: string;
      maskingStrategy?: 'full' | 'partial' | 'placeholder';
    }
  • Core utility function implementing the basic regex-based content masking logic used by the tool handler.
    export function applyBasicMasking(
      content: string,
      maskingStrategy: 'full' | 'partial' | 'placeholder' = 'full'
    ): string {
      // Basic patterns for common sensitive information
      const patterns = [
        // API Keys
        {
          pattern: /sk-[a-zA-Z0-9]{32,}/g,
          replacement: maskingStrategy === 'partial' ? 'sk-...****' : '[API_KEY_REDACTED]',
        },
        {
          pattern: /ghp_[a-zA-Z0-9]{36}/g,
          replacement: maskingStrategy === 'partial' ? 'ghp_...****' : '[GITHUB_TOKEN_REDACTED]',
        },
    
        // AWS Keys
        {
          pattern: /AKIA[0-9A-Z]{16}/g,
          replacement: maskingStrategy === 'partial' ? 'AKIA...****' : '[AWS_ACCESS_KEY_REDACTED]',
        },
    
        // Email addresses
        {
          pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g,
          replacement: maskingStrategy === 'partial' ? '***@***.***' : '[EMAIL_REDACTED]',
        },
    
        // IP Addresses (private ranges)
        {
          pattern: /\b(?:10\.|172\.(?:1[6-9]|2[0-9]|3[01])\.|192\.168\.)\d{1,3}\.\d{1,3}\b/g,
          replacement: '[IP_ADDRESS_REDACTED]',
        },
    
        // Common password patterns
        {
          pattern: /password\s*[:=]\s*["']?[^"'\s]+["']?/gi,
          replacement: 'password=[PASSWORD_REDACTED]',
        },
      ];
    
      let maskedContent = content;
    
      for (const { pattern, replacement } of patterns) {
        maskedContent = maskedContent.replace(pattern, replacement);
      }
    
      return maskedContent;
    }
  • Utility function that validates the masking effectiveness by checking for remaining sensitive patterns and computing a security score.
    export function validateMasking(
      originalContent: string,
      maskedContent: string
    ): {
      isValid: boolean;
      issues: string[];
      securityScore: number;
    } {
      const issues: string[] = [];
      let securityScore = 1.0;
    
      // Check for common patterns that should have been masked
      const sensitivePatterns = [
        /sk-[a-zA-Z0-9]{32,}/g,
        /ghp_[a-zA-Z0-9]{36}/g,
        /AKIA[0-9A-Z]{16}/g,
        /password\s*[:=]\s*["']?[^"'\s\\[\\]]+["']?/gi,
      ];
    
      for (const pattern of sensitivePatterns) {
        const matches = maskedContent.match(pattern);
        if (matches) {
          issues.push(`Potential unmasked sensitive content found: ${matches[0].substring(0, 10)}...`);
          securityScore -= 0.2;
        }
      }
    
      // Check that masking was actually applied
      if (originalContent === maskedContent) {
        issues.push('No masking appears to have been applied');
        securityScore = 0;
      }
    
      return {
        isValid: issues.length === 0,
        issues,
        securityScore: Math.max(0, securityScore),
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions this is a 'fallback' tool but doesn't disclose important behavioral traits: what 'basic content masking' actually does, whether it modifies content in place or returns masked content, what permissions are required, or any limitations. The description is too vague about the tool's actual behavior beyond the fallback context.

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 extremely concise at just one sentence with no wasted words. It's front-loaded with the core purpose and includes the important usage context. Every word earns its place, making it easy to parse quickly while conveying essential information.

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 there are no annotations and no output schema, the description should provide more complete context. For a tool with 2 parameters that performs content transformation, the description doesn't explain what the tool returns, what 'basic' masking entails compared to other masking tools, or any behavioral constraints. The fallback context is helpful but insufficient for understanding the tool's full scope.

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 thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema. It doesn't explain how 'content' relates to masking or provide examples of different 'maskingStrategy' values. With complete schema coverage, the baseline score of 3 is appropriate.

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

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool's purpose as 'Apply basic content masking' which is a clear verb+resource combination. However, it doesn't specify what 'content masking' entails or differentiate this from sibling tools like 'configure_output_masking', 'generate_content_masking', or 'validate_content_masking'. The fallback context adds some context but doesn't clarify the core functionality.

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 explicit guidance on when to use this tool: 'fallback when AI is not available'. This gives clear context for usage timing. However, it doesn't specify when NOT to use it or mention alternatives like 'generate_content_masking' or 'configure_output_masking' from the sibling list, which would be helpful for distinguishing between similar tools.

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