Title: Simple echo MCP server fails to start with `mcp.run()` · Issue #337 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Simple echo MCP server fails to start with `mcp.run()` · Issue #337 · modelcontextprotocol/python-sdk
X Title: Simple echo MCP server fails to start with `mcp.run()` · Issue #337 · modelcontextprotocol/python-sdk
Description: Describe the bug Unable to start MCP server To Reproduce from mcp.server.fastmcp import FastMCP mcp = FastMCP( "Echo Server", port=9000, debug=True, log_level="DEBUG", ) @mcp.tool() def echo(text: str) -> str: """Echo the input text""" r...
Open Graph Description: Describe the bug Unable to start MCP server To Reproduce from mcp.server.fastmcp import FastMCP mcp = FastMCP( "Echo Server", port=9000, debug=True, log_level="DEBUG", ) @mcp.tool() def echo(text: ...
X Description: Describe the bug Unable to start MCP server To Reproduce from mcp.server.fastmcp import FastMCP mcp = FastMCP( "Echo Server", port=9000, debug=True, log_level="DEBUG", ) @mcp.to...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/337
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Simple echo MCP server fails to start with `mcp.run()`","articleBody":"**Describe the bug**\nUnable to start MCP server\n\n**To Reproduce**\n```python\nfrom mcp.server.fastmcp import FastMCP\n\nmcp = FastMCP(\n \"Echo Server\",\n port=9000,\n debug=True,\n log_level=\"DEBUG\",\n)\n\n\n@mcp.tool()\ndef echo(text: str) -\u003e str:\n \"\"\"Echo the input text\"\"\"\n return text\n\n\nif __name__ == \"__main__\":\n mcp.run()\n```\n\n```shell\n$ uv run mcp_server.py \n[03/20/25 16:31:00] DEBUG Using selector: EpollSelector \n\u003c---HANG---\u003e\n```\n\n```shell\n$ curl http://localhost:9000\ncurl: (7) Failed to connect to localhost port 9000 after 0 ms: Could not connect to server\n```\n\n**Expected behavior**\nServer starts\n\n### Additional information\nStack trace on SIGINT\n```\n File \"/home/sirianni/src/example/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py\", line 2303, in run\n return runner.run(wrapper())\n ^^^^^^^^^^^^^^^^^^^^^\n File \"/home/sirianni/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/asyncio/runners.py\", line 118, in run\n return self._loop.run_until_complete(task)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/sirianni/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/asyncio/base_events.py\", line 678, in run_until_complete\n self.run_forever()\n File \"/home/sirianni/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/asyncio/base_events.py\", line 645, in run_forever\n self._run_once()\n File \"/home/sirianni/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/asyncio/base_events.py\", line 1961, in _run_once\n event_list = self._selector.select(timeout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/sirianni/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/selectors.py\", line 468, in select\n fd_event_list = self._selector.poll(timeout, max_ev)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/sirianni/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/asyncio/runners.py\", line 157, in _on_sigint\n raise KeyboardInterrupt()\nKeyboardInterrupt\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"/home/sirianni/src/example/mcp_server.py\", line 18, in \u003cmodule\u003e\n mcp.run()\n File \"/home/sirianni/src/example/.venv/lib/python3.12/site-packages/mcp/server/fastmcp/server.py\", line 154, in run\n anyio.run(self.run_stdio_async)\n File \"/home/sirianni/src/example/.venv/lib/python3.12/site-packages/anyio/_core/_eventloop.py\", line 74, in run\n return async_backend.run(func, args, {}, backend_options)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/sirianni/src/example/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py\", line 2302, in run\n with Runner(debug=debug, loop_factory=loop_factory) as runner:\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/sirianni/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/asyncio/runners.py\", line 62, in __exit__\n self.close()\n File \"/home/sirianni/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/asyncio/runners.py\", line 70, in close\n _cancel_all_tasks(loop)\n File \"/home/sirianni/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/asyncio/runners.py\", line 199, in _cancel_all_tasks\n to_cancel = tasks.all_tasks(loop)\n ^^^^^^^^^^^^^^^^^^^^^\n File \"/home/sirianni/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/asyncio/tasks.py\", line 59, in all_tasks\n scheduled_tasks = list(_scheduled_tasks)\n ^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/sirianni/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/_weakrefset.py\", line 64, in __iter__\n with _IterationGuard(self):\n ^^^^^^^^^^^^^^^^^^^^^\nKeyboardInterrupt\n```","author":{"url":"https://github.com/sirianni","@type":"Person","name":"sirianni"},"datePublished":"2025-03-20T20:32:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/337/python-sdk/issues/337"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:57995ca8-c003-302b-1fc5-2614ff134e9f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DC0C:21DBC5:568B26:71FCBA:6A5B9287 |
| html-safe-nonce | 43d895c5459f924181a777507c9b59cf5681299e52ef951b1604d45be5401e70 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQzBDOjIxREJDNTo1NjhCMjY6NzFGQ0JBOjZBNUI5Mjg3IiwidmlzaXRvcl9pZCI6Ijc3ODcwMjA2Mzg1MzIzNzUxNzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 85ad7d689397d6073472a543554ef15e4ac06d07987e261c1b363d646e9aaf0a |
| hovercard-subject-tag | issue:2936581013 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/337/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b778942c6537efb3a1c3c8f4a8b730cefa21e9fe19a22ea505c5a12b421d39d5/modelcontextprotocol/python-sdk/issues/337 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b778942c6537efb3a1c3c8f4a8b730cefa21e9fe19a22ea505c5a12b421d39d5/modelcontextprotocol/python-sdk/issues/337 |
| og:image:alt | Describe the bug Unable to start MCP server To Reproduce from mcp.server.fastmcp import FastMCP mcp = FastMCP( "Echo Server", port=9000, debug=True, log_level="DEBUG", ) @mcp.tool() def echo(text: ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sirianni |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width