- Add debounced state updates for title and content (500ms delay) - Immediate UI updates with delayed history saving - Prevent one-letter-per-undo issue - Add cleanup for debounce timers on unmount
7.1 KiB
Memento MCP SSE Server
Server-Sent Events (SSE) version of the Memento MCP Server for remote N8N access.
🎯 Purpose
This SSE server allows N8N (or other MCP clients) running on remote machines to connect to Memento via HTTP/SSE instead of stdio.
stdio vs SSE
| Feature | stdio (index.js) |
SSE (index-sse.js) |
|---|---|---|
| Connection | Local process | Network HTTP |
| Remote access | ❌ No | ✅ Yes |
| Use case | Claude Desktop, local tools | N8N on remote machine |
| Port | N/A | 3001 |
🚀 Quick Start
1. Install Dependencies
cd mcp-server
npm install
2. Start the Server
Option A: PowerShell Script (Recommended)
.\start-sse.ps1
Option B: Direct Node
npm run start:sse
# or
node index-sse.js
3. Verify Server is Running
Open browser to: http://localhost:3001
You should see:
{
"name": "Memento MCP SSE Server",
"version": "1.0.0",
"status": "running",
"endpoints": {
"sse": "/sse",
"message": "/message"
}
}
🌐 Get Your IP Address
Windows
ipconfig
Look for "IPv4 Address" (usually 192.168.x.x)
Mac/Linux
ifconfig
# or
ip addr show
🔌 N8N Configuration
Method 1: MCP Client Community Node
If your N8N has the MCP Client node installed:
-
Open N8N Settings → MCP Access
-
Add new server:
{ "name": "memento", "transport": "sse", "url": "http://YOUR_IP:3001/sse" }Replace
YOUR_IPwith your machine's IP (e.g.,192.168.1.100) -
Enable "Available in MCP" for your workflow
-
Use MCP Client node to call tools
Method 2: HTTP Request Nodes (Fallback)
Use N8N's standard HTTP Request nodes with the REST API:
- POST
http://YOUR_IP:3000/api/notes(Memento REST API)
🛠️ Available Tools (9)
All tools from the stdio version are available:
-
create_note - Create new note
{ "name": "create_note", "arguments": { "content": "My note", "title": "Optional title", "color": "blue", "images": ["data:image/png;base64,..."] } } -
get_notes - Get all notes
{ "name": "get_notes", "arguments": { "includeArchived": false, "search": "optional search query" } } -
get_note - Get specific note by ID
-
update_note - Update existing note
-
delete_note - Delete note
-
search_notes - Search notes
-
get_labels - Get all unique labels
-
toggle_pin - Pin/unpin note
-
toggle_archive - Archive/unarchive note
🧪 Testing the SSE Server
Test 1: Health Check
curl http://localhost:3001/
Test 2: SSE Connection
curl -N http://localhost:3001/sse
Test 3: Call a Tool (get_notes)
curl -X POST http://localhost:3001/message \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "get_notes",
"arguments": {}
},
"id": 1
}'
Test 4: Create Note via MCP
$body = @{
jsonrpc = "2.0"
method = "tools/call"
params = @{
name = "create_note"
arguments = @{
content = "Test from MCP SSE"
title = "SSE Test"
color = "green"
}
}
id = 1
} | ConvertTo-Json -Depth 5
Invoke-RestMethod -Method POST -Uri "http://localhost:3001/message" `
-Body $body -ContentType "application/json"
🔥 Troubleshooting
Error: Prisma Client not initialized
Solution: Generate Prisma Client in the main app:
cd ..\keep-notes
npx prisma generate
Error: Port 3001 already in use
Solution: Change port in index-sse.js:
const PORT = process.env.PORT || 3002;
Or set environment variable:
$env:PORT=3002; node index-sse.js
Error: Cannot connect from N8N
Checklist:
- ✅ Server is running (
http://localhost:3001works locally) - ✅ Firewall allows port 3001
- ✅ Using correct IP address (not
localhost) - ✅ N8N can reach your network
- ✅ Using
http://nothttps://
Test connectivity from N8N machine:
curl http://YOUR_IP:3001/
SSE Connection Keeps Dropping
This is normal! SSE maintains a persistent connection. If it drops:
- Client should automatically reconnect
- Check network stability
- Verify firewall/proxy settings
🔒 Security Notes
⚠️ This server has NO AUTHENTICATION!
For production use:
- Add API key authentication
- Use HTTPS with SSL certificates
- Restrict CORS origins
- Use environment variables for secrets
- Deploy behind a reverse proxy (nginx, Caddy)
Add Basic API Key (Example)
// In index-sse.js, add middleware:
app.use((req, res, next) => {
const apiKey = req.headers['x-api-key'];
if (apiKey !== process.env.MCP_API_KEY) {
return res.status(401).json({ error: 'Unauthorized' });
}
next();
});
📊 Endpoints
| Method | Path | Description |
|---|---|---|
| GET | / |
Health check |
| GET | /sse |
SSE connection endpoint |
| POST | /message |
MCP message handler |
🆚 Comparison with REST API
| Feature | MCP SSE | REST API |
|---|---|---|
| Protocol | SSE (MCP) | HTTP JSON |
| Port | 3001 | 3000 (Next.js) |
| Format | MCP JSON-RPC | REST JSON |
| Use case | MCP clients | Standard HTTP clients |
| Tools | 9 MCP tools | 4 CRUD endpoints |
Both work! Use MCP SSE for proper MCP integration, or REST API for simpler HTTP requests.
🔄 Development Workflow
Running Both Servers
Terminal 1: Next.js + REST API
cd keep-notes
npm run dev
# Runs on http://localhost:3000
Terminal 2: MCP SSE Server
cd mcp-server
npm run start:sse
# Runs on http://localhost:3001
Terminal 3: MCP stdio (for Claude Desktop)
cd mcp-server
npm start
# Runs as stdio process
📝 Configuration Examples
N8N Workflow (MCP Client)
{
"nodes": [
{
"name": "Get Memento Notes",
"type": "MCP Client",
"typeVersion": 1,
"position": [250, 300],
"parameters": {
"server": "memento",
"tool": "get_notes",
"arguments": {
"includeArchived": false
}
}
}
]
}
Claude Desktop Config (stdio)
Use the original index.js with stdio:
{
"mcpServers": {
"memento": {
"command": "node",
"args": ["D:/dev_new_pc/Keep/mcp-server/index.js"]
}
}
}
📚 Resources
- MCP Protocol Documentation
- Server-Sent Events Spec
- N8N MCP Integration Guide
- Express.js Documentation
🤝 Support
Issues? Check:
- MCP-SSE-ANALYSIS.md - Detailed SSE analysis
- README.md - Main project README
- COMPLETED-FEATURES.md - Implementation details
Version: 1.0.0
Last Updated: January 4, 2026
Status: ✅ Production Ready