You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/MCP.md
+71-56Lines changed: 71 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,15 @@
1
1
# MCP protocol support
2
2
3
-
`mistralrs-server` can serve **MCP (Model ControlProtocol)**traffic next to the regular OpenAI-compatible HTTP interface!
3
+
`mistralrs-server` can speak the **MCP – Model-Control-Protocol**in addition to the regular OpenAI-compatible REST API.
4
4
5
-
MCP is an open, tool-based protocol that lets clients interact with models through structured *tool calls* instead of free-form HTTP routes.
6
-
7
-
Under the hood the server uses [`rust-mcp-sdk`](https://crates.io/crates/rust-mcp-sdk) and exposes tools based on the supported modalities of the loaded model.
5
+
At a high-level, MCP is an opinionated, tool-based JSON-RPC 2.0 protocol that lets clients interact with models through structured *tool calls* instead of specialised HTTP routes.
6
+
The implementation in Mistral.rs is powered by [`rust-mcp-sdk`](https://crates.io/crates/rust-mcp-sdk) and automatically registers tools based on the modalities supported by the loaded model (text, vision, …).
from mcp.client.streamable_http import streamablehttp_client
114
-
115
-
SERVER_URL="http://localhost:4321/mcp"
116
-
117
-
asyncdefmain() -> None:
118
-
asyncwith streamablehttp_client(SERVER_URL) as (read, write, _):
119
-
asyncwith ClientSession(read, write) as session:
120
-
121
-
# --- INITIALIZE ---
122
-
init_result =await session.initialize()
123
-
print("Server info:", init_result.serverInfo)
124
-
125
-
# --- LIST TOOLS ---
126
-
tools =await session.list_tools()
127
-
print("Available tools:", [t.name for t in tools.tools])
128
-
129
-
# --- CALL TOOL ---
130
-
resp =await session.call_tool(
131
-
"chat",
132
-
arguments={
133
-
"messages": [
134
-
{"role": "user", "content": "Hello MCP 👋"},
135
-
{"role": "assistant", "content": "Hi there!"}
136
-
],
137
-
"maxTokens": 50,
138
-
"temperature": 0.7,
139
-
},
140
-
)
141
-
# resp.content is a list[CallToolResultContentItem]; extract text parts
142
-
text ="\n".join(c.text for c in resp.content if c.type =="text")
143
-
print("Model replied:", text)
144
-
145
-
if__name__=="__main__":
146
-
asyncio.run(main())
147
-
```
148
-
149
161
### HTTP
150
162
151
163
**Call a tool:**
@@ -194,9 +206,12 @@ curl -X POST http://localhost:4321/mcp \
194
206
}'
195
207
```
196
208
197
-
## Limitations
209
+
## Limitations & roadmap
210
+
211
+
The MCP support that ships with the current Mistral.rs release focuses on the **happy-path**. A few niceties have not yet been implemented and PRs are more than welcome:
198
212
199
-
- Streaming requests are not implemented.
200
-
- No authentication layer is provided – run the MCP port behind a reverse proxy if you need auth.
213
+
1. Streaming token responses (similar to the `stream=true` flag in the OpenAI API).
214
+
2. An authentication layer – if you are exposing the MCP port publicly run it behind a reverse-proxy that handles auth (e.g. nginx + OIDC).
215
+
3. Additional tools for other modalities such as vision or audio once the underlying crates stabilise.
201
216
202
-
Contributions to extend MCP coverage (streaming, more tools, auth hooks) are welcome!
217
+
If you would like to work on any of the above please open an issue first so the work can be coordinated.
0 commit comments