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
| Name | Required | Description | Default |
|---|---|---|---|
| contextName | Yes | Name for the context |
Implementation Reference
- src/tools/zap.ts:427-450 (registration)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); } );
- src/integrations/zap.ts:331-349 (helper)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);