store_instinct
Add new behavior rules to the MCP Context Provider for persistent automation across chat sessions. Stores rules with trigger patterns and tags for automatic application.
Instructions
Store a new instinct candidate. Created as inactive with auto approval — use approve_instinct for human approval.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Unique kebab-case ID (e.g. "git-conventional-commits") | |
| rule | Yes | The instinct rule text (20-80 tokens) | |
| domain | Yes | Knowledge domain (e.g. "git", "typescript", "docker") | |
| tags | Yes | Tags for matching and categorization | |
| trigger_patterns | Yes | Regex patterns that trigger this instinct | |
| confidence | No | Initial confidence 0.0-1.0 (default 0.6) | |
| filename | No | Target YAML file (default "learned.instincts.yaml") |
Implementation Reference
- src/server/index.ts:314-360 (handler)The tool 'store_instinct' is implemented within the switch statement of the 'CallToolRequestSchema' handler in 'src/server/index.ts'. It uses 'InstinctLoader' to load/save instinct configurations.
case 'store_instinct': { const id = String(args?.['id'] ?? ''); const rule = String(args?.['rule'] ?? ''); const domain = String(args?.['domain'] ?? ''); const tags = (args?.['tags'] as string[]) ?? []; const trigger_patterns = (args?.['trigger_patterns'] as string[]) ?? []; const confidence = Number(args?.['confidence'] ?? 0.6); const filename = String(args?.['filename'] ?? 'learned.instincts.yaml'); if (!id || !rule || !domain) { return { content: [{ type: 'text', text: 'Error: id, rule, and domain are required' }] }; } const loader = new InstinctLoader(resolve(INSTINCTS_PATH)); let instinctFile: InstinctFile; try { instinctFile = await loader.load(filename); } catch { instinctFile = { version: '1.0', instincts: {} }; } if (instinctFile.instincts[id]) { return { content: [{ type: 'text', text: `Error: instinct "${id}" already exists` }] }; } const now = new Date().toISOString(); instinctFile.instincts[id] = { id, rule, domain, tags, trigger_patterns, confidence, min_confidence: 0.5, usage_count: 0, approved_by: 'auto', outcome_log: [], active: false, created_at: now, updated_at: now, }; await loader.save(filename, instinctFile); return { content: [{ type: 'text', text: JSON.stringify({ stored: id, file: filename, status: 'inactive — use approve_instinct to activate' }, null, 2) }], }; } - src/server/index.ts:142-166 (registration)Registration of the 'store_instinct' tool within the 'ListToolsRequestSchema' handler, defining its input schema and description.
name: 'store_instinct', description: 'Store a new instinct candidate. Created as inactive with auto approval — use approve_instinct for human approval.', inputSchema: { type: 'object' as const, properties: { id: { type: 'string', description: 'Unique kebab-case ID (e.g. "git-conventional-commits")' }, rule: { type: 'string', description: 'The instinct rule text (20-80 tokens)' }, domain: { type: 'string', description: 'Knowledge domain (e.g. "git", "typescript", "docker")' }, tags: { type: 'array', items: { type: 'string' }, description: 'Tags for matching and categorization', }, trigger_patterns: { type: 'array', items: { type: 'string' }, description: 'Regex patterns that trigger this instinct', }, confidence: { type: 'number', description: 'Initial confidence 0.0-1.0 (default 0.6)' }, filename: { type: 'string', description: 'Target YAML file (default "learned.instincts.yaml")' }, }, required: ['id', 'rule', 'domain', 'tags', 'trigger_patterns'], }, },