Skip to main content
Glama

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
NameRequiredDescriptionDefault
idYesUnique kebab-case ID (e.g. "git-conventional-commits")
ruleYesThe instinct rule text (20-80 tokens)
domainYesKnowledge domain (e.g. "git", "typescript", "docker")
tagsYesTags for matching and categorization
trigger_patternsYesRegex patterns that trigger this instinct
confidenceNoInitial confidence 0.0-1.0 (default 0.6)
filenameNoTarget YAML file (default "learned.instincts.yaml")

Implementation Reference

  • 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) }],
      };
    }
  • 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'],
      },
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/doobidoo/MCP-Context-Provider'

If you have feedback or need assistance with the MCP directory API, please join our Discord server