
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 分