You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Remove experimental callout - MCP is now generally available
- DCR is now enabled by default, update docs accordingly
- Add new 'mcp' scope documentation for OAuth and access tokens
- Add 'Disabling DCR' section for admins who need to turn it off
- Add upgrade notes for users migrating from 7.0
- Update mcp-remote example to use 'mcp' scope instead of 'user:all'
---------
Co-authored-by: Amp <amp@ampcode.com>
The Sourcegraph Model Context Protocol (MCP) Server provides AI agents and applications with programmatic access to your Sourcegraph instance's code search, navigation, and analysis capabilities through a standardized interface.
23
17
24
18
## Server Endpoints
@@ -36,44 +30,35 @@ Example URL:
36
30
https://your-sourcegraph-instance.com/.api/mcp
37
31
```
38
32
39
-
## Authentication
40
-
41
-
The Sourcegraph MCP server supports two authentication methods:
42
-
43
-
### OAuth 2.0 with Dynamic Client Registration
44
-
45
-
Sourcegraph supports MCP spec-compliant OAuth with Dynamic Client Registration ([RFC 7591](https://datatracker.ietf.org/doc/html/rfc7591)), allowing AI agents to authenticate without pre-configured client IDs.
46
-
47
-
#### Enabling Dynamic Client Registration
33
+
## Getting Started
48
34
49
-
Enable this feature by setting the following site configuration:
50
-
51
-
```json
52
-
{
53
-
"auth.idpDynamicClientRegistrationEnabled": true
54
-
}
55
-
```
56
-
57
-
Once enabled, MCP clients that support OAuth can authenticate automatically. For example, for [Amp](https://ampcode.com/), you can run:
35
+
MCP clients that support OAuth can connect directly—just point them at your Sourcegraph instance and authenticate through your browser:
claude mcp add --transport http sg https://sourcegraph.example.com/.api/mcp
67
45
```
68
46
47
+
This works similarly for other MCP-compatible agents. See [Client Integration](#client-integration) for detailed setup instructions for each client.
48
+
49
+
## Authentication
50
+
51
+
The MCP server supports OAuth 2.0 and access token authentication.
69
52
70
-
This works similarly for other MCP-compatible agents.
53
+
### OAuth 2.0
71
54
72
-
#### Manual OAuth Setup
55
+
Sourcegraph implements Dynamic Client Registration ([RFC 7591](https://datatracker.ietf.org/doc/html/rfc7591)), so compatible clients can authenticate automatically without pre-configured client IDs. DCR-registered applications are restricted to the `mcp` scope, which limits access to MCP endpoints only.
56
+
57
+
<Accordiontitle="Manual OAuth Setup">
73
58
74
59
If your agent doesn't support Dynamic Client Registration, you can manually create an OAuth application:
75
60
76
-
1. Create an OAuth application in your Sourcegraph instance following the instructions [here](/admin/oauth-apps#creating-an-oauth-app). (Note: you will need the `user:all`scope)
61
+
1. Create an OAuth application in your Sourcegraph instance following the instructions [here](/admin/oauth-apps#creating-an-oauth-app). (Note: you can use the `mcp` scope for MCP-only access, or `user:all`for full access)
77
62
2. Use `mcp-remote` as a fallback with the following configuration:
78
63
79
64
```json
@@ -88,7 +73,7 @@ If your agent doesn't support Dynamic Client Registration, you can manually crea
88
73
"--static-oauth-client-info",
89
74
"{\"client_id\":\"<your-client-id>\"}",
90
75
"--static-oauth-client-metadata",
91
-
"{\"scope\":\"user:all\"}"
76
+
"{\"scope\":\"mcp\"}"
92
77
]
93
78
}
94
79
}
@@ -101,14 +86,30 @@ If your agent doesn't support Dynamic Client Registration, you can manually crea
To disable DCR, set the following site configuration:
94
+
95
+
```json
96
+
{
97
+
"auth.idpDynamicClientRegistrationEnabled": false
98
+
}
99
+
```
100
+
101
+
</Accordion>
102
+
103
+
### Access Tokens
105
104
106
-
Include your token in the Authorization header:
105
+
Alternatively, include an access token in the Authorization header:
107
106
108
107
```
109
108
Authorization: token YOUR_ACCESS_TOKEN
110
109
```
111
110
111
+
Access tokens can use the `mcp` scope to restrict access to MCP endpoints only.
112
+
112
113
## Client Integration
113
114
114
115
The Sourcegraph MCP server can be integrated with various AI tools and IDEs that support the Model Context Protocol.
@@ -529,6 +530,10 @@ Find repositories where a contributor has made commits.
529
530
530
531
### Deep Search
531
532
533
+
<Callouttype="info">
534
+
Admins can disable the `deepsearch` tool on the default and v1 MCP endpoints by setting the environment variable `SRC_MCP_DISABLE_DEEPSEARCH_TOOL=true` on the Sourcegraph instance. This does not affect `deepsearch_read` or the dedicated `/deepsearch` endpoint. This is a temporary measure available in 7.0 and will be replaced by a proper tool allowlist in a future release.
535
+
</Callout>
536
+
532
537
### `deepsearch`
533
538
534
539
Create a new Deep Search conversation to answer complex questions about your codebase.
0 commit comments