Skip to main content
Glama

validate_security_mozilla_observatory

Analyze website security headers like CSP and HSTS using Mozilla Observatory to identify vulnerabilities and improve protection.

Instructions

Analyze HTTP security headers using Mozilla Observatory. Tests CSP, HSTS, etc. Free API, 1 scan per minute per domain.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
forceRescanNoForce new scan (default: false)

Implementation Reference

  • Core handler function that executes the Mozilla Observatory security scan via API, extracts hostname, fetches scan results, handles errors, and formats the response with grade, score, and test results.
    export async function analyzeMozillaObservatory(
      url: string,
      options: MozillaObservatoryOptions = {}
    ): Promise<MozillaObservatoryResult> {
      try {
        // Extract hostname from URL
        const hostname = new URL(url).hostname;
    
        // Build API URL
        const apiUrl = `https://observatory-api.mdn.mozilla.net/api/v2/scan?host=${encodeURIComponent(hostname)}`;
    
        // Make POST request to trigger/retrieve scan
        const response = await fetch(apiUrl, {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
        });
    
        if (!response.ok) {
          throw new Error(`Mozilla Observatory API error: ${response.status} ${response.statusText}`);
        }
    
        const data: MozillaObservatoryResponse = await response.json();
    
        // Check for API errors
        if (data.error) {
          return {
            tool: 'mozilla_observatory',
            success: false,
            grade: 'F',
            score: 0,
            tests_passed: 0,
            tests_failed: 0,
            scanned_at: data.scanned_at || new Date().toISOString(),
            details_url: data.details_url || '',
            error: data.error,
            raw: data,
          };
        }
    
        // Return formatted result
        return {
          tool: 'mozilla_observatory',
          success: true,
          grade: data.grade,
          score: data.score,
          tests_passed: data.tests_passed,
          tests_failed: data.tests_failed,
          scanned_at: data.scanned_at,
          details_url: data.details_url,
          raw: data,
        };
      } catch (error) {
        return {
          tool: 'mozilla_observatory',
          success: false,
          grade: 'F',
          score: 0,
          tests_passed: 0,
          tests_failed: 0,
          scanned_at: new Date().toISOString(),
          details_url: '',
          error: error instanceof Error ? error.message : String(error),
        };
      }
    }
  • index.ts:202-213 (registration)
    Tool registration in the MCP server tools array, defining name, description, and input schema.
    {
      name: 'validate_security_mozilla_observatory',
      description: 'Analyze HTTP security headers using Mozilla Observatory. Tests CSP, HSTS, etc. Free API, 1 scan per minute per domain.',
      inputSchema: {
        type: 'object',
        properties: {
          url: { type: 'string' },
          forceRescan: { type: 'boolean', description: 'Force new scan (default: false)' },
        },
        required: ['url'],
      },
    },
  • Zod schema for validating input arguments to the Mozilla Observatory tool.
    const MozillaObservatoryArgsSchema = z.object({
      url: z.string().url(),
      forceRescan: z.boolean().optional(),
    });
  • Dispatch handler in the main switch statement that validates args, calls the core analyze function, and returns JSON result.
    case 'validate_security_mozilla_observatory': {
      const validatedArgs = MozillaObservatoryArgsSchema.parse(args);
      const result = await analyzeMozillaObservatory(validatedArgs.url, {
        forceRescan: validatedArgs.forceRescan,
      });
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
    }
  • TypeScript interfaces defining input options, API response, and output result structures for the tool.
    export interface MozillaObservatoryOptions {
      /** Force a rescan (default: false, uses cached results if < 1 minute old) */
      forceRescan?: boolean;
    }
    
    export interface MozillaObservatoryResponse {
      id: number;
      details_url: string;
      algorithm_version: number;
      scanned_at: string;
      error: string | null;
      grade: string;
      score: number;
      status_code: number;
      tests_failed: number;
      tests_passed: number;
      tests_quantity: number;
    }
    
    export interface MozillaObservatoryResult {
      tool: 'mozilla_observatory';
      success: boolean;
      grade: string;
      score: number;
      tests_passed: number;
      tests_failed: number;
      scanned_at: string;
      details_url: string;
      error?: string;
      raw?: MozillaObservatoryResponse;
    }
Behavior3/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. It adds useful context: 'Free API, 1 scan per minute per domain' informs about cost and rate limits, and 'Analyze HTTP security headers' implies a read-only operation. However, it doesn't detail error handling, response format, or what happens during a scan (e.g., timeouts, retries), leaving gaps for a tool with no output schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two sentences: the first states the purpose, and the second adds behavioral context. It's front-loaded with the core function, and each sentence adds value without redundancy. However, it could be slightly more structured by explicitly separating usage guidelines.

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

Completeness3/5

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

Given no annotations, no output schema, and 2 parameters with 50% schema coverage, the description is moderately complete. It covers the tool's purpose and some behavioral traits (rate limits, cost) but lacks details on parameters, return values, and error handling. For a security analysis tool, this leaves significant gaps in understanding how to use it 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 50% (only 'forceRescan' has a description). The description adds no parameter-specific information beyond what the schema provides. It mentions 'domain' in the rate limit context, which loosely relates to the 'url' parameter but doesn't explain format or constraints. With low coverage, the description fails to compensate, resulting in a baseline score.

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: 'Analyze HTTP security headers using Mozilla Observatory. Tests CSP, HSTS, etc.' It specifies the verb ('analyze'), resource ('HTTP security headers'), and method ('Mozilla Observatory'), distinguishing it from sibling tools like validate_security_ssl_labs. However, it doesn't explicitly differentiate from other security tools beyond mentioning the specific focus on headers.

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

Usage Guidelines3/5

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

The description provides some implied usage context by mentioning 'Free API, 1 scan per minute per domain,' which suggests rate limits and when to use it for scanning. However, it lacks explicit guidance on when to choose this tool over alternatives like validate_security_ssl_labs or validate_all_security, and no exclusions or prerequisites are stated.

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/cordlesssteve/webby-mcp'

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