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§
- Pinned
Resource Block - 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_sectionturns 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 Resourcesprompt 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/getmessages into a labeled, untrusted-provenance block. - wrap_
resource_ contents - Wrap
resources/readcontents in a provenance block. Text content is scrubbed + length-bounded viasanitize_api_error; blobs are summarized, never dumped.