Skip to content

MCP Sampling with Tools #286648

Description

Type: Feature Request

The latest versions of the Model Context Protocol and FastMCP support "sampling WITH TOOLS" (see: https://modelcontextprotocol.io/specification/2025-11-25/client/sampling and https://gofastmcp.com/servers/sampling#sampling-with-tools). When trying this with VS-Code an error is reported: Client does not support sampling with tools. The client must advertise the sampling.tools capability.. It would be nice to see this supported.

VS Code version: Code 1.107.1 (Universal) (994fd12, 2025-12-17T14:15:14.850Z)
OS version: Darwin arm64 25.1.0
Modes:

Activity

  1. vs-code-engineering commented on Jan 9, 2026

    @vs-code-engineering
    Contributor

    Thanks for creating this issue! It looks like you may be using an old version of VS Code; the latest stable release is 1.108.0. Please try upgrading to the latest version and checking whether this issue remains.

    Happy Coding!

  2. connor4312 commented on Jan 9, 2026

    @connor4312
    Member

    yup, this is blocked on #277472 which I expect to resolve this iteration

  3. HansBouwmeester commented on Jan 10, 2026

    @HansBouwmeester
    Author

    I tried it with 1.108.0 however it responds with the same error. Would be good to understand whether it should work or not. In case it should be supported already I can file a bug report with a minimal example illustrating the issue.

  4. tecnocrata commented on Jan 11, 2026

    @tecnocrata

    I tried it with 1.108.0 however it responds with the same error. Would be good to understand whether it should work or not. In case it should be supported already I can file a bug report with a minimal example illustrating the issue.

    Same error here with a MCP implemented using FastMCP

  5. ScatterTemple commented on Jan 25, 2026

    @ScatterTemple

    I encountered the same issue with my own MCP tool that includes sampling with tool calls, implemented using the Python MCP SDK, and that led me to this issue.

    I updated VS Code to version 1.108.2, but in the example below, the generate_weather_report tool results in the same error:
    Error executing tool generate_weather_report: Client does not support sampling tools capability.

    from mcp.server.fastmcp import Context, FastMCP
    from mcp.server.session import ServerSession
    from mcp.types import SamplingMessage, TextContent
    import mcp.types as types
    
    
    # Create an MCP server
    mcp = FastMCP("Demo")
    
    
    @mcp.tool()
    async def weather_report(location: str, ctx: Context[ServerSession, None]) -> str:
        """Returns tommorow's weather.
        
        :param location: location.
        :type location: str
        :return: Weather.
        :rtype: str
        """
        prompt = "Write a random weather term."
        result = await ctx.session.create_message(
            messages=[
                SamplingMessage(
                    role="user",
                    content=TextContent(type="text", text=prompt),
                )
            ],
            max_tokens=100,
        )
    
        return result.content.text
    
    
    @mcp.tool()
    async def generate_weather_report(ctx: Context[ServerSession, None]) -> str:
        """Generate a weather report using LLM sampling."""
    
        prompt = "Write a short report about tommorow's weather."
        tools = await mcp.list_tools()
        available_tools = [t for t in tools if t.name == "weather_report"]
        tool_choice: types.ToolChoice = types.ToolChoice(mode="required")
    
        result = await ctx.session.create_message(
            messages=[
                SamplingMessage(
                    role="user",
                    content=TextContent(type="text", text=prompt),
                )
            ],
            max_tokens=100,
            tools=available_tools,
            tool_choice=tool_choice,
        )
    
        # Returns dummy string
        return "The tommorow Tokyo's weather is sunny."
    
    
    if __name__ == "__main__":
        mcp.run(transport="stdio")
  6. meceonzo commented on Feb 13, 2026

    @meceonzo

    Same issue when delegating tools via MCP Sampling:

    result = await ctx.session.create_message(
                messages=messages,
                system_prompt=_TRIAGE_SYSTEM_PROMPT,
                max_tokens=4096,
                include_context="none",
                tools=_SCOPED_TOOLS,
                tool_choice=ToolChoice(mode="auto"),
            )

    tools.triage - ERROR - MCP sampling failed for triage: Client does not support sampling tools capability

  7. mjbvz commented on Mar 17, 2026

    @mjbvz
    Contributor

    Moving to 1.113 since this does not seem like a candidate for 1.112. Please move it back if this is incorrect

  8. modified the milestones: 1.112.0, on Mar 17, 2026
  9. modified the milestones: , 1.114.0 on Mar 23, 2026
  10. removed this from the 1.114.0 milestone on Mar 30, 2026
  11. faiz95ahmed commented on Apr 28, 2026

    @faiz95ahmed

    This is still an issue in 1.115.0

  12. connor4312 commented on Apr 29, 2026

    @connor4312
    Member

    jfyi I don't plan to work on this at the moment as sampling overall is potentially going to be deprecated in the next MCP version.

  13. connor4312 commented on May 15, 2026

    @connor4312
    Member

    The MCP PR that deprecates sampling as been merged. Thus I don't plan to do work here, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*out-of-scopePosted issue is not in scope of VS Codechatchat-mcpfeature-requestRequest for new features or functionality

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions