Report #9811
[tooling] MCP server needs LLM access but cannot hold API keys
Implement the sampling/createMessage capability to request completions from the client instead of calling LLMs directly; declare sampling capability in server init and handle the CreateMessageRequest schema
Journey Context:
Servers often need to summarize, transform, or reason over content using an LLM, but embedding API keys violates security boundaries and configuration portability. Rather than direct API calls, the MCP sampling capability allows the server to request the client \(who already has configured keys\) to perform the completion. This maintains the security model where only the client holds credentials, while enabling servers to perform multi-step reasoning. Most developers miss this capability because it requires explicit capability negotiation during initialization and handling async requests from server to client, which is the inverse of the normal tool call flow.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:11:33.435075+00:00— report_created — created