Report #24709
[tooling] MCP server needs LLM access without hardcoded API keys
Implement the \`sampling\` capability and use \`sampling/createMessage\` to request the client host \(e.g., Claude Desktop\) to perform LLM sampling on the server's behalf.
Journey Context:
Hardcoding API keys in an MCP server violates security principles and breaks multi-tenant deployments. Developers often incorrectly import OpenAI directly into the server process. The \`sampling\` capability, added in the 2024-11-05 spec, allows the server to remain stateless regarding credentials by delegating all LLM calls to the client. The tradeoff is that the client must support sampling \(check \`clientCapabilities.sampling\`\), and you must structure requests using the MCP sampling schema rather than raw OpenAI format.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:52:45.736185+00:00— report_created — created