context_servers.md

 1# Context Servers
 2
 3A Context Server is an experimental interface for defining simple, language-agnostic slash commands in Zed's [Assistant](./assistant.md). Context Servers allow you to extend Zed's Assistant to interface with external capabilities and systems in a language-agnostic way.
 4
 5If slash commands allow you to extend the Assistant with new capabilities, Context Servers follow a simple protocol for registering and making use of those capabilities.
 6
 7## Using a Context Server
 8
 9To configure Zed to use a Context Server, add the command required to start the server to your [settings](./configuring-zed.md):
10
11```json
12{
13  "experimental": {
14    "context_servers": [
15      {
16        "id": "python_context_server",
17        "executable": "python",
18        "args": ["-m", "my_context_server"]
19      }
20    ]
21  }
22}
23```
24
25## Developing a Context Server
26
27A Context Server is a server listening for JSON-RPC requests over stdin/stdout. The server must follow the Model Context Protocol (defined below) in order to declare its capabilities such that Zed can make use of them.
28
29### Should you write a Context Server?
30
31[Extensions](./extensions.md) are also capable of adding slash commands to the Assistant.
32
33If your slash commands are already implemented in a language other than Rust, wrapping them in a Context Server implementation will likely be the fastest way to plug them into Zed.
34
35An Extension should be preferred when:
36
37- Your slash commands are implemented in WebAssembly-compatible Rust
38- You want Zed to manage distribution of your slash commands
39- You want to publish your slash commands
40
41### Implementing a Context Server
42
43Context Servers must comply with the [Model Context Protocol (MCP)](./model_context_protocol). See [python-context-server](https://github.com/zed-industries/python-context-server) for a minimal working example.
44
45Currently, Zed's client only implements the subset of the protocol required to support custom prompt insertions and manipulations, although this is likely to be extended in the future.