Skip to content

Commit 1fcd5e9

Browse files
docs: add Amp and Claude Code integration examples for MCP server
Amp-Thread-ID: https://ampcode.com/threads/T-87005ebc-368d-4ed3-8684-dbc4f758c3d6 Co-authored-by: Amp <[email protected]>
1 parent 2e6190b commit 1fcd5e9

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

docs/api/mcp/index.mdx

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,88 @@ Find repositories where a contributor has made commits.
228228
}
229229
```
230230

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+
231313
## Best Practices
232314

233315
1. **Repository Scoping:** Use `sg_list_repos` first to find relevant repositories for better performance

0 commit comments

Comments
 (0)