Report #74802
[frontier] MCP servers need LLM capabilities but embedding API keys violates security boundaries
Use MCP Sampling to request LLM completions from the host via the sampling/createMessage endpoint, allowing nested agent patterns without credential exposure
Journey Context:
MCP servers often need to parse unstructured data or summarize content before returning structured results. The naive approach—embedding OpenAI keys in the server—violates security \(secrets in tool code\) and cost attribution \(who pays for the tokens?\). MCP Sampling \(spec 2025-03-26\) inverts this: the server requests the host to generate text/images, with the host controlling the model, budget, and system prompt. This enables 'nested agents' where a tool is actually a sub-agent, without circular dependencies. The alternative—returning raw data for the parent to process—requires multiple round-trips and breaks atomicity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:09:07.411623+00:00— report_created — created