Skip to content

MCP Feature Request: Support Client Sampling #10704

@yaonyan

Description

@yaonyan

What would you like to be added?

Add MCP Client Sampling support to Gemini CLI, following the MCP Specification.

This would enable MCP servers to call language models through Gemini CLI, similar to how VS Code with GitHub Copilot already supports this feature.

Key capabilities needed:

  • Handle sampling/createMessage requests from MCP servers
  • Support model preferences (hints, cost/speed/intelligence priorities)
  • Forward requests to appropriate Gemini models based on preferences

Why is this needed?

Enables Agentic MCP Tools: Without sampling support, MCP servers can only provide simple deterministic tools. With sampling, they become intelligent agents that can reason and make decisions.

Practical Example - Background Code Style Checker:

While coding, you start an MCP style checker tool that returns immediately, then works silently in the background.

It monitors file saves and uses AI (via sampling) to analyze violations in context - understanding your project's conventions and complexity patterns.

All this reasoning happens in the background while the developer continues working. The MCP server leverages Gemini's AI through sampling, without requiring its own API key.

Benefits:

  • Users don't need separate API keys for each MCP server
  • Users control which Gemini model is used (balancing cost vs intelligence)
  • Enables intelligent, context-aware MCP tools that can reason about complex tasks
  • Provides feature parity with VS Code (which already supports this)

Additional context

Live demo with sampling supported:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitypriority/p2Important but can be addressed in a future release.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions