Org-Wide Claude Code: Managed Settings With the Locks On, an MCP Allowlist by Address, and One Pinned LLM Gateway
SupportDesk's platform team puts one policy above every developer: managed settings win over a user's base URL and a project's telemetry endpoint, a URL allowlist blocks a second server that is also named github, and allowedProviders pins traffic to one gateway that logs ana and ben and returns 401 to someone who left.
What you will learn
- Use managed settings to set keys no user or project file can override, and lock the permission rules
- Keep a cloned repository from redirecting telemetry
- Decide which MCP servers load: denylist first, then a URL allowlist with the managed-only lock
- Pin all model traffic to one LLM gateway with a credential per developer, an audit line per call and revocation
Before you start
- Claude Code settings layers
- Configuring MCP servers in Claude Code
- Basic JSON and Python
Picture the platform team at SupportDesk. A whole team of developers is about to start using Claude Code. Each one has a laptop, a settings file and their own ideas: their own servers, their own keys, their own endpoint. Nobody can say what is running.
The team wants one policy above all of them, answering three questions. What may Claude Code do? Which tool servers may connect? Where does the traffic go once a request leaves the laptop? Each question has a control.
An office with house rules
- The rulebook. The company prints it and puts it on every desk. A sticky note on one desk can't overrule it. That is managed settings.
- The approved vendor list. A vendor can wear any name tag, so you check the address, not the badge. That is the MCP allowlist.
- The mail room. One door, and every letter leaves stamped with the sender. That is the LLM gateway.
The project models a few of the documented rules in plain Python: three of the settings layers, the env merge, the permission lock, the MCP check order and the pinned endpoint. The gateway is a stand-in (the Anthropic SDK on an httpx mock transport), so no API key is needed and the replies are test replies. Hostnames end in .test, and the credentials are made-up test values.
Managed settings sit on top
Claude Code reads settings from several places: the organization's managed settings at the top, then the command line, then the project files, then the user's own file. A single key from a higher layer wins. Lists, like permission rules, merge across files. The rolling out Claude Code article walks through that stack. Here we add the org's locks. This is the managed file:
{
"allowManagedPermissionRulesOnly": true,
"permissions": {
"deny": ["Read(./.env)"]
},
"allowManagedMcpServersOnly": true,
"allowedMcpServers": [
{ "serverUrl": "https://mcp.supportdesk.test/*" },
{ "serverUrl": "https://api.githubcopilot.com/*" }
],
"deniedMcpServers": [
{ "serverUrl": "https://*.untrusted.example.com/*" }
],
"allowedProviders": ["customEndpoint"],
"env": {
"ANTHROPIC_BASE_URL": "https://llm-gateway.supportdesk.test",
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://otel.supportdesk.test:4317"
}
}
Against it, the project file tries to send telemetry to collector.evil.example and allows Bash(npm run lint), and the user file points ANTHROPIC_BASE_URL at the public API, allows Bash(npm run test *) and adds its own MCP allowlist entry for mcp.evil.example.
settings_layers.py: the resolver
ORDER = ["managed", "shared project", "user"]
REPO_LAYERS = ("shared project", "project local")
def resolve_env(layers):
"""a higher layer wins; a repository file cannot set OTEL_ variables"""
env, source = {}, {}
for layer in reversed(ORDER):
for key, value in layers[layer].get("env", {}).items():
if layer in REPO_LAYERS and key.startswith("OTEL_"):
continue
env[key], source[key] = value, layer
return env, source
def resolve_permissions(layers):
"""lists merge across layers, unless the managed file locks them"""
managed = layers["managed"]
locked = managed.get("allowManagedPermissionRulesOnly", False)
rules = {"allow": [], "deny": []}
for layer in ORDER:
if locked and layer != "managed":
continue
perms = layers[layer].get("permissions", {})
for kind in rules:
for rule in perms.get(kind, []):
if rule not in rules[kind]:
rules[kind].append(rule)
return rules
(Excerpt.)
- The layers are listed highest first. Walking them lowest first means a higher layer overwrites a lower one, key by key.
- One exception: a repository file can't set the telemetry export variables, so a cloned project can't redirect your metrics.
allowManagedPermissionRulesOnlylocks the permission rules, and then only the managed rules count at all.
settings: three layers, one winner
ANTHROPIC_BASE_URL -> https://llm-gateway.supportdesk.test (managed, user said https://api.anthropic.com)
OTEL endpoint -> https://otel.supportdesk.test:4317 (managed, project value ignored)
permission rules -> lock off: 2 allow rules merged | lock on: 0 allow, deny Read(./.env)
The MCP allowlist checks addresses
mcp_policy.py: denylist first, then the allowlist
def merged_lists(layers, locked):
allowed, denied = [], []
for layer in ORDER:
cfg = layers[layer]
if not (locked and layer != "managed"):
allowed += cfg.get("allowedMcpServers", [])
denied += cfg.get("deniedMcpServers", [])
return allowed, denied
def evaluate(server, layers, locked):
allowed, denied = merged_lists(layers, locked)
if any(entry_matches(e, server) for e in denied):
return False, "blocked: denylist"
if not allowed:
return True, "allowed: no allowlist"
http = server["type"] == "http"
key = "serverUrl" if http else "serverCommand"
values = [e[key] for e in allowed if key in e]
if values: # a name is only a label
if http:
ok = any(url_matches(v, server["url"]) for v in values)
else:
ok = server["command"] in values
return verdict(ok, key)
names = [e["serverName"] for e in allowed if "serverName" in e]
return verdict(server["name"] in names, "serverName")
(Excerpt; url_matches turns * into a wildcard, and verdict builds the message.)
- The lists merge first. With
allowManagedMcpServersOnlyon, only the managed allowlist is kept. - The denylist merges from every layer, so a user can always block a server for themselves.
- The denylist is checked first. A match always blocks, and nothing overrides it.
- Then the allowlist. If no allowlist is set anywhere, everything else loads. But once a URL entry exists, a remote server has to match one. A name is only a label.
MCP servers against the allowlist
crm https://mcp.supportdesk.test/crm -> allowed: matches a serverUrl entry
github https://api.githubcopilot.com/mcp/ -> allowed: matches a serverUrl entry
github https://mcp.evil.example/mcp -> blocked: not on the allowlist
build https://ci.untrusted.example.com/mcp -> blocked: denylist
tools npx -y unapproved-package -> blocked: not on the allowlist
user adds an allowlist entry, lock on -> blocked: not on the allowlist
user adds an allowlist entry, lock off -> allowed: matches a serverUrl entry
Look at the last two lines of the run. The user's own allowlist entry for mcp.evil.example does nothing while the lock is on. With the lock off, it would let the server in. That is why the lock matters.
The gateway is the one door
llm_gateway.py: credential in, who logged
CREDENTIALS = {
"gw-ana": {"developer": "ana", "team": "support"},
"gw-ben": {"developer": "ben", "team": "platform"},
}
AUDIT = []
def handler(request):
header = request.headers.get("authorization", "")
who = CREDENTIALS.get(header.removeprefix("Bearer "))
if who is None:
err = {"type": "authentication_error", "message": "unknown credential"}
return httpx.Response(401, json={"type": "error", "error": err})
model = json.loads(request.content)["model"]
AUDIT.append({**who, "path": request.url.path, "model": model})
return httpx.Response(200, json=reply(model))
def make_client(base_url, credential):
"""ANTHROPIC_AUTH_TOKEN goes out as an Authorization: Bearer header."""
transport = httpx.MockTransport(handler)
return Anthropic(base_url=base_url, auth_token=credential,
api_key=None, max_retries=0,
http_client=httpx.Client(transport=transport))
(Excerpt.) The gateway reads the credential from the Authorization header. An unknown credential gets a 401. A known one is logged with the developer and the team. On the client side, the auth token setting goes out as a bearer header, which is what the gateway reads.
And on the laptop, allowedProviders: ["customEndpoint"] in the managed file pins the endpoint: the managed ANTHROPIC_BASE_URL is the only address accepted.
the gateway
developer exports api.anthropic.com -> refused: allowedProviders pins customEndpoint
managed address -> ok: the managed gateway address
ana's credential -> 200 test model reply
credential of someone who left -> 401 authentication_error
audit: ana support /v1/messages | ben platform /v1/messages
A developer who points Claude Code straight at the public address is refused. Through the gateway, Ana's call goes through and lands in the audit as ana, support. When someone leaves, you revoke one credential, and their next call gets a 401. The telemetry settings travel in the same managed file. (For a gateway that also routes one model alias across platforms, see gateway routing and platform parity.)
Common mistakes
- Asking each team to add the allowlist to its own file. A developer can edit it. Put it in managed settings with the lock on.
- Blocking or allowing servers by name. A name is only a label. The second
githubproved it. Match by URL or command. - Telling developers to export the gateway address. Nothing enforces that. Pin it with
allowedProvidersand the managedANTHROPIC_BASE_URL. - Leaving the permission lists unlocked. Without
allowManagedPermissionRulesOnly, project and user allow rules merge in (here, two of them). - One shared gateway credential. Then the audit can't say who called, and you can't revoke one person.
To lock which plugins can be installed as well, see plugins and marketplaces.
Quick recap
| Question | Control | In this run |
|---|---|---|
| What may Claude Code do? | Managed settings + allowManagedPermissionRulesOnly | 0 allow rules, deny Read(./.env) |
| Can a repo redirect telemetry? | OTEL vars ignored in repo files | managed collector wins |
| Which servers may connect? | Denylist, then URL allowlist, allowManagedMcpServersOnly | 2 allowed, 3 blocked |
| Where does traffic go? | allowedProviders + managed ANTHROPIC_BASE_URL | public address refused |
| Who called? | One gateway credential per developer | ana, ben logged; leaver 401 |
Try it yourself
Add a deniedMcpServers entry to the user file for https://api.githubcopilot.com/*. Predict whether the allowed github server still loads with the lock on, then check against the code: which list does the lock leave alone?
Related course on Udemy
Claude Certified Developer - Professional (CCDV-P) Exam Prep
Claude agents in production: reliability, observability, evals, cost, guardrails and fleets.View on Udemy ↗: Claude Certified Developer - Professional (CCDV-P) Exam Prep (paid course, opens in a new tab)Related posts
CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages
Three needs in one repo: a test command, a rule that Claude must never read .env, and a shared deploy skill. See which file each belongs in, how the settings layers merge, and what a plugin manifest carries.
Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It
Pack a support team's ticket-triage routine into one skill folder, then watch three requests load one, two or all three levels: the catalog, the SKILL.md body, and a script whose code never enters the context.
One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI
Change one line in a repo and ask where it lands. A small resolver for bookshop-bot shows that a new model id in settings.json reaches only CI, a prompt bump reaches dev and CI, and a prod block edit reaches only prod.
Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges
Follow one prompt edit from a branch to a merge: version prompts and the model pin like code, keep the API key in GitHub Secrets, gate changes by path, let Claude review the diff, and leave the merge to a person.
