Skip to main content
Glama

zap.create_context

Set up a scanning context in ZAP to organize and manage security testing sessions for web application vulnerability assessment.

Instructions

Create a scanning context in ZAP

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNameYesName for the context

Implementation Reference

  • MCP tool registration for 'zap.create_context'. Includes input schema (requires contextName string), description, and handler function that uses ZAPClient.createContext.
    server.tool(
      'zap.create_context',
      {
        description: 'Create a scanning context in ZAP',
        inputSchema: {
          type: 'object',
          properties: {
            contextName: {
              type: 'string',
              description: 'Name for the context',
            },
          },
          required: ['contextName'],
        },
      },
      async ({ contextName }: any): Promise<ToolResult> => {
        const client = getZAPClient();
        if (!client) {
          return formatToolResult(false, null, 'ZAP client not initialized');
        }
        const result = await client.createContext(contextName);
        return formatToolResult(result.success, result.data, result.error);
      }
    );
  • ZAPClient.createContext method: core logic that calls ZAP REST API endpoint '/context/action/newContext/' to create a new scanning context and returns contextId.
    async createContext(contextName: string): Promise<ZAPScanResult> {
      try {
        const response = await this.client.get('/context/action/newContext/', {
          params: { contextName },
        });
        return {
          success: true,
          data: {
            contextId: parseInt(response.data.contextId),
            name: contextName,
          },
        };
      } catch (error: any) {
        return {
          success: false,
          error: error.message || 'Failed to create context',
        };
      }
    }
  • src/index.ts:49-49 (registration)
    Top-level server initialization calls registerZAPTools(server), which registers the zap.create_context tool among other ZAP tools.
    registerZAPTools(server);

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