claude-code.json•1.32 kB
{
"mcp": {
"servers": {
"notion-knowledge": {
"command": "node",
"args": ["./src/mcp-server.js"]
}
}
},
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "node -e \"const fs = require('fs'); const https = require('https'); const path = require('path'); try { const input = fs.readFileSync(0, 'utf8'); const data = JSON.parse(input); if (!data.tool_name || !['Write', 'Edit', 'MultiEdit'].includes(data.tool_name)) process.exit(0); const filePath = data.tool_input?.file_path; const content = data.tool_input?.content; if (!filePath || !content || content.length < 50) process.exit(0); const fileName = path.basename(filePath); const postData = JSON.stringify({ method: 'add_knowledge', params: { title: '自動記錄: ' + fileName, content: content.slice(0, 1000) + (content.length > 1000 ? '...' : ''), project: '其他', type: '代碼片段', file_path: filePath, keywords: [fileName], importance: '中' } }); const req = https.request('https://notion-knowledge.etjang10.workers.dev/call', { method: 'POST', headers: { 'Content-Type': 'application/json' } }, res => {}); req.write(postData); req.end(); } catch(e) {}\""
}
]
}
]
}
}