Skip to main content
Glama

zap.get_alerts

Retrieve security alerts from ZAP scans to identify vulnerabilities, with options to filter by URL, risk level, and paginate results.

Instructions

Get all security alerts from ZAP

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
baseURLNoFilter alerts by base URL (optional)
startNoStart index for pagination (optional)
countNoNumber of alerts to return (optional)
riskIdNoFilter by risk level: 0=Informational, 1=Low, 2=Medium, 3=High, 4=Critical (optional)

Implementation Reference

  • MCP tool handler for 'zap.get_alerts'. Retrieves ZAP client and calls getAlerts method with input parameters, handles client not initialized case, and formats the result.
    async ({ baseURL, start, count, riskId }: any): Promise<ToolResult> => {
      const client = getZAPClient();
      if (!client) {
        return formatToolResult(false, null, 'ZAP client not initialized');
      }
      const result = await client.getAlerts(baseURL, start, count, riskId);
      return formatToolResult(result.success, result.data, result.error);
    }
  • Input schema for the zap.get_alerts tool defining optional filtering parameters: baseURL, start, count, riskId.
    inputSchema: {
      type: 'object',
      properties: {
        baseURL: {
          type: 'string',
          description: 'Filter alerts by base URL (optional)',
        },
        start: {
          type: 'number',
          description: 'Start index for pagination (optional)',
        },
        count: {
          type: 'number',
          description: 'Number of alerts to return (optional)',
        },
        riskId: {
          type: 'string',
          description: 'Filter by risk level: 0=Informational, 1=Low, 2=Medium, 3=High, 4=Critical (optional)',
        },
      },
    },
  • src/index.ts:49-49 (registration)
    Top-level registration call to registerZAPTools on the MCP server, which registers the zap.get_alerts tool among others.
    registerZAPTools(server);
  • Specific registration of the 'zap.get_alerts' tool using server.tool, including schema and inline handler.
    'zap.get_alerts',
    {
      description: 'Get all security alerts from ZAP',
      inputSchema: {
        type: 'object',
        properties: {
          baseURL: {
            type: 'string',
            description: 'Filter alerts by base URL (optional)',
          },
          start: {
            type: 'number',
            description: 'Start index for pagination (optional)',
          },
          count: {
            type: 'number',
            description: 'Number of alerts to return (optional)',
          },
          riskId: {
            type: 'string',
            description: 'Filter by risk level: 0=Informational, 1=Low, 2=Medium, 3=High, 4=Critical (optional)',
          },
        },
      },
    },
    async ({ baseURL, start, count, riskId }: any): Promise<ToolResult> => {
      const client = getZAPClient();
      if (!client) {
        return formatToolResult(false, null, 'ZAP client not initialized');
      }
      const result = await client.getAlerts(baseURL, start, count, riskId);
      return formatToolResult(result.success, result.data, result.error);
    }
  • Core helper function ZAPClient.getAlerts: Makes API request to ZAP /alert/view/alerts/, handles various response formats, normalizes alert data, maps risk and confidence using private helpers.
    async getAlerts(baseURL?: string, start?: number, count?: number, riskId?: string): Promise<ZAPScanResult> {
      try {
        const params: any = {};
        if (baseURL) params.baseurl = baseURL;
        if (start !== undefined) params.start = start;
        if (count !== undefined) params.count = count;
        if (riskId) params.riskId = riskId;
    
        const response = await this.client.get('/alert/view/alerts/', { params });
        
        // Handle both array format and object format responses
        let alertsData: any[] = [];
        if (Array.isArray(response.data.alerts)) {
          alertsData = response.data.alerts;
        } else if (response.data.alerts && typeof response.data.alerts === 'object') {
          // If alerts is an object, convert to array
          alertsData = Object.values(response.data.alerts);
        } else if (Array.isArray(response.data)) {
          // Some ZAP versions return alerts directly as array
          alertsData = response.data;
        }
        
        const alerts: ZAPAlert[] = alertsData.map((alert: any) => ({
          id: alert.pluginId?.toString() || alert.id?.toString() || '',
          name: alert.alert || alert.name || 'Unknown Alert',
          risk: this.mapRisk(alert.risk || alert.riskString || 'Informational'),
          confidence: this.mapConfidence(alert.confidence || alert.confidenceString || 'Low'),
          url: alert.url || '',
          param: alert.param || undefined,
          attack: alert.attack || undefined,
          evidence: alert.evidence || undefined,
          description: alert.description || undefined,
          solution: alert.solution || undefined,
          reference: alert.reference || undefined,
        }));
    
        return {
          success: true,
          data: {
            alerts,
            count: alerts.length,
          },
        };
      } catch (error: any) {
        return {
          success: false,
          error: error.message || 'Failed to get alerts',
        };
      }
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 of behavioral disclosure. It states 'Get all security alerts' but doesn't clarify if this is a read-only operation, whether it requires authentication, what the response format is, or any rate limits. The description is minimal and leaves key behavioral traits unspecified.

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 with zero waste. It is front-loaded with the core purpose ('Get all security alerts from ZAP'), making it easy to scan and understand quickly without unnecessary elaboration.

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 the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is incomplete. It lacks details on behavioral traits, usage context, and output format, which are critical for a security tool. However, the schema provides good parameter coverage, preventing a lower score.

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 all four parameters with clear descriptions, including optional filters and pagination. The description adds no additional meaning beyond the schema, such as default values or usage examples, but the schema provides adequate baseline information.

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 ('Get') and resource ('all security alerts from ZAP'), making the purpose immediately understandable. It distinguishes from siblings like 'zap.get_alerts_summary' by specifying 'all' alerts rather than a summary, though it doesn't explicitly contrast with other alert-related tools.

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 'zap.get_alerts_summary' or other security testing tools. It lacks context about prerequisites, such as whether ZAP must be running or configured first, or any exclusions for when not to use it.

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/telmon95/VulneraMCP'

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