zap.create_context
Create a scanning context in ZAP to organize and manage security testing sessions for vulnerability assessment.
Instructions
Create a scanning context in ZAP
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contextName | Yes | Name for the context |
Implementation Reference
- src/integrations/zap.ts:331-349 (handler)Core handler logic that performs the HTTP request to ZAP's API endpoint /context/action/newContext/ to create a new scanning context.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/tools/zap.ts:428-450 (registration)MCP tool registration including input schema, description, and wrapper handler that initializes ZAP client and calls the core createContext method.'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); } );
- src/index.ts:49-49 (registration)Top-level registration call that invokes registerZAPTools to add all ZAP tools, including zap.create_context, to the MCP server.registerZAPTools(server);
- src/integrations/zap.ts:3-7 (schema)Type definition for the return type of ZAP API calls, used by createContext and the tool handler.export interface ZAPScanResult { success: boolean; data?: any; error?: string; }