Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Connecting to a remote MCP server

An MCP server gives the agent extra tools. A remote one is reached over HTTPS with a URL and a token, and nothing is installed locally. Keys: config.md.

Before you start

  • The URL of the server’s MCP endpoint, such as https://api.githubcopilot.com/mcp/.
  • A fixed token the server accepts (a personal access token, an API key). OAuth isn’t supported.
  • Harness 0.15.0 or later.

Setup

1. Put the token in an environment variable, never in the config file. Type this, don’t paste it:

read -rs GITHUB_PAT; export GITHUB_PAT; echo "length: ${#GITHUB_PAT}"

Tokens shorter than 8 characters are refused.

2. Add the server to your own config.toml (default ~/.config/harness/config.toml; harness paths shows yours). A project’s config can’t add servers.

[mcp.servers.github]
url = "https://api.githubcopilot.com/mcp/"
token_env = "GITHUB_PAT"                  # the variable's name, not the token
tools = ["search_issues", "issue_read"]   # optional: offer only these
allow = ["search_issues"]                 # optional: run without asking
  • github is any name you choose.
  • The token is sent as Authorization: Bearer …; token_header = "X-API-Key" uses another header.
  • Without tools you get every tool, and each costs model context.

3. Run harness run in the same terminal and type /mcp. Expect a line like:

github  http · api.githubcopilot.com · 2026-07-28 · 2 of 46 tools · ≈N tokens

Using it

Ask in plain language; the agent picks the tool. Every call asks first unless the tool is in allow: y allows it, n denies it and stops the turn, 4 denies it with a message to the agent. A server’s read-only label is informational only.

  • --approve-all skips asking all session; use it only with servers you trust.
  • Plan mode offers no MCP tools.
  • /away refuses any call that would ask.

/mcp shows servers, tools, calls and failures.

What the harness does with your token

  • It goes only to that server’s address; redirects are never followed.
  • Calls are logged, the token never is; if the server echoes it, the log shows [redacted].
  • harness replay replays the session with no server and no token.

Good to know

  • Tools are fixed at session start; new ones appear next session.
  • Resuming reloads tools from the log and reconnects at the first call. If the server’s config changed, its calls are refused; start a new session.
  • Results are text only, up to 64 KiB; an image becomes a placeholder like [image: image/png, 1234 bytes].
  • The URL must be https://, or http:// for a loopback address such as 127.0.0.1.

If something goes wrong

You seeLikely cause
mcp: github failed to start: GITHUB_PAT is not setNot exported in this terminal. Do step 1 here, then start a new session.
failed to start: … 401 or 403Token wrong, expired or lacking access.
failed to start: timed out after 30 sServer unreachable or slow; if slow, set startup_timeout = 60.
/mcp lists no serversAnother config file was read; check harness paths.
A load error naming a keyA typo in [mcp.servers.…].