Skip to content

HTTP and Docker

You run the server over Streamable HTTP, or from a Docker image, when a client wants a URL instead of a command, or when you want the server in a container. Both put a network port in front of your index.

  • The HTTP server has no authentication. Anyone who can reach its port can search your index.
  • It listens on 127.0.0.1 by default, so only your computer reaches it. Keep it there.
  • Any other address needs a proxy with authentication in front.
  • On every address the server answers only the Host names localhost, 127.0.0.1 and [::1], plus each name you add with --allowed-host. Behind a reverse proxy, add the name the proxy sends.
Terminal window
corpus serve --http

The server listens on http://127.0.0.1:8765/mcp. --host and --port change the address, and a --host that is not a loopback address needs --allow-remote-bind (see “What the port exposes”). It answers each request on its own, with a plain JSON body and no session id, so any copy of the server can take any request.

$ corpus serve --http --port 8767
INFO engineering_corpus.server: serving .../demo-only
INFO engineering_corpus.server: listening on http://127.0.0.1:8767/mcp, and on /chatgpt/mcp for ChatGPT's search and fetch
INFO: Uvicorn running on http://127.0.0.1:8767 (Press CTRL+C to quit)

This run used port 8767 so it would not collide with another server on 8765.

Call a tool with any HTTP client. The Accept header must list both types:

$ curl -s -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"corpus_status","arguments":{}}}' \
http://127.0.0.1:8767/mcp
{"jsonrpc": "2.0", "id": 1, "result": {"content": [{"text": "{\n \"version\": \"0.1.0\",\n \"repos_indexed\": 2,\n \"repos_registered\": 2,\n \"repos_unscanned\": 0\n}", "type": "text"}], "isError": false, "structuredContent": {"version": "0.0.1", "repos_indexed": 2, "repos_registered": 2, "repos_unscanned": 0}}}
Terminal window
claude mcp add --transport http engineering-corpus http://127.0.0.1:8765/mcp

The server must be running first. This is the real output of the same command against the server on port 8767, followed by the health check:

$ claude mcp add --transport http engineering-corpus-http http://127.0.0.1:8767/mcp
Added HTTP MCP server engineering-corpus-http with URL: http://127.0.0.1:8767/mcp to local config
File modified: .../claude-cfg/.claude.json [project: .../proj]
$ claude mcp list
engineering-corpus-http: http://127.0.0.1:8767/mcp (HTTP) - ✔ Connected
$ codex mcp add engineering-corpus-http --url http://127.0.0.1:8765/mcp
Added global MCP server 'engineering-corpus-http'.
MCP server may or may not require login. Run `codex mcp login engineering-corpus-http` to login.

Codex prints that second line for every URL server. This server has no login, so skip codex mcp login. The entry that Codex wrote to its config.toml:

[mcp_servers.engineering-corpus-http]
url = "http://127.0.0.1:8765/mcp"
  • The server has no authentication: it checks no key, token or password. Every tool is read-only, but any caller can read every file the index serves.

  • The server refuses requests from a foreign web page, on every address. It checks the Host and Origin headers of each request. It answers localhost, 127.0.0.1 and [::1], and each name you add with --allowed-host. Another Host gets status 421 and another Origin gets 403. The security model shows the real refusals. These checks stop a web page in your browser. They do not identify a caller: a program sends any Host it likes.

  • An address that is not a loopback address needs --allow-remote-bind. The server has no authentication, so on such an address it would answer anyone who can reach it. It refuses to start there without the flag:

    Terminal window
    $ corpus serve --http --host 0.0.0.0
    corpus: --host '0.0.0.0' is not a loopback address, and the HTTP server has no authentication, so it would answer anyone who can reach it. Use 127.0.0.1, or pass --allow-remote-bind when a proxy with authentication is in front, or the port is published on localhost only

    The command exits with status 2. With --allow-remote-bind the server starts, still without authentication, so the flag belongs only behind a proxy that adds authentication or in a container whose port is published on localhost.

  • Every request is bounded. A body over 128 KiB gets status 413. This call sent a corpus_search request whose query held 140,000 characters, in a body of 140,117 bytes:

    $ curl -s -w '\nHTTP %{http_code}\n' -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
    --data-binary @big.json http://127.0.0.1:8768/mcp
    Request body too large
    HTTP 413

    Each text, list and number argument has a limit too, and a value over it is an error. A query of 4,001 characters, one over the 4,000 allowed, is refused before any search runs, and the error names the limit:

    {"jsonrpc":"2.0","id":1,"result":{"content":[{"text":"Error executing tool corpus_search: 1 validation error for corpus_searchArguments\nquery\n String should have at most 4000 characters [type=string_too_long, input_value='aaaaaaaaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaaa', input_type=str]\n For further information visit https://errors.pydantic.dev/2.14/v/string_too_long","type":"text"}],"isError":true}}
    HTTP 200

    The Limits column of the tools reference lists every limit.

  • For any shared use, put a reverse proxy with authentication, and TLS, in front of a server that still listens on 127.0.0.1. “Behind a reverse proxy” shows how the server learns the proxy’s name.

A reverse proxy forwards each request to the server and puts the name your clients use in the Host header. The server answers that name only when you add it. Start the server with one --allowed-host for each name:

Terminal window
corpus serve --http --allowed-host mcp.example.org --allowed-host proxy.example:8443
  • A name alone, mcp.example.org, allows any port. A name with a port, proxy.example:8443, allows that port and no other.
  • A value is a DNS name, an IPv4 address or an [IPv6] address, as a client sends it in the Host header. A wildcard, a scheme or a path is a usage error.
  • The flag needs --http.
  • A page served from an allowed name passes the Origin check, over http or https. A page from any other name gets 403.

These runs started that command on port 8769 and sent each Host with curl, which sends the header it is told to, as a proxy does. The server’s own address stayed 127.0.0.1:

Host sent Origin sent Answer
mcp.example.org:8443 none 200
mcp.example.org none 200
proxy.example:8443 none 200
proxy.example:9000 none 421
proxy.example none 421
other.example none 421
127.0.0.1:8769 none 200
mcp.example.org https://mcp.example.org 200
mcp.example.org https://evil.example 403

A refusal says what the server got and which flag would let it in. The list of names grows with each --allowed-host:

$ curl -s -w '\nHTTP %{http_code}\n' -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-H 'Host: other.example' -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"corpus_status","arguments":{}}}' http://127.0.0.1:8769/mcp
Invalid Host header 'other.example': this server answers localhost, 127.0.0.1, [::1], mcp.example.org and proxy.example:8443 only. To allow this name, start it with `corpus serve --http --allowed-host other.example`.
HTTP 421

When a client behind your proxy gets 421, read the name in the message: it is what the proxy sent. Add that name with --allowed-host, or change what the proxy sends. A wrong use of the flag stops the command with status 2. The usage lines that precede the second message are left out here:

$ corpus serve --allowed-host mcp.example.org
corpus: --allowed-host applies to the HTTP server: add --http
$ corpus serve --http --allowed-host '*.example.org'
corpus serve: error: argument --allowed-host: not a host name or address: '*.example.org'; give it as a client sends it in the Host header, such as proxy.example or proxy.example:8443, with no scheme, path or wildcard

The proxy still has to add authentication. The server has none.

The same server answers ChatGPT’s two tools at /chatgpt/mcp: search and fetch. They run through corpus_search and corpus_read, so each result keeps its license verdict, the secret masking and the visible markers. Each result’s id and url are the hit’s pinned permalink. For a file that gives location only, fetch returns a note that tells you to open the url. The tools reference lists both tools.

A real listing of the endpoint, from an MCP client on 2026-11-11:

/chatgpt/mcp tools: ['search', 'fetch']

Not run: connecting ChatGPT. OpenAI’s MCP page (developers.openai.com/api/docs/mcp, read on 2026-11-11) describes remote servers as connecting models “over the Internet”, and a server on 127.0.0.1 can be reached only from your computer. Signing ChatGPT users in is part of the hosted service, which is not built yet. The page’s server example uses the SSE transport, and it does not say whether Streamable HTTP is accepted. Treat ChatGPT as unsupported until the hosted service says otherwise.

Not run. The Docker daemon is not running on the Mac that ran the other examples. These lines come from the Dockerfile and the release workflow, which say how the image is built, named and used. The workflow builds the image and runs demo in it before it pushes the image to GHCR.

Pull the image:

Terminal window
docker pull ghcr.io/ymcbzrgn/engineering-corpus

The release tags it with the version and latest. It is a linux/amd64 image, built from the Linux x86_64 wheel: Docker Desktop on an Intel Mac runs it as it is. Windows on Arm and Alpine Linux on arm64 have neither a wheel nor an arm64 image in v0.1.

Then run it one of three ways. Each mounts a volume named corpus at /data, the container’s data folder:

Terminal window
# The demo; its index goes to /data/demo on the volume
docker run -it --rm -v corpus:/data ghcr.io/ymcbzrgn/engineering-corpus demo --data-dir /data/demo
# MCP over stdio, the form a client starts for you; it serves /data, where your own index goes
docker run -i --rm -v corpus:/data ghcr.io/ymcbzrgn/engineering-corpus serve --data-dir /data
# Streamable HTTP at /mcp, on localhost only; it serves /data too
docker run --rm -p 127.0.0.1:8765:8765 -v corpus:/data ghcr.io/ymcbzrgn/engineering-corpus

The demo’s index is in /data/demo. After the demo alone, /data holds the model and the demo folder and no index of its own. To serve the demo’s index over stdio, change the stdio line’s --data-dir /data to --data-dir /data/demo, as the demo’s own last line does.

To index your own repos in the image, lend it your slice file and run index (Index your stars writes one):

Terminal window
docker run -it --rm -v corpus:/data -v "$PWD/stars.toml:/data/stars.toml:ro" ghcr.io/ymcbzrgn/engineering-corpus index stars.toml

The file is mounted read-only in the container’s working folder, /data, where index stars.toml finds it, and the index goes to the volume. This line has not been run: it is derived from the Dockerfile and waits for a run on the published image. After it, the stdio and HTTP lines serve your index, because both read /data.

To build the image yourself, for example to test a change, run the build from a folder that holds the Linux x86_64 wheel and tag it with the published name, so that the commands the engine prints inside the image name an image you have:

Terminal window
docker build -f Dockerfile -t ghcr.io/ymcbzrgn/engineering-corpus wheel/

What the image holds:

  • Python 3.13 on Debian, with git and Betterleaks 1.9.0, so corpus index scans for secrets inside the container too. The Dockerfile checks the Betterleaks download against its published SHA-256.
  • The engine from the wheel, installed with no build step.
  • A user without root rights (uid 10000) and a volume at /data. The embedding model downloads into the volume the first time it is needed.
  • ENGINEERING_CORPUS_DATA=/data, so every corpus command in the container uses the volume as its data folder.
  • ENGINEERING_CORPUS_IMAGE=ghcr.io/ymcbzrgn/engineering-corpus, which the demo and corpus search read to print docker run commands that name this image.
  • A default command that serves HTTP on 0.0.0.0:8765 inside the container, with --allow-remote-bind.

That default address is why the third line publishes the port as 127.0.0.1:8765:8765. Inside the container the server listens on every address, so the published port is what keeps the server on your computer. The image passes --allow-remote-bind because the server refuses a non-loopback address without it.

The Host and Origin checks stay on inside the container. A client on your computer reaches it as 127.0.0.1:8765, a name the server answers, so a container published as -p 127.0.0.1:8765:8765 needs nothing extra. A client that reaches it by another name or by a LAN address gets 421. Behind a reverse proxy, add --allowed-host for each name the proxy sends. Arguments after the image name replace the image’s default command, so write the whole command:

Terminal window
docker run --rm -p 127.0.0.1:8765:8765 -v corpus:/data ghcr.io/ymcbzrgn/engineering-corpus \
serve --http --host 0.0.0.0 --allow-remote-bind --port 8765 --data-dir /data --allowed-host mcp.example.org

Publish the port on localhost, or put a proxy with authentication in front.

To connect a client to the container over stdio, use the Docker line as the command:

Terminal window
claude mcp add engineering-corpus -- docker run -i --rm -v corpus:/data ghcr.io/ymcbzrgn/engineering-corpus serve --data-dir /data