docs: Improve MCP-related pages (#32422)

While creating a new MCP extension this weekend, I visited these pages
and it felt like they could be improved a little bit. I'm renaming the
MCP-related page under the /extension directory to use the "MCP"
acronym, instead of "context servers".

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2025-06-09 21:00:10 -03:00 committed by GitHub
parent 3db00384f4
commit 7c2822a020
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 64 additions and 48 deletions

View file

@ -1,39 +0,0 @@
# Context Servers
Extensions may provide [context servers](../ai/mcp.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.md#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.

View file

@ -8,7 +8,7 @@ Extensions can add the following capabilities to Zed:
- [Themes](./themes.md)
- [Icon Themes](./icon-themes.md)
- [Slash Commands](./slash-commands.md)
- [Context Servers](./context-servers.md)
- [MCP Servers](./mcp-extensions.md)
## Developing an Extension Locally

View file

@ -0,0 +1,44 @@
# MCP Server Extensions
[Model Context Protocol servers](../ai/mcp.md) can be exposed as extensions for use in the Agent Panel.
## Defining MCP Extensions
A given extension may provide one or more MCP servers.
Each MCP 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 an MCP server, along with any arguments or environment variables necessary for it to function.
If you need to download the MCP server from an external source—like GitHub Releases or npm—you can also do that in this function.
## Available Extensions
Check out all the MCP servers that have already been exposed as Zed extensions [on Zed's site](https://zed.dev/extensions?filter=context-servers).
We recommend taking a look at their repositories as a way to understand how they are generally created and structured.
## Testing
To test your new MCP server extension, you can [install it as a dev extension](./developing-extensions.md#developing-an-extension-locally).