1# Context Servers
2
3Extensions may provide [context servers](../ai/mcp.md) for use in the Assistant.
4
5## Example extension
6
7To 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).
8
9This extension can be [installed as a dev extension](./developing-extensions.html#developing-an-extension-locally) if you want to try it out for yourself.
10
11## Defining context servers
12
13A given extension may provide one or more context servers. Each context 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 a context server, along with any arguments or environment variables necessary for it to function.
38
39If you need to download the context server from an external source—like GitHub Releases or npm—you can also do this here.