Skip to content

[Feature Request] Support for MCP Sampling to leverage Claude Max subscriptions and reduce API costs #1785

Description

@mateuszmazurek

Support for MCP Sampling to leverage Claude Max subscriptions and reduce API costs

Problem

Currently, Claude Code, when acting as an MCP (Model Context Protocol) client, does not support (based on the feature support matrix from https://github.com/modelcontextprotocol/docs/blob/main/clients.mdx) the "sampling" feature of the MCP. This means that any MCP server connected to Claude Code, requiring an LLM inference, must make a direct API call to the Anthropic API.

While many Claude Code users benefit from the nearly unlimited usage provided by a Claude Max subscription, this direct API inference leads to additional "pay-as-you-go" costs for every server-initiated request. This creates an unexpected financial burden and complexity for users who assumed their Max subscription would cover the majority of their Claude usage, including server-side interactions.

Solution

Claude Code should be updated to fully support the MCP "sampling" feature: https://modelcontextprotocol.io/specification/2025-03-26/client/sampling

With sampling support, when an MCP server needs an LLM inference, it would send a sampling/createMessage request to the Claude Code client (the user's instance). This would allow the Claude Code client to:

  1. Utilize the user's existing Claude Max subscription: The inference request would be processed by the user's locally running Claude Code instance, falling under their subscription's usage limits, eliminating the need for the MCP server to manage separate API keys or directly configure access to the Anthropic API.
  2. Provide human-in-the-loop oversight (optional but beneficial): The user could review and approve/edit the prompt before it's sent to Claude, and review the completion before it's returned to the MCP server, leveraging Claude Code's existing interactive capabilities. This enhances transparency and control.
  3. Reduce pay-as-you-go API costs: This would eliminate the need for MCP servers to make direct API calls for inferences, significantly reducing unexpected costs for Claude Max subscribers.

Summary

The MCP "sampling" feature is designed precisely for scenarios where a server requires LLM assistance but wants to delegate the actual inference and associated costs/control to the client. Implementing this feature in Claude Code would align it more closely with the broader MCP philosophy and significantly enhance the value proposition for Claude Max subscribers who integrate Claude Code with custom MCP servers.

This would make Claude Code a more cost-effective and flexible solution for advanced agentic workflows.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions