You are helping me build the following AI agent workflow. ## Goal Secure MongoDB Data Retrieval API: Exposes a secure GET endpoint to fetch all documents from a specified MongoDB collection, validating input and normalizing IDs. ## Specification - What it does: You get secure access to all documents in your specified MongoDB collection through a validated GET endpoint that prevents injection attacks and unauthorized system access. The tool automatically normalizes IDs and returns consistent JSON responses with proper status codes for reliable integration. - Trigger: Triggered by an event (Event ยท on HTTP GET request) - Autonomy: Fully hands-off - Expected setup effort: about an afternoon - Tools/services involved: - n8n: Workflow orchestration and webhook handling - MongoDB: Database storage and document retrieval - Code: Input validation and data transformation ## Known pitfalls, handle each one explicitly in your implementation 1. Regex patterns can be bypassed with encoded characters, so add strict type checking on the input string before applying regex. 2. MongoDB ObjectIds are not JSON serializable by default, so you must explicitly convert them to strings in your transformation code. 3. Exposing raw database errors can leak schema details, so wrap all database calls in try-catch blocks and return generic error messages. ## Reference implementation https://n8n.io/workflows/7674 (workflow template) Fetch and inspect this before building. If it matches my stack, adapt it; if not, rebuild the pattern with my tools. ## Process requirements 1. Before building: ask me which of the listed tools I actually use and what my platform is (n8n / Make / code / other). Do not assume. 2. Adapt the pattern to my answers; do not force the reference stack. 3. Address every pitfall above; tell me how you handled each. 4. Provide a test plan I can run before letting this touch real data. 5. Ask before any step that sends messages, modifies data, or spends money. Source: https://usecasesforagents.com/use-case/secure-mongodb-data-retrieval-api/ via usecasesforagents.com