Skip to content

Commit 5cc60d6

Browse files
docs: add Amp and Claude Code integration examples for MCP server (#1369)
Amp-Thread-ID: https://ampcode.com/threads/T-87005ebc-368d-4ed3-8684-dbc4f758c3d6 <!-- Explain the changes introduced in your PR --> ## Pull Request approval You will need to get your PR approved by at least one member of the Sourcegraph team. For reviews of docs formatting, styles, and component usage, please tag the docs team via the #docs Slack channel. --------- Co-authored-by: Amp <[email protected]>
1 parent 2e6190b commit 5cc60d6

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

docs/api/mcp/index.mdx

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,100 @@ Include your token in the Authorization header:
3737
Authorization: token YOUR_ACCESS_TOKEN
3838
```
3939

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 YOUR_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 `YOUR_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+
40134
## Available Tools
41135

42136
The MCP server provides these tools for code exploration and analysis:

0 commit comments

Comments
 (0)