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### Implementing a Context Server
30
31Context Servers are JSON-RPC servers communicating over stdio. Context Servers must comply with the [Model Context Protocol (MCP)](./model_context_protocol).
32
33See [python-context-server](https://github.com/zed-industries/python-context-server) for a minimal working example.
34
35Currently, Zed's client only implements a subset of the protocol required to support custom prompt insertions and manipulations. This is likely to be expanded in the future.
36
37### Should you write a Context Server?
38
39[Extensions](../extensions.md) are also capable of [adding slash commands to the Assistant](../extensions/slash-commands.md).
40
41If 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.
42
43An Extension should be preferred when:
44
45- Your slash commands are implemented in WebAssembly-compatible Rust
46- You want Zed to manage distribution of your slash commands
47- You want to publish your slash commands