diff --git a/docs/api/mcp/index.mdx b/docs/api/mcp/index.mdx index f95d29977..40af11fe0 100644 --- a/docs/api/mcp/index.mdx +++ b/docs/api/mcp/index.mdx @@ -84,6 +84,16 @@ Authorization: token YOUR_ACCESS_TOKEN The Sourcegraph MCP server can be integrated with various AI tools and IDEs that support the Model Context Protocol. +### Supported Clients + +- [Amp](#amp) +- [Claude Code](#claude-code) +- [Google Gemini Code Assist](#google-gemini-code-assist) +- [VS Code](#vs-code) + - [Cursor](#cursor) + - [Antigravity](#antigravity) +- [OpenCode](#opencode) + ### Amp @@ -209,24 +219,25 @@ You can add the Sourcegraph MCP server to Google Gemini Code Assist by configuri 3. Save the configuration file. 4. Restart Gemini Code Assist to apply the new configuration. -### Cursor +### VS Code -You can add the Sourcegraph MCP server to Cursor by configuring it in your MCP settings file: +You can add the Sourcegraph MCP server to VS Code by configuring it in your MCP settings file: -1. Open or create the MCP configuration file at `~/.cursor/mcp.json` (or the equivalent path on your system). +1. Create `.vscode/mcp.json` in your project. 2. Add the following configuration: ```json { - "mcpServers": { + "servers": { "sourcegraph": { - "type": "http", "url": "https://your-sourcegraph-instance.com/.api/mcp/v1", + "type": "http", "headers": { "Authorization": "token YOUR_ACCESS_TOKEN" } } - } + }, + "inputs": [] } ``` @@ -236,25 +247,24 @@ You can add the Sourcegraph MCP server to Cursor by configuring it in your MCP s 3. Save the configuration file. -4. Restart Cursor to apply the new configuration. +4. Restart VS Code to apply the new configuration. -#### VS Code +#### Cursor -1. Create ⁠`.vscode/mcp.json` in your project. +1. Open or create the MCP configuration file at `~/.cursor/mcp.json` (or the equivalent path on your system). 2. Add the following: ```json { - "servers": { + "mcpServers": { "sourcegraph": { - "url": "https://your-sourcegraph-instance.com/.api/mcp/v1", "type": "http", + "url": "https://your-sourcegraph-instance.com/.api/mcp/v1", "headers": { "Authorization": "token YOUR_ACCESS_TOKEN" } } - }, - "inputs": [] + } } ``` @@ -263,6 +273,9 @@ You can add the Sourcegraph MCP server to Cursor by configuring it in your MCP s URL and `YOUR_ACCESS_TOKEN` with your access token. +3. Save the configuration file. +4. Restart Cursor to apply the new configuration. + #### Antigravity 1. Create ⁠`.vscode/mcp.json` (Antigravity uses `.vscode` for configs) in your project. @@ -288,7 +301,7 @@ You can add the Sourcegraph MCP server to Cursor by configuring it in your MCP s URL and `YOUR_ACCESS_TOKEN` with your access token. -#### OpenCode +### OpenCode You can add the Sourcegraph MCP server to OpenCode by configuring it in your MCP settings file: @@ -296,19 +309,19 @@ You can add the Sourcegraph MCP server to OpenCode by configuring it in your MCP 2. Add the following configuration: ```json - { - "mcp": { - "sourcegraph": { - "type": "remote", - "url": "https://your-sourcegraph-instance.com/.api/mcp/v1", - "oauth": false, - "headers": { - "Authorization": "token {env:YOUR_ACCESS_TOKEN}" - } - } - }, - "$schema": "https://opencode.ai/config.json" - } + { + "mcp": { + "sourcegraph": { + "type": "remote", + "url": "https://your-sourcegraph-instance.com/.api/mcp/v1", + "oauth": false, + "headers": { + "Authorization": "token {env:YOUR_ACCESS_TOKEN}" + } + } + }, + "$schema": "https://opencode.ai/config.json" + } ``` @@ -318,6 +331,7 @@ You can add the Sourcegraph MCP server to OpenCode by configuring it in your MCP 3. Save the configuration file. 4. Restart OpenCode to apply the changes. + ## Available Tools @@ -338,11 +352,11 @@ Read file contents with line numbers and support for specific ranges and revisio **Parameters:** -- `repo` - Repository name (required) -- `path` - File path within repository (required) -- `startLine` - Starting line number (optional) -- `endLine` - Ending line number (optional) -- `revision` - Branch, tag, or commit hash (optional) +- `repo` - Repository name (required) +- `path` - File path within repository (required) +- `startLine` - Starting line number (optional) +- `endLine` - Ending line number (optional) +- `revision` - Branch, tag, or commit hash (optional) **Use cases:** Reading specific files, examining code sections, reviewing different versions @@ -356,9 +370,9 @@ List files and directories in a repository path. **Parameters:** -- `repo` - Repository name (required) -- `path` - Directory path (optional, defaults to root) -- `revision` - Branch, tag, or commit hash (optional) +- `repo` - Repository name (required) +- `path` - Directory path (optional, defaults to root) +- `revision` - Branch, tag, or commit hash (optional) #### `sg_list_repos` @@ -366,9 +380,9 @@ Search and list repositories by name patterns with pagination support. **Parameters:** -- `query` - Search pattern for repository names (required) -- `limit` - Maximum results per page (optional, default 50) -- `after`/`before` - Pagination cursors (optional) +- `query` - Search pattern for repository names (required) +- `limit` - Maximum results per page (optional, default 50) +- `after`/`before` - Pagination cursors (optional) ### Code Search @@ -378,13 +392,13 @@ Perform exact keyword searches with boolean operators and filters. **Parameters:** -- `query` - Search query with optional filters (required) +- `query` - Search query with optional filters (required) **Supported filters:** -- `repo:` - limit to specific repositories -- `file:` - search specific file patterns -- `rev:` - search specific revisions +- `repo:` - limit to specific repositories +- `file:` - search specific file patterns +- `rev:` - search specific revisions **Features:** Boolean AND/OR operators, regex patterns @@ -394,13 +408,13 @@ Semantic search with flexible linguistic matching. **Parameters:** -- `query` - Natural language search query (required) +- `query` - Natural language search query (required) **Supported filters:** -- `repo:` - limit to specific repositories -- `file:` - search specific file patterns -- `rev:` - search specific revisions +- `repo:` - limit to specific repositories +- `file:` - search specific file patterns +- `rev:` - search specific revisions **Features:** Flexible linguistic matching, stemming, broader results than keyword search @@ -412,10 +426,10 @@ Find the definition of a symbol from a usage location. **Parameters:** -- `repo` - Repository name (required) -- `path` - File path containing symbol usage (required) -- `symbol` - Symbol name to find definition for (required) -- `revision` - Branch, tag, or commit hash (optional) +- `repo` - Repository name (required) +- `path` - File path containing symbol usage (required) +- `symbol` - Symbol name to find definition for (required) +- `revision` - Branch, tag, or commit hash (optional) **Features:** Cross-repository support, compiler-level accuracy @@ -425,10 +439,10 @@ Find all references to a symbol from its definition location. **Parameters:** -- `repo` - Repository name (required) -- `path` - File path containing symbol definition (required) -- `symbol` - Symbol name to find references for (required) -- `revision` - Branch, tag, or commit hash (optional) +- `repo` - Repository name (required) +- `path` - File path containing symbol definition (required) +- `symbol` - Symbol name to find references for (required) +- `revision` - Branch, tag, or commit hash (optional) ### Version Control & History @@ -438,12 +452,12 @@ Search commits by message, author, content, files, and date ranges. **Parameters:** -- `repos` - Array of repository names (required) -- `messageTerms` - Terms to search in commit messages (optional) -- `authors` - Filter by commit authors (optional) -- `contentTerms` - Search in actual code changes (optional) -- `files` - Filter by file paths (optional) -- `after`/`before` - Date range filters (optional) +- `repos` - Array of repository names (required) +- `messageTerms` - Terms to search in commit messages (optional) +- `authors` - Filter by commit authors (optional) +- `contentTerms` - Search in actual code changes (optional) +- `files` - Filter by file paths (optional) +- `after`/`before` - Date range filters (optional) #### `sg_diff_search` @@ -451,12 +465,12 @@ Search actual code changes for specific patterns across repositories. **Parameters:** -- `pattern` - Search pattern for code changes (required) -- `repos` - Array of repository names (required) -- `added` - Search only added code (optional) -- `removed` - Search only removed code (optional) -- `author` - Filter by author (optional) -- `after`/`before` - Date range filters (optional) +- `pattern` - Search pattern for code changes (required) +- `repos` - Array of repository names (required) +- `added` - Search only added code (optional) +- `removed` - Search only removed code (optional) +- `author` - Filter by author (optional) +- `after`/`before` - Date range filters (optional) #### `sg_compare_revisions` @@ -464,11 +478,11 @@ Compare changes between two specific revisions. **Parameters:** -- `repo` - Repository name (required) -- `base` - Base revision (older version) (required) -- `head` - Head revision (newer version) (required) -- `first` - Maximum file diffs to return (optional, default 50) -- `after` - Pagination cursor (optional) +- `repo` - Repository name (required) +- `base` - Base revision (older version) (required) +- `head` - Head revision (newer version) (required) +- `first` - Maximum file diffs to return (optional, default 50) +- `after` - Pagination cursor (optional) #### `sg_get_contributor_repos` @@ -476,9 +490,9 @@ Find repositories where a contributor has made commits. **Parameters:** -- `author` - Author name or email (required) -- `limit` - Maximum repositories to return (optional, default 20) -- `minCommits` - Minimum commits required (optional, default 1) +- `author` - Author name or email (required) +- `limit` - Maximum repositories to return (optional, default 20) +- `minCommits` - Minimum commits required (optional, default 1) ## Usage Examples diff --git a/src/middleware.ts b/src/middleware.ts index 5b4c82d3a..910179279 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -146,5 +146,5 @@ export function middleware(request: NextRequest) { } export const config = { - matcher: ['/((?!api|_next/static|_next/image|assets|favicon.ico|sw.js).*)'] + matcher: ['/((?!api/md|_next/static|_next/image|assets|favicon.ico|sw.js).*)'] };