{
  "name": "Keep Notes - Search & Summary",
  "nodes": [
    {
      "parameters": {},
      "id": "mcp-trigger-2",
      "name": "MCP Server Trigger",
      "type": "n8n-nodes-langchain.mcptrigger",
      "typeVersion": 1,
      "position": [250, 300],
      "webhookId": "memento-note-search",
      "description": "MCP trigger to search and summarize notes"
    },
    {
      "parameters": {
        "resource": "note",
        "operation": "get_all",
        "url": "http://localhost:3000/api/notes",
        "method": "GET"
      },
      "id": "get-notes-1",
      "name": "Get All Notes",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [500, 300],
      "sendHeaders": true,
      "headerParameters": {
        "parameters": [
          {
            "name": "Content-Type",
            "value": "application/json"
          }
        ]
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "condition-1",
              "leftValue": "={{ $json.title }}",
              "rightValue": "={{ $('MCP Server Trigger').item.json.searchQuery }}",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            },
            {
              "id": "condition-2",
              "leftValue": "={{ $json.content }}",
              "rightValue": "={{ $('MCP Server Trigger').item.json.searchQuery }}",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "id": "filter-1",
      "name": "Filter by Query",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.1,
      "position": [750, 300]
    },
    {
      "parameters": {
        "operation": "aggregate",
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldName": "id",
              "aggregateOperation": "count"
            },
            {
              "fieldName": "createdAt",
              "aggregateOperation": "max"
            },
            {
              "fieldName": "createdAt",
              "aggregateOperation": "min"
            }
          ]
        },
        "options": {}
      },
      "id": "aggregate-1",
      "name": "Aggregate Stats",
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [1000, 300],
      "continueOnFail": true
    },
    {
      "parameters": {
        "modelId": "openai/gpt-4",
        "prompt": "You are a helpful note summarizer. Analyze these notes and provide:\n\n1. **Summary**: A concise summary of all notes (2-3 sentences)\n2. **Key Themes**: List main topics found (bullet points)\n3. **Action Items**: Extract any action items or tasks\n4. **Related Notes**: Group notes by theme\n\nNotes to analyze:\n{{ $json.notes }}\n\nProvide the result in JSON format:"
      },
      "id": "ai-summarizer-1",
      "name": "AI Summarizer",
      "type": "n8n-nodes-langchain.agent",
      "typeVersion": 1.1,
      "position": [1250, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "searchQuery",
              "value": "={{ $('MCP Server Trigger').item.json.searchQuery }}",
              "type": "string"
            },
            {
              "name": "totalNotes",
              "value": "={{ $json.data.length }}",
              "type": "number"
            },
            {
              "name": "filteredCount",
              "value": "={{ $('Filter by Query').item.json.length }}",
              "type": "number"
            },
            {
              "name": "summary",
              "value": "={{ $json }}",
              "type": "object"
            },
            {
              "name": "notes",
              "value": "={{ $('Filter by Query').item.json }}",
              "type": "array"
            }
          ]
        },
        "options": {}
      },
      "id": "format-2",
      "name": "Format Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [1500, 300]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}"
      },
      "id": "mcp-response-2",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [1750, 300]
    }
  ],
  "connections": {
    "MCP Server Trigger": {
      "main": [
        [
          {
            "node": "Get All Notes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All Notes": {
      "main": [
        [
          {
            "node": "Filter by Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter by Query": {
      "main": [
        [
          {
            "node": "Aggregate Stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Stats": {
      "main": [
        [
          {
            "node": "AI Summarizer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Summarizer": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Response": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
        }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    {
      "createdAt": "2026-01-18T00:00:00.000Z",
      "id": "memento-note-mcp",
      "name": "Keep Notes MCP"
    }
  ],
  "triggerCount": 1,
  "updatedAt": "2026-01-18T00:00:00.000Z",
  "versionId": "1"
}
