mcp-mistral-queue
An MCP (Model Context Protocol) server and CLI tool that coordinates local and multi-process / multi-client calls to the Mistral free tier (~1 request / 30 seconds) via a shared SQLite queue. It uses SQLite (WAL mode) and async queueing with a single in-flight task to space request starts. This is best-effort traffic control, not an official SLA.
Features
- Automatic rate-limit coordination: Shared ~31s start interval; on 429, shared backoff then re-enter the gate. Resets to the base interval on success.
- Multi-process & priority control: Multiple processes/tasks can enqueue work. Priority (1–3) plus single in-flight processing order the queue.
- Flexible model & message options: Any Mistral chat model name (defaults to
mistral-small-latest; e.g.mistral-large-latest,codestral-latest), plus full conversation history via amessagesarray. - Streaming & cancel handling: Streams the Mistral API response internally (tool returns the full text); on client cancel (
CancelledError) updates task status in the DB. - Local control DB: Temp DB under a per-user directory with mode
0700(path overridable viaMMQ_TEMP_DB_PATH). - uv-friendly: PEP 723 inline script metadata; use
uv runto resolve deps. - Mistral Vibe integration: Register as an MCP server (
--mcp) for Vibe / Claude Desktop / similar clients. Direct CLI use isuv run(notvibe mmq.py ...).
Prerequisites
- Python 3.10+
- uv installed (0.1.0+ recommended)
- A Mistral API key (
MISTRAL_API_KEY)
export MISTRAL_API_KEY="your-mistral-api-key"
Usage
1. CLI mode (direct run)
Run the script with uv run.
The vibe command is Mistral Vibe’s agent CLI; vibe mmq.py "..." does not execute this script.
# Basic run (default model: mistral-small-latest)
uv run mmq.py "Explain Python list comprehensions briefly"
# Choose a model (e.g. mistral-large-latest, codestral-latest)
uv run mmq.py -m mistral-large-latest "Explain a complex algorithm"
# Custom system prompt
uv run mmq.py -s "You are an AI that speaks casually." "How is the weather today?"
# Priority (1: high, 2: normal, 3: low)
uv run mmq.py --priority 1 "Urgent question"
# Full conversation context as a messages JSON array
uv run mmq.py --messages '[{"role":"system","content":"Strict programmer"},{"role":"user","content":"What is ownership in Rust?"}]'
# Emergency brake: cancel queued / stuck work (no API call)
uv run mmq.py --purge # cancel all pending
uv run mmq.py --purge-all # cancel pending + processing
uv run mmq.py --purge-id 42 # cancel one task by ID
2. MCP server mode (Mistral Vibe / other clients)
Expose the ask_mistral tool to Vibe, Claude Desktop, OpenCode, Goose, and similar clients.
This is a separate path from CLI uv run mmq.py "...".
From a local checkout (works today; uv run resolves PEP 723 deps).
See docs/SMOKE_VIBE.md.
{
"mcpServers": {
"mistral-queue": {
"command": "uv",
"args": [
"run",
"--with", "mcp[cli]>=1.0.0,<2",
"--with", "mistralai>=1.0.0,<2",
"--no-project",
"/absolute/path/to/mmq.py",
"--mcp"
],
"env": {
"MISTRAL_API_KEY": "your-mistral-api-key"
}
}
}
}
After installing from PyPI (console script is mmq, not the package name):
# one-shot without a permanent install
uvx --from mcp-mistral-queue mmq --mcp
# or: pip install mcp-mistral-queue && mmq --mcp
{
"mcpServers": {
"mistral-queue": {
"command": "uvx",
"args": ["--from", "mcp-mistral-queue", "mmq", "--mcp"],
"env": {
"MISTRAL_API_KEY": "your-mistral-api-key"
}
}
}
}
Note: A local
uv buildproducesdist/artifacts; uploading to PyPI requires a token (uv publish). Until the package is on the index, use the path-based config above.
After changing config, restart the client and have the agent use the tools (ask_mistral, get_queue_status; pass model when needed).
MCP tools
When the server is running, clients can use the following tools:
ask_mistral
| Argument | Type | Default | Description |
|---|---|---|---|
| prompt | string | null | Single-shot user prompt text |
| messages | array | null | Conversation history ([{"role": "...", "content": "..."}]) |
| model | string | "mistral-small-latest" |
Mistral model name |
| system_prompt | string | null | Custom system prompt (only when using prompt) |
| priority | number | 2 | Task priority (1: high, 2: normal, 3: low) |
get_queue_status
Returns current shared queue / rate-limit status as JSON:
| Field | Type | Description |
|---|---|---|
| pending | number | Tasks waiting in the queue |
| processing | number | Tasks currently claimed / running |
| seconds_until_next_slot | number | Seconds until the shared API gate opens |
| current_wait_interval | number | Active shared wait interval (seconds) |
| in_flight | boolean | Whether any task is currently processing |
Control data location
The coordination temp DB is stored in a per-user directory created with mode 0700:
- Default:
<tempdir>/mcp_mistral_queue_<USER>/mcp_mistral_flow_control.db
(tempfile.gettempdir(), often/tmpon Linux) - Override: set
MMQ_TEMP_DB_PATHto a full file path (parent dir is created with0700)
Tests
# Unit + e2e (fake API; no network required)
uv run --with 'mcp[cli]>=1.0.0,<2' --with 'mistralai>=1.0.0,<2' \
--with pytest --with pytest-asyncio --no-project \
python -m pytest tests/ -v -m "not live"
# e2e only
uv run --with 'mcp[cli]>=1.0.0,<2' --with 'mistralai>=1.0.0,<2' \
--with pytest --with pytest-asyncio --no-project \
python -m pytest tests/e2e -v -m "not live"
# Live API (optional; consumes free-tier quota)
export MISTRAL_API_KEY=...
uv run --with 'mcp[cli]>=1.0.0,<2' --with 'mistralai>=1.0.0,<2' \
--with pytest --with pytest-asyncio --no-project \
python -m pytest tests/e2e/test_live_api.py -v -m live
e2e uses MMQ_FAKE_API=1 and a short MMQ_BASE_WAIT_TIME to exercise process boundaries (CLI / MCP stdio).
For a manual Vibe UI check, see docs/SMOKE_VIBE.md.
License
MIT License
Copyright (c) 2026 utenadev
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_mistral_queue-0.1.0.tar.gz.
File metadata
- Download URL: mcp_mistral_queue-0.1.0.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
649cf05a6f275661b17a20eaf3dc7f54ff12e3db3f7626532b2bc7d8a01aa968
|
|
| MD5 |
aad5efa84a798ee1ead2cf05d5563cb4
|
|
| BLAKE2b-256 |
edc5838e67206fa819c1c2ce99aba17cdb7c743eb71080feb9d165e8349a22f3
|
File details
Details for the file mcp_mistral_queue-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_mistral_queue-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
870967879dcf96e5a7a384f623cb18a7c95ef1f8b0fb5652749f560f41809156
|
|
| MD5 |
4220c48152c5bd1c6e24fb307ca4e4ff
|
|
| BLAKE2b-256 |
5f3a5317dab5a657902f0887e316f59f637a7b735ac9b1811b3fd4e9e4e6534f
|