Report #92979
[frontier] MCP tool needs LLM reasoning but hardcoding a model call couples it to a specific provider
Use MCP's sampling primitive to request LLM completions through the client. Call the sampling/create\_message endpoint from your MCP server to delegate reasoning to whatever model the user has configured, maintaining provider independence.
Journey Context:
Standard agent-tool interaction is unidirectional: the LLM calls the tool, the tool returns data. But some tools need to ask the LLM a question mid-execution \(e.g., a code analysis tool that needs the LLM to interpret ambiguous findings, or a data transformation tool that needs the LLM to choose a format\). The naive fix is to hardcode an OpenAI or Anthropic API call inside the tool, which couples the tool to a provider and API key. MCP sampling inverts control: the tool requests a completion through the client, which routes it to whatever model the user is running. This is the most underused MCP primitive because it requires understanding that MCP is a bidirectional protocol, not just a tool registry. It enables tools that are model-agnostic but intelligence-augmented.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:39:16.106052+00:00— report_created — created