1---
2title: MCP Server Extensions
3description: "MCP Server Extensions for Zed extensions."
4---
5
6# MCP Server Extensions
7
8[Model Context Protocol servers](../ai/mcp.md) can be exposed as extensions for use in the Agent Panel.
9
10## Defining MCP Extensions
11
12A given extension may provide one or more MCP servers.
13Each MCP server must be registered in the `extension.toml`:
14
15```toml
16[context_servers.my-context-server]
17```
18
19Then, in the Rust code for your extension, implement the `context_server_command` method on your extension:
20
21```rust
22impl zed::Extension for MyExtension {
23 fn context_server_command(
24 &mut self,
25 context_server_id: &ContextServerId,
26 project: &zed::Project,
27 ) -> Result<zed::Command> {
28 Ok(zed::Command {
29 command: get_path_to_context_server_executable()?,
30 args: get_args_for_context_server()?,
31 env: get_env_for_context_server()?,
32 })
33 }
34}
35```
36
37This method should return the command to start up an MCP server, along with any arguments or environment variables necessary for it to function.
38
39If you need to download the MCP server from an external source (GitHub Releases, npm, etc.), you can also do that in this function.
40
41## Available Extensions
42
43See MCP servers published as extensions [on Zed's site](https://zed.dev/extensions?filter=context-servers).
44
45Review their repositories to see common implementation patterns and structure.
46
47## Testing
48
49To test your new MCP server extension, you can [install it as a dev extension](./developing-extensions.md#developing-an-extension-locally).