Skip to main content
Glama
git-fabric

@git-fabric/chat

Official
by git-fabric

chat_context_inject

Add external context like memory recall, documentation, or runtime state to chat sessions before sending messages. Injects content as messages for AI completions.

Instructions

Inject external context into a session before the next message send. Use this to pipe in Aiana memory recall, documentation snippets, or runtime state. The injected content is stored as a message and included in the next completion call.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesUUID of the session to inject context into.
contextYesContext content to inject (markdown, JSON, plain text).
roleNoRole for the injected context message. Default: system.

Implementation Reference

  • The injectContext function implements the core logic for chat_context_inject tool. It creates a new message in the session with the provided context content and role (system or user), adds metadata tracking the injection timestamp, and returns the created message ID.
    export async function injectContext(
      adapter: ChatAdapter,
      sessionId: string,
      context: string,
      role: "system" | "user" = "system",
    ): Promise<{ messageId: string; sessionId: string; role: string }> {
      const msg = await adapter.addMessage({
        sessionId,
        role,
        content: context,
        metadata: { injected: true, injectedAt: new Date().toISOString() },
      });
      return { messageId: msg.id, sessionId, role };
    }
  • src/app.ts:275-305 (registration)
    Registration of the chat_context_inject tool in the tools array. Defines the tool's name, description, input schema (sessionId, context, role), and executes the injectContext function from layers.messages module.
    {
      name: "chat_context_inject",
      description:
        "Inject external context into a session before the next message send. Use this to pipe in Aiana memory recall, documentation snippets, or runtime state. The injected content is stored as a message and included in the next completion call.",
      inputSchema: {
        type: "object",
        properties: {
          sessionId: {
            type: "string",
            description: "UUID of the session to inject context into.",
          },
          context: {
            type: "string",
            description: "Context content to inject (markdown, JSON, plain text).",
          },
          role: {
            type: "string",
            enum: ["system", "user"],
            description: "Role for the injected context message. Default: system.",
          },
        },
        required: ["sessionId", "context"],
      },
      execute: async (args) =>
        layers.messages.injectContext(
          adapter,
          args.sessionId as string,
          args.context as string,
          args.role as "system" | "user" | undefined,
        ),
    },
  • ChatMessage interface defining the data structure for messages, including role field which supports 'system' and 'user' values used by the context injection feature. The metadata field allows storing injection tracking information.
    export interface ChatMessage {
      id: string;             // UUID v4
      sessionId: string;
      role: "user" | "assistant" | "system";
      content: string;
      model?: ChatModel;      // set on assistant messages
      inputTokens?: number;   // set on assistant messages
      outputTokens?: number;  // set on assistant messages
      timestamp: string;      // ISO-8601
      metadata?: Record<string, unknown>;
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden and effectively discloses key behavioral traits: it describes the action ('inject'), the effect ('stored as a message and included in the next completion call'), and the timing ('before the next message send'). It lacks details on permissions or error handling, but covers essential operation context.

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

Conciseness5/5

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

The description is front-loaded and efficiently structured in two sentences: the first states the purpose and usage, the second explains the behavioral outcome. Every sentence adds value without redundancy, making it appropriately concise.

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

Completeness4/5

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

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is mostly complete: it clarifies the tool's role, usage timing, and behavioral effects. However, it could improve by mentioning potential side effects or error cases, though the lack of output schema is mitigated by the clear description of the injection process.

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 description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema by implying the context parameter's purpose ('external context'), but does not provide additional syntax or format details. This meets the baseline for high schema coverage.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verbs ('inject external context') and resources ('into a session'), and distinguishes it from siblings by specifying it prepares content 'before the next message send', unlike chat_message_send or chat_search which handle different actions.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('before the next message send') and examples of what to inject ('Aiana memory recall, documentation snippets, or runtime state'), but does not explicitly state when not to use it or name alternatives among siblings like chat_message_send.

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/git-fabric/chat'

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