query_knowledge_base_document
Query CSV documents in the RAD Security knowledge base using natural language questions to extract security insights from structured data.
Instructions
Query a CSV document from the knowledge base using natural language. IMPORTANT: This tool ONLY works with CSV documents. Use list_knowledge_base_documents with filters='file_type:csv' to find CSV document IDs (search_knowledge_base results also contain document IDs). Results are returned as a markdown table
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| document_id | Yes | The ID of the CSV document to query. Use list_knowledge_base_documents with filters='file_type:csv' to find CSV document IDs. Document IDs are also available in search_knowledge_base results. This will fail if the document is not a CSV file. | |
| query | Yes | Natural language question to execute against the CSV document. The system will analyze the CSV structure and generate the appropriate query (e.g., 'Show me all rows where severity is critical', 'Count the number of vulnerabilities by type', 'Show me the owner of asset IKM99832'). |
Implementation Reference
- src/operations/knowledge-base.ts:129-146 (handler)The core handler function `structuredQueryDocument` that executes the tool logic by sending a POST request to the RAD Security API endpoint `/knowledge_base/documents/{documentId}/query` with the natural language query.export async function structuredQueryDocument( client: RadSecurityClient, documentId: string, query: string, ): Promise<any> { const tenantId = await client.getTenantId(); const body = { query }; return client.makeRequest( `/tenants/${tenantId}/accounts/${client.getAccountId()}/knowledge_base/documents/${documentId}/query`, {}, { method: "POST", body: body, } ); }
- Zod schema defining the input parameters: `document_id` (string) and `query` (string) for the tool.export const StructuredQueryDocumentSchema = z.object({ document_id: z.string().describe("The ID of the CSV document to query. Use list_knowledge_base_documents with filters='file_type:csv' to find CSV document IDs. Document IDs are also available in search_knowledge_base results. This will fail if the document is not a CSV file."), query: z.string().describe("Natural language question to execute against the CSV document. The system will analyze the CSV structure and generate the appropriate query (e.g., 'Show me all rows where severity is critical', 'Count the number of vulnerabilities by type', 'Show me the owner of asset IKM99832')."), });
- src/index.ts:569-575 (registration)Tool registration in the listTools handler, defining the tool name, description, and input schema (converted from Zod).name: "query_knowledge_base_document", description: "Query a CSV document from the knowledge base using natural language. IMPORTANT: This tool ONLY works with CSV documents. Use list_knowledge_base_documents with filters='file_type:csv' to find CSV document IDs (search_knowledge_base results also contain document IDs). Results are returned as a markdown table", inputSchema: zodToJsonSchema( knowledgeBase.StructuredQueryDocumentSchema ), },
- src/index.ts:1519-1533 (registration)Tool call handler in the CallToolRequest handler that parses arguments with the schema and invokes the structuredQueryDocument handler function.case "query_knowledge_base_document": { const args = knowledgeBase.StructuredQueryDocumentSchema.parse( request.params.arguments ); const response = await knowledgeBase.structuredQueryDocument( client, args.document_id, args.query ); return { content: [ { type: "text", text: JSON.stringify(response, null, 2) }, ], }; }