inspector icon indicating copy to clipboard operation
inspector copied to clipboard

Sampling TransportMode http does not show sampling popup

Open psyfreak opened this issue 3 months ago • 3 comments

Inspector Version

  • 0.16.7

Describe the bug The inspector does not show the sampling approval popup with transport mode "http" instead of transport mode "stdio".

To Reproduce

  1. start an mcp server with transport streaming-http and a tool (see below) with mcpServer.server.createMessage
  2. run the inspector and connect via transport type streaming-http
  3. Run the tool
  4. See timeout error and no popup to approve the sampling request.

Expected behavior There should be a sampling request like with transport mode "stdio" resulting in no timeout in mcpServer.server.createMessage.

Environment

  • OS: windows
  • Browser chrome

Additional context

    mcpServer.registerTool(
        "create-random-user",
        {
            title: "Create Random User Tool",
            description: "Create a random user with fake data",
            annotations: {
                readOnlyHint: false,
                destructiveHint: false,
                idempotentHint: false,
                openWorldHint: true
            }
        },
        async () => {
            try {
                const caps = mcpServer.server.getClientCapabilities() ?? {};
                console.error("Client capabilities", caps);
                if (!caps.sampling) {
                    return {
                        isError: true,
                        content: [{ type: "text", text: "Client does not support MCP sampling." }]
                    };
                }
               const response = await mcpServer.server.createMessage({
                        messages: [
                            {
                                role: "user",
                                content: {
                                    type: "text",
                                    text: `Generate fake user data. The user should have a realistic name and email.
                                    Return this data as a json object with name and email fields only. No other text so it can be used with JSON.parse.`,
                                },
                            },
                        ],
                        maxTokens: 1024,
                    });
                console.error("createMessage response", response);
//create user etc. and return content object.

psyfreak avatar Sep 16 '25 14:09 psyfreak

Probably the same issue as mentioned in elicitation timeout. Stateless server is most likely the issue.

Update: Confirmed - Sampling works with a stateful server with transport http-streamable and the best, this change also solved the issue that createMessage / logging was not working as well in the inspector. I think the documentation should be maybe extended for streamable stateless vs stateful (which features are working).

psyfreak avatar Sep 17 '25 21:09 psyfreak

Added the documentation label in case this needs to be clarified in docs.

olaservo avatar Sep 29 '25 15:09 olaservo

What is the limitation that prevents stateless servers from leveraging sampling? I just ran into this as well.

edkimmel avatar Oct 30 '25 01:10 edkimmel