Is the Sourcegraph MCP server safe? What it can reach
What the Sourcegraph MCP server can read, write and delete, how it signs in, and how to limit it in Claude Code and Codex.
Sourcegraph’s official MCP server is built into Enterprise instances at /.api/mcp and signs in with OAuth or an access token. Every documented tool reads or searches code, limited to repositories the user can already see. The control that matters most is the mcp scope plus the admin setting mcp.tools.disabled.
Who maintains it
| Implementation | Kind | Status |
|---|---|---|
| Sourcegraph MCP server (official, Enterprise) | Official | active |
It runs as a hosted remote server.
How it signs in
OAuth 2.0 through dynamic client registration or a pre-registered client, or a Sourcegraph access token sent as Authorization: token. The server acts with the signed-in user’s repository permissions.
| Scope or permission | Access |
|---|---|
mcp | read |
user:all | write |
What its tools can do
| Kind | Tools |
|---|---|
| Read | read_file, list_files, list_repos, list_refs, keyword_search, nls_search, evaluator, go_to_definition, find_references, commit_search, diff_search, compare_revisions, get_contributor_repos, code_finder, deepsearch, deepsearch_read |
| Write | none documented |
| Can’t be undone | none documented |
/.api/mcp serves a subset, /.api/mcp/all serves every tool, and /.api/mcp/deepsearch serves the two Deep Search tools. deepsearch starts new Deep Search conversations. code_finder and Deep Search use your instance’s metered entitlement.
Built-in limits
| Option | What it does |
|---|---|
mcp.tools.disabled | A site config array of tool names removed from every endpoint, such as ["code_finder", "deepsearch"]. Disabled tools are hidden and rejected. |
mcp.enabled | Turns MCP off for the whole instance. Defaults to true. |
MCP#ACCESS permission | Granted to the built-in User role by default. Admins can remove it from that role and grant it through a custom role. |
mcp scope | Limits an OAuth app or access token to the MCP endpoints. Request only this scope for MCP-only use. |
Endpoint choice | Use /.api/mcp for the core read tools or /.api/mcp/deepsearch for Deep Search only. |
auth.idpDynamicClientRegistrationEnabled | Controls whether OAuth clients can register themselves. |
The risks
- Anything in the repositories the user can read, including secrets committed to code, can be pulled into the agent’s context by an injected instruction.
- By default every signed-in user has MCP#ACCESS, so access is wide unless an admin changes the User role.
- deepsearch and code_finder spend your instance’s metered entitlement.
- An access token in client config carries the user’s repository access and must be stored like a password.
Limit it in Claude Code
Add it from the documented launch settings, at local or user scope so a token never lands in a shared .mcp.json:
claude mcp add --transport http sourcegraph https://sourcegraph.example.com/.api/mcpClaude Code names MCP tools mcp__sourcegraph__<tool>. Once you know the tool names, deny the ones you won’t use and set the rest to ask in .claude/settings.json.
Limit it in Codex
Codex reads MCP servers from ~/.codex/config.toml. disabled_tools removes tools, and enabled_tools keeps only the ones you list:
[mcp_servers.sourcegraph]
url = "https://sourcegraph.example.com/.api/mcp"Checklist
- Use OAuth, or an access token limited to the mcp scope.
- Ask your admin to disable tools you do not need.
- Use the /.api/mcp endpoint, not /all, unless you need Deep Search.
- Do not commit access tokens to config files.
Checked against the vendor documentation on November 25, 2026. Sourcegraph MCP server docs · Sourcegraph MCP authentication
What Excellent covers
Excellent doesn’t inspect MCP servers themselves. Its free scan reads supported logs on the Mac (Claude Code, Codex, Grok Build, GitHub Copilot CLI, Gemini CLI and Qwen Code) and reports findings for review, so you can see what an agent did after a session. Run the free scan · See a sample report · How to vet any MCP server
Excellent Pro adds checks before supported actions. Claude Code can display an ask prompt. With Codex, an Excellent “ask” refuses the action and tells the agent to ask you. Pro is US-only for now. Agent coverage · Pricing