Skip to main content
Glama

build_injection

Creates injection payloads with contexts and instincts for specific tool-input combinations to automate rule and preference application.

Instructions

Build a complete injection payload (contexts + instincts) for a tool/input combination

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toolYesTool name or pattern
inputYesInput text to match instincts against

Implementation Reference

  • The core business logic that builds the injection payload by combining context matches and instinct matches.
    buildInjection(tool: string, input: string): InjectionPayload {
      // 1. Match contexts (always full confidence)
      const contextMatches = this.matchContexts({ tool });
      const context_rules: InjectionRule[] = contextMatches.map((m) => ({
        source: 'context' as const,
        id: m.context.tool_category,
        content: JSON.stringify(m.context),
        confidence: 1.0,
        matched_by: m.matched_pattern,
      }));
    
      // 2. Match instincts (confidence-scored)
      const instinctMatches = this.matchInstincts({ input });
      const instinct_rules: InjectionRule[] = instinctMatches.map((m) => ({
        source: 'instinct' as const,
        id: m.instinct.id,
        content: m.instinct.rule,
        confidence: m.instinct.confidence,
        matched_by: m.matched_pattern,
      }));
    
      // 3. Estimate tokens
      const estimateTokens = (text: string) =>
        text.split(/\s+/).filter(Boolean).length;
      const estimated_tokens =
        context_rules.reduce((sum, r) => sum + estimateTokens(r.content), 0) +
        instinct_rules.reduce((sum, r) => sum + estimateTokens(r.content), 0);
  • MCP tool handler registration and request dispatching for build_injection.
    case 'build_injection': {
      const tool = String(args?.['tool'] ?? '*');
      const input = String(args?.['input'] ?? '');
      const payload = engine.buildInjection(tool, input);
      return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
    }
  • MCP schema definition for the build_injection tool.
    {
      name: 'build_injection',
      description:
        'Build a complete injection payload (contexts + instincts) for a tool/input combination',
      inputSchema: {
        type: 'object' as const,
        properties: {
          tool: { type: 'string', description: 'Tool name or pattern' },
          input: {
            type: 'string',
            description: 'Input text to match instincts against',
          },
        },
        required: ['tool', 'input'],
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but fails to disclose whether this tool is read-only (generates payload) or persistent, what format the payload takes, error conditions, or size constraints. The term 'Build' is ambiguous regarding state mutation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with the action. Mostly efficient, though 'complete' is filler adjective that doesn't add measurable criteria. Appropriate length for the complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a 2-parameter tool with full schema coverage, but lacks explanation of the output (no output schema exists) and domain-specific jargon ('injection payload', 'instincts') is undefined. Without annotations, minimal behavioral context is provided.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 100% coverage with clear descriptions ('Tool name or pattern', 'Input text to match instincts against'). The description references 'tool/input combination' which aligns parameters to the operation but adds no syntax, format details, or examples beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses specific verb 'Build' and resource 'injection payload', clarifying it constructs a composite object. It distinguishes from siblings like store_instinct or list_available_contexts by explicitly mentioning 'contexts + instincts' as combined components, indicating this is an aggregation operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this versus alternatives like get_tool_context or store_instinct. No mention of prerequisites (e.g., whether instincts must be pre-approved) or when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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