---
title: How to share an MCP server without sharing the API key
description: Use OAuth so each person signs in as themselves, or commit a config that reads each person’s own token. Keep a single service key behind a gateway.
canonical: https://mcp1.com/blog/share-mcp-server-without-api-key
last-updated: 2026-11-12
---

# How to share an MCP server without sharing the API key

Use OAuth so each person signs in as themselves, or commit a config that reads each person’s own token. Keep a single service key behind a gateway.

![](https://avatars.githubusercontent.com/u/1297371?s=96&v=4)Eldad FuxFounder and CEO, Appwrite

- MatejOAuth
- HarshOAuth
- LauraOAuth

 GitHub token

••••••••••

 Held by the gateway

- MatejOAuth
- HarshOAuth
- LauraOAuth

 GitHub token

••••••••••

 Held by the gateway

To share an MCP server without sharing its API key, have each person sign in with their own account if the server supports OAuth, and otherwise commit a config that reads each person’s own token from their environment. When the service only issues one key for everyone, put it behind a proxy or gateway that people sign in to as themselves, so the key stays in one place.

## Why is a shared MCP API key a problem?

A key pasted into a team channel works on day one. The problems show up later:

- Everyone acts as the key’s owner. The service’s logs show one identity, so you can’t tell who closed the ticket or ran the query.
- Everyone gets the same access. You can’t give the support team read-only and the platform team write access with one token.
- Removing one person means rotating the key and handing the new one to everyone else, so in practice nobody rotates it.
- Copies spread. The key ends up in chat history, .env files, dotfile repos and screenshots, and you can’t find them all.

## Does the server support OAuth?

Check this first, because if it does there’s no key to share. Remote servers that implement MCP authorization, like [Linear](https://mcp1.com/servers/linear), [Notion](https://mcp1.com/servers/notion) and [Sentry](https://mcp1.com/servers/sentry), sign each person in through the browser with their own account. Share the server entry, and each teammate authenticates once. In Claude Code, `--scope project` writes the entry to the repository’s `.mcp.json`:

Terminal

```
claude mcp add --transport http --scope project linear https://mcp.linear.app/mcp
```

Commit `.mcp.json`. Teammates approve the server when Claude Code first loads it, then run `/mcp` and choose Authenticate. The file holds a URL and nothing secret, and each person’s calls carry their own permissions in Linear.

## How do I keep the token out of a shared mcp.json?

Put a placeholder in the file and let each client fill it in from the person’s environment or a prompt. Every major client can do this, with its own syntax:

ClientHow the token gets in

Claude Code

`${GITHUB_TOKEN}` in .mcp.json, read from the environment. `${VAR:-default}` sets a fallback.

Cursor

`${env:GITHUB_TOKEN}` in mcp.json.

VS Code

An `inputs` entry with `"password": true`, referenced as `${input:github-token}`. VS Code asks once and stores it.

Codex

`bearer_token_env_var` in config.toml names the variable that holds the token.

For Claude Code, the committed file looks like this, and each person exports their own `GITHUB_TOKEN`:

.mcp.json

```
{
  "mcpServers": {
    "github": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": { "Authorization": "Bearer ${GITHUB_TOKEN}" }
    }
  }
}
```

VS Code keeps the prompt definition in the same file, so nobody needs to set a variable:

.vscode/mcp.json

```
{
  "inputs": [
    { "type": "promptString", "id": "github-token", "description": "GitHub fine-grained token", "password": true }
  ],
  "servers": {
    "github": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": { "Authorization": "Bearer ${input:github-token}" }
    }
  }
}
```

A placeholder isn’t a policy

Variables keep the token out of git, not out of people’s hands. The real fix is that each person creates their own token, like a fine-grained GitHub token with only the scopes they need, so the service can tell people apart and you can revoke one without touching the rest.

## What if the service only gives you one key?

Some services issue keys per organization or project, not per person. Then the key has to live somewhere people can’t read it, with something in front that knows who is calling. That can be a small proxy you run or an MCP gateway. Whichever you pick, it needs to:

- Sign people in with their own identity, ideally through your existing SSO, and support MCP OAuth so clients connect without a pasted secret.
- Store the service key encrypted, and add it to calls on the way out. Nobody should be able to read it back.
- Record each call with the person who made it, since the service’s own logs will only show the key.
- Let you remove one person, or limit them to some tools, without rotating the key.

That’s an authorization server, a secret store and an audit log to run and keep patched. It’s worth building only if you need it to sit inside your own network.

## How do I remove someone’s access?

It depends on how you shared the server:

SetupWhen someone leaves

OAuth, per person

Remove them from the service, or revoke the MCP client’s grant in its settings.

Personal tokens

Revoke their tokens. Nobody else is affected.

One shared key

Rotate the key and give the new one to everyone who still needs it.

Proxy or gateway

Remove them there. The key stays the same.

## Sharing servers through MCP1

MCP1 is the gateway option, hosted. An admin installs a server once for the workspace, with a token or a one-click OAuth connection, and people reach it through a gateway URL:

- Server tokens are encrypted with AES-256-GCM. Nobody sees a workspace server’s token, and nobody else can use a personal server’s.
- People connect their client to the gateway with OAuth 2.1 as themselves, for example `claude mcp add --transport http mcp1 https://mcp1.com/mcp/<workspace>/<gateway>`.
- Gateways are granted to groups with full or read-only access, and a server can hold a second, read-only token for people on read-only access.
- The audit log records every call with the person, client, gateway and tool, so the service’s single identity stops being a blind spot.
- Removing someone from the workspace stops every client they approved. CI gets API keys scoped to one gateway, stored as a hash and revocable on their own.

For CI specifically, see [how to use MCP servers in CI and headless agents](https://mcp1.com/blog/mcp-in-ci-and-headless-agents). The [docs](https://mcp1.com/docs) cover servers, gateways and groups, and the Individual plan is free to [start with](https://mcp1.com/signup).

## Common questions

### Can I commit .mcp.json to git?

Yes, as long as it holds no secrets. Use OAuth servers or placeholders like ${GITHUB\_TOKEN}, which Claude Code fills in from each person’s environment.

### Should my team share one GitHub token for the MCP server?

No. Each person should create their own fine-grained token, so GitHub can tell people apart and you can revoke one token without breaking everyone else.

### Does every MCP server support OAuth?

No. Only remote servers that implement MCP authorization sign people in through the browser. Others take a token or API key in a header or an environment variable.

### How do I rotate an MCP API key the team uses?

Create the new key, update it wherever it’s stored, check that calls work, then revoke the old one. Behind a gateway that’s one place to change instead of every laptop.

Give your team one URL

Create a workspace, install your servers and share a gateway with a group. Free for individuals.

[Start with MCP1](https://mcp1.com/signup)[Read the docs](https://mcp1.com/docs)

## More from the blog

[What is an MCP gateway?An MCP gateway is one endpoint between MCP clients and many MCP servers. It signs people in, filters their tools, holds server credentials and logs every call.![](https://avatars.githubusercontent.com/u/1297371?s=96&v=4)Eldad FuxFounder and CEO, Appwrite](https://mcp1.com/blog/what-is-an-mcp-gateway)[ Terminal$ claude mcp add --transport http linear mcp.linear.app/mcplinearConnectedHow to connect Linear MCP to Claude CodeRun claude mcp add with Linear’s hosted URL and authenticate with /mcp. How to share it with a team, make it read-only, use an API key and fix errors.![](https://avatars.githubusercontent.com/u/1297371?s=96&v=4)Eldad FuxFounder and CEO, Appwrite](https://mcp1.com/blog/linear-mcp-claude-code)

---

This is the markdown copy of https://mcp1.com/blog/share-mcp-server-without-api-key. Site index for agents: https://mcp1.com/llms.txt
