
BanditDB
com.banditdb由 banditdb.com 發布v0.3.1更新於 Oct 27, 2026
Persistent decision memory for agents — learns which action works in which context
概覽
BanditDB 的 MCP 伺服器:以情境式多臂吃角子老虎機資料庫,讓代理記住哪種動作在何種情境下有效。
- 可以做什麼
- 建立、列出、封存與還原決策活動,並新增或暫停動作
- 依指定情境取得最佳動作,可單次或批次,並記錄成功或失敗結果
- 檢視各動作的學習狀態、收斂報告與各資源的預算消耗
- 連線 BanditDB 伺服器,讓所有代理的結果共同改進模型
- 適用情境
- 適合助手或一群代理需要反覆在多個動作(模型、優惠、路由)之間選擇並從回饋中學習時;也適合需要共享、持久決策記憶而非無狀態重試的情境。
- 執行需求
- 需要本機 Python 執行環境與 uvx(banditdb-python 套件),以及可連線的 BanditDB 伺服器。設定 BANDITDB_URL 為伺服器位址,BANDITDB_API_KEY 為 API 金鑰;writer 角色金鑰即可使用直覺與結果記錄工具,建立或刪除活動則需 admin 金鑰。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 BanditDB,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
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.
來源:README.md,提交 b1d8e65
工具
0版本歷史
2- v0.3.1最新Oct 11, 2026
- v0.2.1Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分