Skip to content

appendMcpServerInstructionsNote

appendMcpServerInstructionsNote(systemPrompt, instructions): string | undefined

Defined in: _worktrees/docs-release/gaunt-sloth/packages/core/src/utils/systemPromptNotes.ts:323

EXT-32: append connected MCP servers’ discovery instructions to the composed system prompt.

Each connected MCP server may return an instructions string in its initialize handshake that describes how to use its tools. We surface those to the model — but the text is server-supplied and therefore a prompt-injection surface, so it is:

  • fenced in an explicit [BEGIN/END MCP SERVER-PROVIDED CONTEXT] block (never blended into first-party prompt text),
  • labelled per server (--- Server: "name" ---) so the model can attribute each block, and
  • bracketed by a leading framing line AND a trailing first-party reassertion, so the LAST thing the model reads is gsloth’s own authority, not the server text — server instructions may not override the system instructions, safety rules, or the user’s directives.

Backend-agnostic: composed through the shared path so BOTH the lean GthLangChainAgent and the deep GthDeepAgent inject it. Empty/absent contributes NOTHING: when no server supplied (non-whitespace) instructions the base prompt is returned unchanged — no empty header, no dangling label. Each server’s text is trimmed and capped at MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER. Returns the block alone when there is no base prompt.

string | undefined

McpServerInstruction[] | undefined

string | undefined