Skip to content

GitHub MCP Server looks unreachable in HTTP (but works using Docker) #931

@mickaelandrieu

Description

@mickaelandrieu

Describe the bug

I try to access GitHub MCP Server with Python and I get a 400 HTTP error.

Affected version

Successfully installed mcp-1.13.0 uvicorn-0.35.0

Steps to reproduce the behavior

  1. Get a GITHUB_PAT
  2. Complete and execute the provided script
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

GITHUB_TOKEN = "XXXXX"

async def main():
    # Connect to a streamable HTTP serverstreamastreamablehttp_client
    async with streamablehttp_client(
        "https://api.githubcopilot.com/mcp/",
        {
            "Authorization": f"""Bearer ${GITHUB_TOKEN}"""
        }
    ) as (
        read_stream,
        write_stream,
        _,
    ):
        # Create a session using the client streams
        async with ClientSession(read_stream, write_stream) as session:
            # Initialize the connection
            await session.initialize()
            # List available tools
            tools = await session.list_tools()
            print(f"Available tools: {[tool.name for tool in tools.tools]}")


if __name__ == "__main__":
    asyncio.run(main())
  1. See error

Expected vs actual behavior

Expected: the list of available tools

(venv) ➜  mcp-client ./venv/bin/python stdio_github_mcp_docker_ok.py             
time=2025-08-20T10:06:34.182Z level=INFO msg="starting server" version=v0.12.1 host="" dynamicToolsets=false readOnly=false
GitHub MCP Server running on stdio
add_comment_to_pending_review
add_issue_comment
add_sub_issue
assign_copilot_to_issue
cancel_workflow_run
create_and_submit_pull_request_review
create_branch
create_gist
create_issue
create_or_update_file
create_pending_pull_request_review
create_pull_request
...

Current: an HTTP 400 error

Logs

Here is the error message:

(venv) ➜  mcp-client ./venv/bin/python http_github_mcp.py
  + Exception Group Traceback (most recent call last):
  |   File "/home/dev/Projects/sfeir/mcp-client/http_github_mcp.py", line 31, in <module>
  |     asyncio.run(main())
  |   File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
  |     return runner.run(main)
  |            ^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
  |     return self._loop.run_until_complete(task)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
  |     return future.result()
  |            ^^^^^^^^^^^^^^^
  |   File "/home/dev/Projects/sfeir/mcp-client/http_github_mcp.py", line 11, in main
  |     async with streamablehttp_client(
  |   File "/usr/lib/python3.12/contextlib.py", line 231, in __aexit__
  |     await self.gen.athrow(value)
  |   File "/home/dev/Projects/sfeir/mcp-client/venv/lib/python3.12/site-packages/mcp/client/streamable_http.py", line 476, in streamablehttp_client
  |     async with anyio.create_task_group() as tg:
  |   File "/home/dev/Projects/sfeir/mcp-client/venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__
  |     raise BaseExceptionGroup(
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/home/dev/Projects/sfeir/mcp-client/venv/lib/python3.12/site-packages/mcp/client/streamable_http.py", line 407, in handle_request_async
    |     await self._handle_post_request(ctx)
    |   File "/home/dev/Projects/sfeir/mcp-client/venv/lib/python3.12/site-packages/mcp/client/streamable_http.py", line 278, in _handle_post_request
    |     response.raise_for_status()
    |   File "/home/dev/Projects/sfeir/mcp-client/venv/lib/python3.12/site-packages/httpx/_models.py", line 829, in raise_for_status
    |     raise HTTPStatusError(message, request=request, response=self)
    | httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://api.githubcopilot.com/mcp/'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions