-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Document context servers (#21170)
This PR adds documentation for context servers. Release Notes: - N/A
- Loading branch information
1 parent
b83f104
commit 385c447
Showing
7 changed files
with
116 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Context Servers | ||
|
||
Context servers are a mechanism for pulling context into the Assistant from an external source. They are powered by the [Model Context Protocol](./model-context-protocol.md). | ||
|
||
Currently Zed supports context servers providing [slash commands](./commands.md) for use in the Assistant. | ||
|
||
## Installation | ||
|
||
Context servers can be installed via [extensions](../extensions/context-servers.md). | ||
|
||
If you don't already have a context server, check out one of these: | ||
|
||
- [Postgres Context Server](https://github.com/zed-extensions/postgres-context-server) | ||
|
||
## Configuration | ||
|
||
Context servers may require some configuration in order to run or to change their behavior. | ||
|
||
You can configure each context server using the `context_servers` setting in your `settings.json`: | ||
|
||
```json | ||
{ | ||
"context_servers": { | ||
"postgres-context-server": { | ||
"settings": { | ||
"database_url": "postgresql://postgres@localhost/my_database" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
If desired, you may also provide a custom command to execute a context server: | ||
|
||
```json | ||
{ | ||
"context_servers": { | ||
"my-context-server": { | ||
"command": { | ||
"path": "/path/to/my-context-server", | ||
"args": ["run"], | ||
"env": {} | ||
}, | ||
"settings": { | ||
"enable_something": true | ||
} | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Model Context Protocol | ||
|
||
Zed uses the [Model Context Protocol](https://modelcontextprotocol.io/) to interact with [context servers](./context-server.md): | ||
|
||
> The Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you're building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need. | ||
Check out the [Anthropic news post](https://www.anthropic.com/news/model-context-protocol) and the [Zed blog post](https://zed.dev/blog/mcp) for an introduction to MCP. | ||
|
||
## Try it out | ||
|
||
Want to try it for yourself? | ||
|
||
The following context servers are available today as Zed extensions: | ||
|
||
- [Postgres Context Server](https://github.com/zed-extensions/postgres-context-server) | ||
|
||
## Bring your own context server | ||
|
||
If there's an existing context server you'd like to bring to Zed, check out the [context server extension docs](../extensions/context-servers.md) for how to make it available as an extension. | ||
|
||
If you are interested in building your own context server, check out the [Model Context Protocol docs](https://modelcontextprotocol.io/introduction#get-started-with-mcp) to get started. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Context Servers | ||
|
||
Extensions may provide [context servers](../assistant/context-servers.md) for use in the Assistant. | ||
|
||
## Example extension | ||
|
||
To see a working example of an extension that provides context servers, check out the [`postgres-context-server` extension](https://github.com/zed-extensions/postgres-context-server). | ||
|
||
This extension can be [installed as a dev extension](./developing-extensions.html#developing-an-extension-locally) if you want to try it out for yourself. | ||
|
||
## Defining context servers | ||
|
||
A given extension may provide one or more context servers. Each context server must be registered in the `extension.toml`: | ||
|
||
```toml | ||
[context-servers.my-context-server] | ||
``` | ||
|
||
Then, in the Rust code for your extension, implement the `context_server_command` method on your extension: | ||
|
||
```rust | ||
impl zed::Extension for MyExtension { | ||
fn context_server_command( | ||
&mut self, | ||
context_server_id: &ContextServerId, | ||
project: &zed::Project, | ||
) -> Result<zed::Command> { | ||
Ok(zed::Command { | ||
command: get_path_to_context_server_executable()?, | ||
args: get_args_for_context_server()?, | ||
env: get_env_for_context_server()?, | ||
}) | ||
} | ||
} | ||
``` | ||
|
||
This method should return the command to start up a context server, along with any arguments or environment variables necessary for it to function. | ||
|
||
If you need to download the context server from an external source—like GitHub Releases or npm—you can also do this here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters