
BanditDB
com.banditdbPublished by banditdb.comv0.3.1Updated Oct 27, 2026
Persistent decision memory for agents — learns which action works in which context
Overview
MCP server for BanditDB, a contextual-bandit database that gives agents persistent memory of which action works in which context.
- What you can do
- Create, list, archive and restore decision campaigns, and add or pause arms
- Ask for the best arm for a given context, singly or in batches, and record success or failure outcomes
- Inspect per-arm learning state, convergence reports and budget spend per resource
- Run against a BanditDB server that learns from every recorded outcome across agents
- When to use it
- Use it when an assistant or a swarm of agents must choose between actions (models, offers, routes) repeatedly and improve from feedback, or when you want shared, persistent decision memory instead of stateless retries.
- Requirements
- A local Python runtime with uvx (package banditdb-python) and a reachable BanditDB server. Set BANDITDB_URL to the server base URL and BANDITDB_API_KEY to an API key; a writer-role key suffices for intuition and outcome tools, while creating or deleting campaigns needs an admin key.
Installation
In SourceWeft
- Open BanditDB in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
BanditDB Python SDK
The official Python client and Model Context Protocol (MCP) server for BanditDB — the ultra-fast, lock-free Contextual Bandit database written in Rust.
BanditDB abstracts away the complex linear algebra of Reinforcement Learning (LinUCB, Thompson Sampling) behind a dead-simple API. Build real-time personalizers, dynamic A/B tests, and give LLM agents mathematically rigorous persistent memory.
mcp-name: com.banditdb/mcp
Installation
Requires the BanditDB Rust server running (default: http://localhost:8080).
1. Standard SDK Usage
The client features automatic connection pooling, exponential backoff retries, and strict timeouts.
Named features or a vector. With features=[...] the campaign stores the
feature order in its metadata, and predict, batch_predict and interact accept
a dict keyed by name. A missing or misspelt name raises ValueError before any
request is sent. Campaigns created in the BanditDB console accept dicts too. The
order is read once per campaign with campaign_info() and cached on the client.
To manage the vector yourself, pass feature_dim instead and send lists —
normalize_context() scales one to unit length.
All Client methods
Health
Campaigns
Predict & Reward
Data & Export
Budget constraints
Server 2.3.0+. Give a campaign one or more budgeted resources and per-arm costs; the server learns a shadow price per resource and steers spend to last the horizon, choosing costly arms only where their uplift is worth it.
Worth knowing:
- Budget is spent at
predict, notreward. A recommendation you never act on still consumes budget. - Budget never resets and pacing is immutable. Once spent, costly arms stay unselectable until the campaign is recreated.
arm_costskeys must be campaign arms. The server would silently treat a misspelt arm as free; the SDK raisesValueErrorinstead.- Predicts on a pacing campaign can return 503 if the server's WAL is saturated.
- Downgrading the server below 2.3.0 silently drops pacing.
2. The AI "Hive Mind" (Model Context Protocol)
Standard LLM agents are stateless — if they route a task to the wrong model and fail, they repeat the same mistake tomorrow. BanditDB's built-in MCP server gives the entire agent swarm shared persistent memory.
Starting the MCP server
Connecting to Claude Desktop
Add to your Claude configuration file:
- Mac:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
The agent swarm now has twelve tools:
Every decision made by any agent in the network improves the routing for all future agents.
3. Data Science & Offline Evaluation
BanditDB event-sources every prediction and reward to a Write-Ahead Log (WAL). Calling checkpoint() compiles completed prediction→reward pairs into Snappy-compressed Parquet files — one per campaign — for offline analysis with Polars or Pandas.
Every prediction is guaranteed to appear in the Parquet file even if its reward arrives hours later: BanditDB re-emits in-flight interactions at each checkpoint so delayed rewards are always captured in a future cycle.
Offline Policy Evaluation (OPE)
The SDK ships three OPE estimators in banditdb.eval. They answer the question: "what would my average reward have been under a different policy — without running a live experiment?"
Install the eval dependencies:
All three estimators:
- Accept a Polars or pandas DataFrame loaded from a BanditDB Parquet export
- Evaluate the uniform random policy as the target (the unbiased baseline to beat)
- Raise
ValueErrorfor Thompson Sampling campaigns (propensity column is null — TS does not log propensities) - Return an
OPEResultwithestimate,std_error,n_used,n_total, andmethod
Practical use: sweep alpha offline before deploying. Train a campaign on real traffic, checkpoint to Parquet, then replay different alpha values through doubly_robust() to find the best exploration level — no live experiment needed.
Note: OPE requires the
propensitycolumn, which is only written for LinUCB campaigns. Thompson Sampling campaigns lognullpropensities because TS arm selection is stochastic and propensity scoring requires a deterministic logging policy.
Choosing an Algorithm
BanditDB supports five algorithms, selected at campaign creation time.
All five algorithms share the same predict → reward loop. Either neural config also works as a Progressive base or challenger.
NeuralLinUCB vs NeuralTS
Both neural algorithms need a server built with the neural feature: check "neural" in db.server_info()["features"].
Error Handling
License
Apache-2.0 — Copyright (C) 2026 Simeon Lukov and Dynamic Pricing Ltd. See the main repository for details.
Source: README.md at commit b1d8e65
Tools
0Version history
2- v0.3.1LatestOct 11, 2026
- v0.2.1Sep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts