Skip to main content
Glama
code-alchemist01

Development Tools MCP Server

detect_secrets

Identify hardcoded secrets and credentials in code files to prevent security vulnerabilities during development.

Instructions

Detect hardcoded secrets and credentials in code

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesYesFile paths to scan

Implementation Reference

  • The handler function for the 'detect_secrets' MCP tool. It processes input files, scans them using SecurityAnalyzer.scanSecurityIssues(), filters for secret-type issues, and returns a summary with detected secrets.
    case 'detect_secrets': {
      const files = params.files as string[];
      const codeFiles = await FileReader.readFiles(files.join(','));
      const issues = await securityAnalyzer.scanSecurityIssues(codeFiles);
      const secretIssues = issues.filter((i) => i.type === 'secret');
      return {
        total: secretIssues.length,
        secrets: secretIssues,
      };
    }
  • Tool schema definition for 'detect_secrets', including name, description, and inputSchema for MCP tool listing.
    {
      name: 'detect_secrets',
      description: 'Detect hardcoded secrets and credentials in code',
      inputSchema: {
        type: 'object',
        properties: {
          files: {
            type: 'array',
            items: { type: 'string' },
            description: 'File paths to scan',
          },
        },
        required: ['files'],
      },
    },
  • src/server.ts:18-25 (registration)
    Registration of codeAnalysisTools (containing detect_secrets) into the combined allTools array, which is returned by the MCP listTools handler.
    const allTools = [
      ...codeAnalysisTools,
      ...codeQualityTools,
      ...dependencyAnalysisTools,
      ...lintingTools,
      ...webScrapingTools,
      ...apiDiscoveryTools,
    ];
  • src/server.ts:62-64 (registration)
    Dispatch logic in MCP callTool handler that routes 'detect_secrets' calls to handleCodeAnalysisTool based on tool name matching in codeAnalysisTools.
    if (codeAnalysisTools.some((t) => t.name === name)) {
      result = await handleCodeAnalysisTool(name, args || {});
    } else if (codeQualityTools.some((t) => t.name === name)) {
  • Core helper function implementing secret detection logic via regex pattern matching on code lines. Called from SecurityAnalyzer.scanSecurityIssues() which is invoked by the tool handler.
    private detectSecrets(file: CodeFile): SecurityIssue[] {
      const issues: SecurityIssue[] = [];
      const lines = file.content.split('\n');
    
      // Common secret patterns
      const secretPatterns = [
        {
          pattern: /(?:password|passwd|pwd)\s*[=:]\s*["']([^"']+)["']/gi,
          type: 'password' as const,
          severity: 'critical' as const,
        },
        {
          pattern: /(?:api[_-]?key|apikey)\s*[=:]\s*["']([^"']+)["']/gi,
          type: 'api_key' as const,
          severity: 'critical' as const,
        },
        {
          pattern: /(?:secret|token)\s*[=:]\s*["']([^"']+)["']/gi,
          type: 'secret' as const,
          severity: 'high' as const,
        },
        {
          pattern: /(?:aws[_-]?access[_-]?key|aws[_-]?secret)\s*[=:]\s*["']([^"']+)["']/gi,
          type: 'aws_credentials' as const,
          severity: 'critical' as const,
        },
        {
          pattern: /(?:private[_-]?key|ssh[_-]?key)\s*[=:]\s*["']([^"']+)["']/gi,
          type: 'private_key' as const,
          severity: 'critical' as const,
        },
      ];
    
      for (let i = 0; i < lines.length; i++) {
        const line = lines[i];
        for (const { pattern, type, severity } of secretPatterns) {
          if (pattern.test(line)) {
            issues.push({
              type: 'secret',
              severity,
              location: `${file.path}:${i + 1}`,
              description: `Potential hardcoded ${type} detected`,
              recommendation: 'Move secrets to environment variables or secure configuration',
              detectedAt: new Date(),
            });
          }
        }
      }
    
      return issues;
    }
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 the tool detects secrets but doesn't disclose behavioral traits such as what types of secrets are detected (e.g., API keys, passwords), whether it's a read-only scan, if it requires specific permissions, or how results are returned. This leaves significant gaps for a security 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 directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it easy to understand at a glance.

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 secret detection and the lack of annotations and output schema, the description is insufficient. It doesn't explain what constitutes a 'secret', the detection methodology, output format, or error handling. For a security-focused tool with no structured support, more context is needed for effective use.

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%, with the parameter 'files' clearly documented as 'File paths to scan'. The description adds no additional meaning beyond this, such as file format support or scanning depth. With high schema coverage, the baseline score of 3 is appropriate as the schema handles parameter documentation adequately.

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 tool's purpose with a specific verb ('detect') and resource ('hardcoded secrets and credentials in code'). It distinguishes from most siblings that analyze other aspects like bundle size, dependencies, or code quality, though it doesn't explicitly differentiate from 'scan_security_issues' which might overlap in security scanning.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing code files), exclusions (e.g., not for runtime secrets), or comparisons to similar tools like 'scan_security_issues' or 'check_compliance' that might handle security aspects.

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/code-alchemist01/development-tools-mcp-Server'

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