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
Copy file name to clipboardExpand all lines: docs/docs/more/mcp-server.mdx
+11-2Lines changed: 11 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,9 @@ The [Model Context Protocol](https://modelcontextprotocol.io/introduction) (MCP)
13
13
14
14
<Steps>
15
15
<Steptitle="Launch Sourcebot">
16
-
Follow the self-hosting [quick start guide](/self-hosting/overview#quick-start-guide) to launch Sourcebot and get your code indexed.
16
+
Follow the self-hosting [quick start guide](/self-hosting/overview#quick-start-guide) to launch Sourcebot and get your code indexed. The host url of your instance (e.g., `http://localhost:3000`) is passed to the MCP server via the `SOURCEBOT_HOST` url.
17
+
18
+
If a host is not provided, then the server will fallback to using the demo instance hosted at https://demo.sourcebot.dev. You can see the list of repositories indexed [here](https://demo.sourcebot.dev/~/repos). Add additional repositories by [opening a PR](https://github.com/sourcebot-dev/sourcebot/blob/main/demo-site-config.json).
17
19
</Step>
18
20
19
21
<Steptitle="Install the MCP server">
@@ -83,6 +85,9 @@ The [Model Context Protocol](https://modelcontextprotocol.io/introduction) (MCP)
83
85
"type": "stdio",
84
86
"command": "npx",
85
87
"args": ["-y", "@sourcebot/mcp@latest"]
88
+
},
89
+
"env": {
90
+
"SOURCEBOT_HOST": "http://localhost:3000"
86
91
}
87
92
}
88
93
}
@@ -97,7 +102,7 @@ The [Model Context Protocol](https://modelcontextprotocol.io/introduction) (MCP)
97
102
Run the following command:
98
103
99
104
```sh
100
-
claude mcp add sourcebot -e http://localhost:3000 -- npx -y @sourcebot/mcp@latest
105
+
claude mcp add sourcebot -e SOURCEBOT_HOST=http://localhost:3000 -- npx -y @sourcebot/mcp@latest
101
106
```
102
107
103
108
Replace `http://localhost:3000` with wherever your Sourcebot instance is hosted.
@@ -126,6 +131,10 @@ The [Model Context Protocol](https://modelcontextprotocol.io/introduction) (MCP)
An MCP server that provides blazingly fast regex-based code search, allowing LLMs to fetch code context from repositories you don't have checked out.
9
+
The Sourcebot MCP server enables precise regular expression code search across repos hosted on [GitHub](https://docs.sourcebot.dev/docs/connections/github), [GitLab](https://docs.sourcebot.dev/docs/connections/gitlab), [BitBucket](https://docs.sourcebot.dev/docs/connections/bitbucket-cloud) and [more](#supported-code-hosts). This unlocks the capability for LLM agents to fetch code context for repositories that aren't checked out locally. Some use cases where precise search on a wider code context can help:
10
+
11
+
- Enriching responses to user requests:
12
+
-_"What repositories are using internal library X?"_
13
+
-_"Provide usage examples of the CodeMirror component"_
14
+
-_"Where is the `useCodeMirrorTheme` hook defined?"_
15
+
-_"Find all usages of `deprecatedApi` across all repos"_
16
+
17
+
- Improving reasoning ability for existing horizontal agents like AI code review, docs generation, etc.
18
+
-_"Find the definitions for all functions in this diff"_
19
+
-_"Document what systems depend on this class"_
20
+
21
+
- Building custom LLM horizontal agents like like compliance auditing agents, migration agents, etc.
22
+
-_"Find all instances of hardcoded credentials"_
23
+
-_"Identify repositories that depend on this depreacted api"_
24
+
10
25
11
26
## Getting Started
12
-
Please follow [these docs](https://docs.sourcebot.dev/docs/more/mcp-server) to get started.
27
+
28
+
1. Install Node.JS >= v18.0.0.
29
+
30
+
2. (optional) Spin up a Sourcebot instance by following [this guide](https://docs.sourcebot.dev/self-hosting/overview). The host url of your instance (e.g., `http://localhost:3000`) is passed to the MCP server via the `SOURCEBOT_HOST` url.
31
+
32
+
If a host is not provided, then the server will fallback to using the demo instance hosted at https://demo.sourcebot.dev. You can see the list of repositories indexed [here](https://demo.sourcebot.dev/~/repos). Add additional repositories by [opening a PR](https://github.com/sourcebot-dev/sourcebot/blob/main/demo-site-config.json).
| Don't see your code host? Open a [GitHub discussion](https://github.com/sourcebot-dev/sourcebot/discussions/categories/ideas).
206
+
207
+
## Future Work
208
+
209
+
### Semantic Search
210
+
211
+
Currently, Sourcebot only supports regex-based code search (powered by [zoekt](https://github.com/sourcegraph/zoekt) under the hood). It is great for scenarios when the agent is searching for is something that is super precise and well-represented in the source code (e.g., a specific function name, a error string, etc.). It is not-so-great for _fuzzy_ searches where the objective is to find some loosely defined _category_ or _concept_ in the code (e.g., find code that verifies JWT tokens). The LLM can approximate this by crafting regex searches that attempt to capture a concept (e.g., it might try a query like `"jwt|token|(verify|validate).*(jwt|token)"`), but often yields sub-optimal search results that aren't related. Tools like Cursor solve this with [embedding models](https://docs.cursor.com/context/codebase-indexing) to capture the semantic meaning of code, allowing for LLMs to search using natural language. We would like to extend Sourcebot to support semantic search and expose this capability over MCP as a tool (e.g., `semantic_search_code` tool). [GitHub Discussion](https://github.com/sourcebot-dev/sourcebot/discussions/297)
212
+
213
+
### Code Navigation
214
+
215
+
Another idea is to allow LLMs to traverse abstract syntax trees (ASTs) of a codebase to enable reliable code navigation. This could be packaged as tools like `goto_definition`, `find_all_references`, etc., which could be useful for LLMs to get additional code context. [GitHub Discussion](https://github.com/sourcebot-dev/sourcebot/discussions/296)
216
+
217
+
### Got an idea?
22
218
23
-
| Don't see your code host? Open a [GitHub discussion](https://github.com/sourcebot-dev/sourcebot/discussions/categories/ideas).
219
+
Open up a [GitHub discussion](https://github.com/sourcebot-dev/sourcebot/discussions/categories/feature-requests)!
0 commit comments