Skip to main content
Moxie Docs
All guides

MCP how-to

How to connect Claude Code to an MCP server for a private codebase

The command

claude mcp add --transport http <name> <url> adds a remote server. Add --scope user to use it in every project, or --scope project to write it to a shared .mcp.json. If the server uses OAuth, run /mcp in Claude Code to sign in; for a token, add --header "Authorization: Bearer <token>". Check it with claude mcp list.

Claude Code connects to remote MCP servers with one command. The decisions that matter are which scope to install it in, how it authenticates, and whether your team shares the config. This guide covers each, with the syntax from Claude Code's MCP docs.

Last reviewed: December 2026

Need living codebase context for Claude Code or Cursor?

Moxie Docs indexes your codebase and serves verified conventions and docs over MCP. Free on 1 repo.

Connect 1 repo free

1. Add the server

Remote servers use the HTTP transport, which Claude Code's docs recommend for remote MCP servers (SSE is deprecated):

Shell
claude mcp add --transport http <name> <url>

For example, Moxie Docs' hosted server, installed for all your projects:

Shell
claude mcp add --scope user --transport http moxie-docs https://moxiedocs.com/api/mcp

2. Pick a scope

Claude Code has three scopes:

  • local (default): Only you, only this project. Stored in ~/.claude.json under the project's path.
  • project: Written to .mcp.json in the repo root, so everyone who clones the repo gets it. Claude Code asks each person to approve project servers before first use.
  • user: Only you, in every project. Stored in ~/.claude.json.

3. Authenticate

OAuth. Many hosted servers support it. After adding the server, run /mcp inside Claude Code and finish sign-in in the browser, or run claude mcp login <name> from the shell. Tokens are stored and refreshed for you, and nothing secret lands in a config file.

Bearer token. For servers that use API keys, pass a header. Keep the token in an environment variable rather than the command history:

Shell
claude mcp add --transport http moxie-docs https://moxiedocs.com/api/mcp \
  --header "Authorization: Bearer $MOXIE_DOCS_TOKEN"

If you set an Authorization header and the server rejects it, Claude Code reports the connection as failed rather than falling back to OAuth, so remove the header if you want OAuth.

4. Share it with your team (.mcp.json)

A project-scoped server lives in .mcp.json. Use environment variable expansion so tokens stay out of git:

JSON
{
  "mcpServers": {
    "moxie-docs": {
      "type": "http",
      "url": "https://moxiedocs.com/api/mcp",
      "headers": { "Authorization": "Bearer ${MOXIE_DOCS_TOKEN}" }
    }
  }
}

Include "type": "http": an entry with a url and no type is read as a stdio server and fails. Claude Code's docs also note that some credential variable names (for example ANTHROPIC_API_KEY) always read as empty inside a remote server's url or headers, so use a name of your own. For OAuth servers, leave headers out and each person signs in with /mcp.

5. Verify

Shell
claude mcp list        # shows ✔ Connected, ! Needs authentication, or ✘ Failed to connect
claude mcp get moxie-docs

Inside a session, /mcp shows each server's status and tools. Then ask a question only the server can answer, such as 'What are this repo's conventions for API routes?', and check that Claude calls the server's tools.

Which servers serve a private codebase's docs and conventions?

You need a server that has indexed your private code. Options as of December 2026, each with its own pricing:

  • Moxie Docs: Hosted, https://moxiedocs.com/api/mcp, OAuth or bearer token. Serves conventions, generated docs, doc gaps and verified commands for GitHub repos. Free for one repository. Setup: npx moxie-docs setup or moxiedocs.com/setup.
  • Devin MCP: Hosted, https://mcp.devin.ai/mcp with a Devin API key. Serves DeepWiki content for private repos connected to Devin. The free DeepWiki MCP server covers public repos only.
  • Unblocked: Hosted MCP that answers from code plus Slack, Jira, Confluence and other sources. Per-user pricing.
  • Dosu: Hosted MCP endpoint per deployment, OAuth or API key. Private repos need Pro.
  • Self-hosted: OpenDeepWiki exposes MCP endpoints per repository, and Repowise's open-source core runs an MCP server against a local checkout.

How-to

Connect Claude Code to a remote MCP server

  1. 1

    Add the server

    Run claude mcp add --transport http , adding --scope user for every project or --scope project to share it through .mcp.json.

  2. 2

    Authenticate

    For OAuth servers, run /mcp inside Claude Code (or claude mcp login ) and approve in the browser. For token servers, add --header "Authorization: Bearer ".

  3. 3

    Verify

    Run claude mcp list and confirm the server shows as connected, then ask Claude a question only the server can answer.

The short version

claude mcp add --transport http, a scope that matches who should get it, OAuth where the server supports it, and claude mcp list to confirm. The harder choice is the server: it has to have indexed your private code and keep up as the code changes.

FAQ

Frequently asked questions

Quick answers to the questions developers ask about Connect Claude Code to an MCP server for a private codebase.

Get started

Give your agents real codebase context.

Connect a repository and Moxie Docs generates living documentation and serves it to your agents over MCP. Free on 1 repository, no card required.