Skip to content

Sampling TransportMode http does not show sampling popup #809

@psyfreak

Description

@psyfreak

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions