@@ -37,6 +37,100 @@ Include your token in the Authorization header:
37
37
Authorization: token YOUR_ACCESS_TOKEN
38
38
```
39
39
40
+ ## Client Integration
41
+
42
+ The Sourcegraph MCP server can be integrated with various AI tools and IDEs that support the Model Context Protocol.
43
+
44
+ ### Amp
45
+
46
+ <Callout type = " info" >
47
+ To create an access token, visit [ Creating an access token] ( /cli/how-tos/creating_an_access_token ) .
48
+ </Callout >
49
+
50
+ You can add the Sourcegraph MCP server to [ Amp] ( https://ampcode.com ) in two ways:
51
+
52
+ #### Option 1: VSCode settings.json
53
+
54
+ 1 . Open VSCode's ` settings.json ` file.
55
+ 2 . Add the following configuration:
56
+
57
+ ``` json
58
+ {
59
+ "amp.mcpServers" : {
60
+ "sourcegraph" : {
61
+ "url" : " https://your-sourcegraph-instance.com/.api/mcp/v1" ,
62
+ "headers" : {
63
+ "Authorization" : " token YOUR_ACCESS_TOKEN"
64
+ }
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ <Callout type = " info" >
71
+ Replace ` your-sourcegraph-instance.com ` with your Sourcegraph instance URL and ` YOUR_ACCESS_TOKEN ` with your access token.
72
+ </Callout >
73
+
74
+ 3 . Save the configuration file.
75
+ 4 . Restart VS Code to apply the new configuration.
76
+
77
+ #### Option 2: Amp CLI
78
+
79
+ Run the following command in your terminal:
80
+
81
+ ``` bash
82
+ amp mcp add sourcegraph --header " Authorization=token $SRC_ACCESS_TOKEN " https://sourcegraph.sourcegraph.com/.api/mcp/v1
83
+ ```
84
+
85
+ <Callout type = " info" >
86
+ Replace ` sourcegraph.sourcegraph.com ` with your Sourcegraph instance URL and set ` $SRC_ACCESS_TOKEN ` environment variable to your access token.
87
+ </Callout >
88
+
89
+ ### Claude Code
90
+
91
+ You can add the Sourcegraph MCP server to [ Claude Code] ( https://claude.ai/code ) in two ways:
92
+
93
+ #### Option 1: Project-scoped server (via .mcp.json file)
94
+
95
+ 1 . Create a ` .mcp.json ` file in your project root if it doesn't exist.
96
+ 2 . Add the following configuration:
97
+
98
+ ``` json
99
+ {
100
+ "mcpServers" : {
101
+ "sourcegraph" : {
102
+ "url" : " https://your-sourcegraph-instance.com/.api/mcp/v1" ,
103
+ "headers" : {
104
+ "Authorization" : " token YOUR_ACCESS_TOKEN"
105
+ }
106
+ }
107
+ }
108
+ }
109
+ ```
110
+
111
+ <Callout type = " info" >
112
+ Replace ` your-sourcegraph-instance.com ` with your Sourcegraph instance URL and ` YOUR_ACCESS_TOKEN ` with your access token.
113
+ </Callout >
114
+
115
+ 3 . Save the configuration file.
116
+ 4 . Restart Claude Code to apply the new configuration.
117
+
118
+ #### Option 2: Locally-scoped server (via CLI command)
119
+
120
+ You can also add the Sourcegraph MCP server as a locally-scoped server, which is only available to you in the current project:
121
+
122
+ 1 . Run the following command in your terminal:
123
+
124
+ ``` bash
125
+ claude mcp add sourcegraph -s local --url https://your-sourcegraph-instance.com/.api/mcp/v1 --header " Authorization: token YOUR_ACCESS_TOKEN"
126
+ ```
127
+
128
+ <Callout type = " info" >
129
+ Replace ` your-sourcegraph-instance.com ` with your Sourcegraph instance URL and ` YOUR_ACCESS_TOKEN ` with your access token.
130
+ </Callout >
131
+
132
+ Locally-scoped servers take precedence over project-scoped servers with the same name and are stored in your project-specific user settings.
133
+
40
134
## Available Tools
41
135
42
136
The MCP server provides these tools for code exploration and analysis:
@@ -228,88 +322,6 @@ Find repositories where a contributor has made commits.
228
322
}
229
323
```
230
324
231
- ## Client Integration
232
-
233
- The Sourcegraph MCP server can be integrated with various AI tools and IDEs that support the Model Context Protocol.
234
-
235
- ### Amp
236
-
237
- You can add the Sourcegraph MCP server to [ Amp] ( https://ampcode.com ) in two ways:
238
-
239
- #### Option 1: VSCode settings.json
240
-
241
- 1 . Open VSCode's ` settings.json ` file.
242
- 2 . Add the following configuration:
243
-
244
- ``` json
245
- {
246
- "amp.mcpServers" : {
247
- "sourcegraph" : {
248
- "url" : " https://your-sourcegraph-instance.com/.api/mcp/v1" ,
249
- "headers" : {
250
- "Authorization" : " token YOUR_ACCESS_TOKEN"
251
- }
252
- }
253
- }
254
- }
255
- ```
256
-
257
- Replace ` your-sourcegraph-instance.com ` with your Sourcegraph instance URL and ` YOUR_ACCESS_TOKEN ` with your access token.
258
-
259
- 3 . Save the configuration file.
260
- 4 . Restart VS Code to apply the new configuration.
261
-
262
- #### Option 2: Amp CLI
263
-
264
- Run the following command in your terminal:
265
-
266
- ``` bash
267
- amp mcp add sourcegraph --header " Authorization=token $SRC_ACCESS_TOKEN " https://sourcegraph.sourcegraph.com/.api/mcp/v1
268
- ```
269
-
270
- Replace ` sourcegraph.sourcegraph.com ` with your Sourcegraph instance URL and set ` $SRC_ACCESS_TOKEN ` environment variable to your access token.
271
-
272
- ### Claude Code
273
-
274
- You can add the Sourcegraph MCP server to [ Claude Code] ( https://claude.ai/code ) in two ways:
275
-
276
- #### Option 1: Project-scoped server (via .mcp.json file)
277
-
278
- 1 . Create a ` .mcp.json ` file in your project root if it doesn't exist.
279
- 2 . Add the following configuration:
280
-
281
- ``` json
282
- {
283
- "mcpServers" : {
284
- "sourcegraph" : {
285
- "url" : " https://your-sourcegraph-instance.com/.api/mcp/v1" ,
286
- "headers" : {
287
- "Authorization" : " token YOUR_ACCESS_TOKEN"
288
- }
289
- }
290
- }
291
- }
292
- ```
293
-
294
- Replace ` your-sourcegraph-instance.com ` with your Sourcegraph instance URL and ` YOUR_ACCESS_TOKEN ` with your access token.
295
-
296
- 3 . Save the configuration file.
297
- 4 . Restart Claude Code to apply the new configuration.
298
-
299
- #### Option 2: Locally-scoped server (via CLI command)
300
-
301
- You can also add the Sourcegraph MCP server as a locally-scoped server, which is only available to you in the current project:
302
-
303
- 1 . Run the following command in your terminal:
304
-
305
- ``` bash
306
- claude mcp add sourcegraph -s local --url https://your-sourcegraph-instance.com/.api/mcp/v1 --header " Authorization: token YOUR_ACCESS_TOKEN"
307
- ```
308
-
309
- Replace ` your-sourcegraph-instance.com ` with your Sourcegraph instance URL and ` YOUR_ACCESS_TOKEN ` with your access token.
310
-
311
- Locally-scoped servers take precedence over project-scoped servers with the same name and are stored in your project-specific user settings.
312
-
313
325
## Best Practices
314
326
315
327
1 . ** Repository Scoping:** Use ` sg_list_repos ` first to find relevant repositories for better performance
0 commit comments