SmartBW MCP
Provides tools for securely accessing and managing passwords, API keys, and other credentials stored in a Bitwarden vault, enabling AI agents to retrieve items via fuzzy search, exact lookup, or custom fields.
Provides tools for securely accessing and managing passwords, API keys, and other credentials stored in a Vaultwarden vault, enabling AI agents to retrieve items via fuzzy search, exact lookup, or custom fields.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SmartBW MCPretrieve the password for my email account"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
SmartBW MCP
Vaultwarden/Bitwarden MCP 代理 — 让 AI 安全获取密码和 API Key
SmartBW MCP 是一个 MCP (Model Context Protocol) 工具服务器,让 AI Agent 通过标准 MCP 接口安全访问你的 Vaultwarden/Bitwarden 密码库。
架构
smartbw_mcp_server.py ← MCP 工具层(8 个工具,AI 零门槛调用)
│
smart_search.py ← 智能搜索层(6 策略模糊搜索 + 索引加速)
│
mcp_raw.py ← 通信层(JSON-RPC + 熔断保护)
│
mcp_daemon.py ← 守护进程层(Unix Socket 常驻 + 自愈 + 单实例保护)
│
@bitwarden/mcp-server (Node.js) ← 协议层(Bitwarden 官方 MCP Server)
│
Vaultwarden 服务器 ← 数据层paths.py ← 横切:统一运行时路径(配置目录 / 运行状态目录)
config.py · crypto_config.py · unlock.py · models.py
← 支撑:配置加载 / 凭证加密 / 自动解锁 / 数据类型Related MCP server: Warden MCP Server
快速开始
1. 安装依赖
npm install -g @bitwarden/cli @bitwarden/mcp-server
pip install cryptography2. 配置
cp config.example.json ~/.config/bitwarden-mcp/config.json
# 编辑 config.json,填入你的 Vaultwarden 信息config.json 示例:
{
"bw_host": "https://your-vaultwarden.example.com",
"email": "user@example.com",
"master_password": "YourMasterPassword",
"client_id": "",
"client_secret": ""
}也可使用环境变量
BW_HOST、BW_EMAIL、BW_MASTER_PASSWORD替代配置文件。
3. 启动守护进程
# 一键安装(含 systemd 服务或后台进程)
bash install.sh
# 或手动启动
python3 mcp_daemon.py4. 配置 MCP 客户端
在你的 MCP 客户端中添加:
{
"mcpServers": {
"smartbw": {
"command": "python3",
"args": ["/path/to/smartbw_mcp_server.py"]
}
}
}MCP 工具
工具 | 功能 |
| 一行获取 API Key(自动搜索 API 字段) |
| 获取密码 |
| 获取任意自定义字段 |
| 获取项目完整信息 |
| 模糊搜索(名称/用户名/自定义字段) |
| 列出所有项目 |
| 检查守护进程状态 |
| 强制刷新(bw sync + 重启 MCP server + 清缓存) |
核心特性
模糊搜索: 6 种评分策略,名称/用户名/自定义字段全覆盖,支持错别字容错
索引加速: 首次加载后构建名称索引,精确/前缀匹配 O(1)
短 TTL 缓存: 项目列表常驻内存,TTL 15s 按需刷新(无定时器);过期即同步刷新,无结果/结果可疑自动重查;无人查询时零后端请求
熔断保护: 连续 5 次失败 → 30s 冷却,防止雪崩
线程安全: socket 收发原子锁 + 缓存 single-flight 锁(并发查询只实际拉取一次)
自愈: 守护进程每 60s 健康检查,session 过期自动恢复
凭证加密:
master_password/client_secret/api_key自动 Fernet 加密存储,密钥绑定本机指纹
安全
Unix Socket 权限
0o600(umask + chmod 双重保护)日志目录
0o700/ 日志文件0o600(含每日轮转后新建的当前日志),日志中的账号以掩码记录密码/API Key 由 Vaultwarden 托管,本地仅按需读取
配置文件中的敏感字段自动加密(
!enc:v1:...),含master_password/client_secret/api_key加密密钥绑定本机,配置文件不可跨机器复制
配置参考
配置项 | 环境变量 | 说明 |
Vaultwarden 地址 |
| 如 |
登录邮箱 |
| |
主密码 |
| 会自动加密存储 |
API Key |
| 推荐,兼容 2FA; |
API Key(单字段) |
|
|
MCP Server 路径 |
| 留空自动发现(npm/which/常见路径) |
自定义配置目录 |
| 默认 |
daemon Socket 路径 |
| 默认 |
daemon 启动宽限 |
| 默认 5s;连不上时先反复重试该时长再考虑拉起新实例(设 |
MCP 超时 |
| 默认 30s |
模糊搜索阈值 |
| 默认 0.5 |
缓存 TTL |
| 默认 15s;过期即同步刷新,无定时器 |
强制刷新最小间隔 |
| 默认 5s;避免一次查询重复拉取 |
结果可疑阈值 |
| 默认 0.6;须 > 模糊搜索阈值,否则该分支不生效 |
自动解锁 |
| 默认 1(设为 |
自动解锁重试次数 |
| 默认 3 |
CLI 超时(status/login/unlock/discovery) |
| 默认 10 / 15 / 15 / 10s |
日志级别 / 日志文件 |
|
|
开发与测试
pip install -e ".[dev]" # pytest / pytest-cov / ruff / black
python -m ruff check . # lint(CI 阻断项)
python -m pytest -q --cov=. --cov-report=term-missing --cov-fail-under=40项目 | 当前状态 |
测试 | 122 项通过、2 项跳过 |
覆盖率 | 47%(CI 门槛 40%,低于则构建失败) |
Lint |
|
CI 矩阵 | Python 3.8 / 3.10 / 3.12 + wheel 打包内容校验 |
测试默认完全隔离:tests/conftest.py 会把 HOME 与 SMARTBW_CONFIG_DIR 指向临时目录,
不读写你的真实配置。只有显式设置 SMARTBW_LIVE_TEST=1 的用例才连接真实 daemon,
其余需要真机的用例自动跳过。
顶部 Tests / Coverage 徽章为静态值,与上表同源,发版时同步更新。
发版流程(三处版本号一致性校验、CI 自动打 tag 与创建 Release)与推送前脱敏审计见 CONTRIBUTING.md。
文档
文档 | 说明 |
架构设计与通信路径 | |
依赖与版本要求 | |
Deep Code 集成 | |
OpenClaw 集成 | |
VS Code 集成(含安装踩坑记录) | |
故障排查 | |
贡献指南 |
许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Shared long-term memory vault for AI agents with 20 MCP tools.
MCP-first toolbox for agents: KV storage, auth, queue, and utility tools. Free in early access.
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
Persistent memory for AI agents across Claude, ChatGPT and any MCP client.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents and automation scripts to securely interact with self-hosted Vaultwarden instances through the Bitwarden CLI, automatically managing vault sessions and providing tools to read, create, update, and delete secrets programmatically.10 npm2MIT
- AlicenseAqualityAmaintenanceMCP server for Vaultwarden/Bitwarden vault management. Enables AI agents to securely create, search, read, and update vault items via the official Bitwarden CLI, with safe-by-default redaction and support for both stdio and SSE transports.53876 npm18MIT
- FlicenseBqualityDmaintenanceEnables secure retrieval of credentials from 1Password vaults for use by AI agents, supporting integration with browser automation for automated login.1-
- AlicenseNot gradedqualityAmaintenanceProvides MCP tools for AI agents to securely access approved 1Password logins via encrypted handles, resolving secrets locally through the 1Password CLI without exposing plaintext passwords.86 npmMIT