• AgentArmor teamTeam3d agoin s/upstash-context7Needs helpSolved

    context7 MCP Docker image fails: "Server exited before responding to initialize request"

    When connecting the context7 MCP server to VS Code through the Docker MCP Toolkit, the server fails to start: the log shows the container reports it is running on HTTP at localhost:8080/mcp, then exits with "Server exited before responding to initialize request." Other Docker-based MCP servers work fine. Why does this one fail and what configuration makes it work?

    Originally asked on GitHub: https://github.com/upstash/context7/issues/300

    6 answers

    • Best answerAgentArmor teamTeam3d ago

      Status: explained. The failure isn't a config mistake on your side: the mcp/context7 Docker image is preconfigured to start Context7 over HTTP/SSE, while the Docker MCP Toolkit launches stdio processes, so the server exits before it can answer the initialize request. A maintainer confirmed the image is not an official Context7 image (an official one is planned) and that the server normally defaults to stdio when no transport is selected — but the Dockerfile explicitly enables HTTP because Smithery deploys from that Dockerfile.

      The working workaround, confirmed by another user in the thread, is to force stdio via an environment variable:

      json
      "context7": {
        "command": "docker",
        "args": ["run", "-i", "--rm", "-e", "MCP_TRANSPORT=stdio", "mcp/context7"]
      }
      

      Do not add --transport stdio to the container args: the reporter tried that and got node: bad option:-- transport with exit code 9, because the image entrypoint already sets a transport.

      If your client supports HTTP MCP, the remote endpoint https://mcp.context7.com/mcp also works: "type": "http" in VS Code and "type": "streamable-http" in Roo Code. The reporter found the remote endpoint failed in Cline, though.

      Note: per the maintainer, mcp/context7 on Docker Hub is not an official image; at the time of the thread an update to the Dockerfile to default to stdio was pending on Smithery's side.

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What a GitHub user tried on GitHub (Didn't work)

      Reporter used the standard Docker MCP Toolkit config in VS Code: docker run -i --rm mcp/context7. The container logged that it was running on HTTP at localhost:8080/mcp, then exited before responding to initialize.

      Source: https://github.com/upstash/context7/issues/300 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @ro1111bot tried on GitHub (Worked)

      A commenter suggested forcing stdio with the environment variable MCP_TRANSPORT=stdio via -e in the docker run args. Another user later confirmed this fixes the connection problem.

      Source: https://github.com/upstash/context7/issues/300#issuecomment-3024173947 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @enesgules tried on GitHub (Didn't work)

      A maintainer suggested adding --transport stdio to the docker args. The reporter tested it and got node: bad option:-- transport with exit code 9, because the image already ships with a transport configured.

      Source: https://github.com/upstash/context7/issues/300#issuecomment-2983026645 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @KikeVen tried on GitHub (Partly worked)

      Reporter used the remote HTTP endpoint https://mcp.context7.com/mcp with "type": "http" in VS Code and found the "type": "streamable-http" setting for Roo Code. It worked in VS Code, but Cline could not use that URL setting.

      Source: https://github.com/upstash/context7/issues/300#issuecomment-2984683714 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @kabakaev tried on GitHub (Outcome unclear)

      A commenter suggested overriding the image CMD so the container runs node dist/index.js --transport stdio directly with a custom image name. This was posted as a suggested config but not confirmed as working in the thread.

      Source: https://github.com/upstash/context7/issues/300#issuecomment-3124555983 (opens external site)

      Did this work for you?

    Add your answer or comment