Guest User

mcp-error-401-unauthorized-fix

a guest
Jan 14th, 2026
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. Traceback (most recent call last):
  2. File "./openai-agents-python/.venv/lib/python3.13/site-packages/mcp/client/streamable_http.py", line 405, in handle_request_async
  3. await self._handle_post_request(ctx)
  4. File "./openai-agents-python/.venv/lib/python3.13/site-packages/mcp/client/streamable_http.py", line 277, in _handle_post_request
  5. response.raise_for_status()
  6. ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  7. File "./openai-agents-python/.venv/lib/python3.13/site-packages/httpx/_models.py", line 829, in raise_for_status
  8. raise HTTPStatusError(message, request=request, response=self)
  9. httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'http://localhost:8000/mcp'
  10. For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
  11.  
  12. The above exception was the direct cause of the following exception:
  13.  
  14. Traceback (most recent call last):
  15. File "./openai-agents-python/test.py", line 39, in <module>
  16. asyncio.run(main())
  17. ~~~~~~~~~~~^^^^^^^^
  18. File "./.local/share/uv/python/cpython-3.13.9-macos-aarch64-none/lib/python3.13/asyncio/runners.py", line 195, in run
  19. return runner.run(main)
  20. ~~~~~~~~~~^^^^^^
  21. File "./.local/share/uv/python/cpython-3.13.9-macos-aarch64-none/lib/python3.13/asyncio/runners.py", line 118, in run
  22. return self._loop.run_until_complete(task)
  23. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  24. File "./.local/share/uv/python/cpython-3.13.9-macos-aarch64-none/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
  25. return future.result()
  26. ~~~~~~~~~~~~~^^
  27. File "./openai-agents-python/test.py", line 28, in main
  28. async with MCPServerStreamableHttp(
  29. ~~~~~~~~~~~~~~~~~~~~~~~^
  30. name="Streamable HTTP Python Server",
  31. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  32. ...<3 lines>...
  33. },
  34. ^^
  35. ) as server:
  36. ^
  37. File "./openai-agents-python/src/agents/mcp/server.py", line 278, in __aenter__
  38. await self.connect()
  39. File "./openai-agents-python/src/agents/mcp/server.py", line 405, in connect
  40. await self.cleanup()
  41. File "./openai-agents-python/src/agents/mcp/server.py", line 528, in cleanup
  42. raise UserError(
  43. ...<3 lines>...
  44. ) from http_error
  45. agents.exceptions.UserError: Failed to connect to MCP server 'Streamable HTTP Python Server': Authentication failed (401 Unauthorized). Please check your credentials.
Advertisement
Add Comment
Please, Sign In to add comment