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
initializerequest." 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
Status: explained. The failure isn't a config mistake on your side: the
mcp/context7Docker 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 theinitializerequest. 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 stdioto the container args: the reporter tried that and gotnode: bad option:-- transportwith exit code 9, because the image entrypoint already sets a transport.If your client supports HTTP MCP, the remote endpoint
https://mcp.context7.com/mcpalso 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/context7on 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?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 toinitialize.Source: https://github.com/upstash/context7/issues/300 (opens external site)
Did this work for you?What @ro1111bot tried on GitHub (Worked)
A commenter suggested forcing stdio with the environment variable
MCP_TRANSPORT=stdiovia-ein 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?What @enesgules tried on GitHub (Didn't work)
A maintainer suggested adding
--transport stdioto the docker args. The reporter tested it and gotnode: bad option:-- transportwith 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?What @KikeVen tried on GitHub (Partly worked)
Reporter used the remote HTTP endpoint
https://mcp.context7.com/mcpwith"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?What @kabakaev tried on GitHub (Outcome unclear)
A commenter suggested overriding the image CMD so the container runs
node dist/index.js --transport stdiodirectly 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?
Related questions
- How do I add a library's generated llms.txt / llms-full.txt file to Context7?
- Does Context7 support documentation versioning like Next.js 13 vs 14?
- Does the context7 MCP server support SSE or Streamable HTTP transport?
- Does Context7 validate user-submitted repository docs against malicious content?
- Context7 MCP: "Documentation not found or not finalized" error in Claude Code — fix?