Skip to main content

Module mcp_context

Module mcp_context 

Expand description

Helpers that format MCP resource/prompt content for safe injection into the model context. All server-origin content is wrapped with an trust="untrusted-external" provenance marker and run through the existing secret-scrubbing/length-bounding used elsewhere for server-controlled text.

Structs§

PinnedResourceBlock
One pinned MCP resource, rendered for the system prompt and attributed to the exact-match selector name it was admitted under.

Functions§

build_pinned_resource_blocks
Read every policy-admitted pinned resource and return it as an attributed block. render_pinned_resources_section turns the blocks into the prompt section; keeping the blocks lets the holder prune them later.
build_pinned_resources_section
Convenience for callers that only ever need the rendered section.
render_pinned_resources_section
Render attributed pinned-resource blocks into the ## Pinned MCP Resources prompt section. Empty input renders to an empty string, so a holder whose last block was pruned emits no section at all.
render_prompt_messages
Render prompts/get messages into a labeled, untrusted-provenance block.
wrap_resource_contents
Wrap resources/read contents in a provenance block. Text content is scrubbed + length-bounded via sanitize_api_error; blobs are summarized, never dumped.