Adding a server
# local server over stdio (runs the command, talks over its stdin/stdout)
claude mcp add playwright -- npx @playwright/mcp@latest
# remote server over HTTP
claude mcp add --transport http github https://api.githubcopilot.com/mcp/
# with a header (API-key style auth)
claude mcp add --transport http posthog https://mcp.posthog.com/mcp \
--header "Authorization: Bearer $POSTHOG_API_KEY"
claude mcp list # what is configured
claude mcp remove playwright
Stdio servers are programs Claude Code starts for you — most community servers are npm or Python packages run this way. Remote servers are URLs; they authenticate with OAuth (run /mcp in a session and follow the browser flow) or with a header you pass at add time, as in the PostHog example. Check each vendor's docs for the current URL — remote endpoints move.
Scopes and .mcp.json
- local (default) — stored in your user settings, for this project only. Personal, private servers.
- project (
--scope project) — written to.mcp.jsonin the repo root and shared with everyone who clones it. Claude Code asks before trusting a project's servers the first time. - user (
--scope user) — available in every project on your machine.
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "${DATABASE_URL}"]
}
}
}
.mcp.json supports environment-variable expansion, so the repo can ship the server definition while each developer supplies their own credentials.
Using a server in a session
Once connected, the server's tools are simply available — ask for "the last 24 hours of errors from PostHog" and Claude Code calls the tool. Resources the server exposes can be referenced with @-mentions (@github:issue://123), which pulls them into context on demand. Prompts a server defines show up as slash commands under /mcp__<server>__<prompt>. /mcp shows connection status, lets you reconnect or authenticate, and lists every tool with its description.
Examples worth copying
- PostHog MCP — product analytics from inside the agent: "which feature flag is this code behind, and what is its rollout?" PostHog publishes a remote MCP server; add it with
--transport httpand your personal API key as a bearer header. - GitHub — issues and pull requests as context; pair it with the GitHub guide's Action for the review loop.
- Playwright — a real browser for end-to-end tests and for checking the UI you just changed; see the QA automation guide.
- Postgres / SQLite — schema-aware queries and migrations; give it a read-only user unless you mean it.
- Filesystem outside the repo —
--add-diris simpler for extra directories; MCP is for things that are not files.
Cost and context
Every tool result an MCP server returns lands in the conversation and is resent on each turn afterwards. A server that returns 5,000 rows is a context bomb. Prefer tools with limits, ask for summaries, and /compact after a heavy query. Servers run locally or against the vendor; they do not go through the model endpoint, so ANTHROPIC_BASE_URL=https://aiprimetech.io is unaffected — only the tokens the results consume are billed.
Frequently asked questions
How do I add an MCP server to Claude Code?
`claude mcp add <name> -- <command>` for a local server, or `claude mcp add --transport http <name> <url>` for a remote one; add `--scope project` to share it via .mcp.json.
How do I connect PostHog to Claude Code?
Add PostHog's remote MCP server with `claude mcp add --transport http posthog <url> --header "Authorization: Bearer <api key>"`, using the URL from PostHog's MCP docs, then ask about events, flags or errors in a session.
Does MCP work through a gateway?
Yes. MCP servers run locally or against the vendor and are independent of the model endpoint; only the tokens their results consume are billed through the gateway.
Run Claude Code on the gateway
Same models, two environment variables, credits at 7.69× face value — or a flat-rate unlimited plan.
Get an API key See unlimited plansAI Prime Tech is an independent API gateway and is not affiliated with, endorsed by, or sponsored by Anthropic. “Claude” and “Claude Code” are trademarks of Anthropic. Claude Code features described here follow Anthropic’s public documentation at the time of writing and change frequently; prices and model lists on this page are read from this gateway’s live settings.