inspector icon indicating copy to clipboard operation
inspector copied to clipboard

Can't list tools of python server when using poetry command

Open simone-gaiarin opened this issue 7 months ago • 2 comments

Describe the bug When listing tools of a python server connected with stdio using the inspector and using poetry instead of uv the following errors appears: Error: "Error POSTing to endpoint (HTTP 500): SSE connection not established"

Not clear why it attempts a SSE connection if the protocol is set to STDIO.

To Reproduce Steps to reproduce the behavior:

  1. Create server.py with the code reported in the example
  2. Start the server with poetry run mcp dev server.py
  3. Set transport type to STDIO
  4. Set command to poetry
  5. Set arguments to run mcp run server.py
  6. Click Connect (successful connection)
  7. Click List tools

Expected behavior The tools are listed.

Additional context

  • It works if run with uv as explained in the quickstart
  • server code:
# server.py
from mcp.server.fastmcp import FastMCP

# Create an MCP server
mcp = FastMCP("Demo")


# Add an addition tool
@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b


# Add a dynamic greeting resource
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
    """Get a personalized greeting"""
    return f"Hello, {name}!"

simone-gaiarin avatar May 16 '25 10:05 simone-gaiarin

@simone-gaiarin
Hey there, might not be the same issue as for you but thought of leaving this here to see if it helps:

TLDR: Is the server running?

For me, the reason was that simply the error displayed is more confusing than not. I had instantiated the server and that does correctly get initialized when inspecting it (Connection succeeds), but it does not stay alive past initialization if it's not explicitly running. Listing the tools returned that weird error as well. I only later found out that that error is thrown (independently of your MCP server transport type) if the message can't be posted.

I discovered this by trying my MCP server in VSCode, and saw in the logs that it spawned up and then down immediately.

is mcp.run() being called somewhere for you?

estib-vega avatar May 26 '25 11:05 estib-vega

I figured out the problem. If there are multiple tabs open in the browser with npx inspector, the situation above happens.

To solve the problem close all inspector browser tabs and re-launch the inspector

Steps to reproduce the problem:

  1. Close all tabs with the inspector and kill all the inspector processes
  2. Start the server with poetry run mcp dev server.py
  3. Set transport type to STDIO
  4. Set command to poetry
  5. Set arguments to run mcp run server.py
  6. Click Connect (successful connection)
  7. Click List tools (successful listing of tools)
  8. Duplicate the browser tab
  9. Click Connect (successful connection)
  10. Click List tools (ambiguos SSE error)

Note that the following block is not needed in server.py; the inspector knows how to run the mcp server with the right protocol:

if __name__ == "__main__":
    mcp.run(transport="stdio")

I think that the error reporting can be improved.

simone-gaiarin avatar May 28 '25 10:05 simone-gaiarin

@simone-gaiarin

Thanks for the clear reproduction steps.

However, at step 8 (duplicate tab), the new tab has Command uv, and Arguments run --with mcp mcp run server.py -- as expected, because the default values are set in the Inspector at startup. So, given the use of Poetry and the known need to change the Command and Arguments, in the duplicate tab one wouldn't immediate click Connect (step 9); but instead, adjust the Command and Arguments. After that, Connect and List Tools work.

If Connect is clicked immediately, then of course uv with args is executed and expected errors appear in the Error output from MCP server sidebar pane.

I don't think there is a bug here, and error messages seem correct too. Can this be closed?

richardkmichael avatar Aug 19 '25 19:08 richardkmichael

I tried the steps I reported again and indeed when the tab is duplicated the uv command is present. I believe I did report the steps incorrectly, because I'm quite sure I could replicate the problem when two tabs with the right poetry commands were open at the same time.

In fact if I try to connect with the second tab with the uv command I can't connect at all, while when I tested I could connect to then get the SSE connection not established above.

Trying again today I can use two tabs at the same time once the right poetry commands are set, so I would say we can close this given that I am not able to reproduce the error again.

simone-gaiarin avatar Sep 04 '25 16:09 simone-gaiarin