Setup & Connections
Getting Bollard connected to your database is simple. It runs as a standard Model Context Protocol (MCP) server over standard input/output streams, meaning any modern editor client (such as Cursor or VS Code) can manage the server daemon process directly.
1. Installation
Bollard is packaged as a standard Python module available on PyPI. You can install it globally, in a project virtual environment, or run it directly from source.
Global Installation (Recommended)
Install the package globally using pip. This automatically registers the bollard-mcp CLI executable in your system path:
pip install bollard-mcpVirtual Environment Installation
If you prefer to lock dependencies per project or keep your system scope clean, install it in a local Python virtual environment:
# Create virtual environment and activate
python -m venv .venv
# Activate on macOS/Linux
source .venv/bin/activate
# Activate on Windows (PowerShell)
.venv\Scripts\activate
# Install the package
pip install bollard-mcpDeveloper Source Installation
To run the latest bleeding-edge updates directly from the source repository:
git clone https://github.com/Bollard-db/Bollard.git
cd Bollard
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
pip install -e .2. Configuring your IDE Client
Because Bollard implements the standard Model Context Protocol (MCP), it integrates out-of-the-box with any modern IDE client that supports MCP servers.
Cursor
To configure Bollard in Cursor:
- Navigate to Cursor Settings > Features > MCP.
- Click + Add New MCP Server.
- Configure the server with the following settings:
- Name:
bollard - Type:
command - Command:
bollard-mcp(or the full absolute path to the executable inside your virtualenv)
- Name:
Alternatively, you can edit your Cursor MCP config file directly:
- Windows:
%USERPROFILE%\.cursor\mcp.json - macOS/Linux:
~/.cursor/mcp.json
{
"mcpServers": {
"bollard": {
"command": "bollard-mcp",
"env": {
"BOLLARD_DEBUG": "false"
}
}
}
}{
"mcpServers": {
"bollard": {
"command": "bollard-mcp",
"env": {
"BOLLARD_DEBUG": "false"
}
}
}
} GitHub Copilot (VS Code)
To configure Bollard with GitHub Copilot Chat in VS Code, you can set up the mcp.json file structure either globally or locally for your workspace. Note that Copilot expects the top-level key to be "servers" instead of "mcpServers".
Option A: Global User Setup (All projects)
- Open the VS Code Command Palette (
Ctrl+Shift+PorCmd+Shift+P). - Search for and select MCP: Open User Configuration.
- If the configuration file is empty, paste the full JSON below. If you already have other servers configured, add the
"bollard"block inside your existing"servers"object:
{
"servers": {
"bollard": {
"command": "bollard-mcp",
"env": {
"BOLLARD_DEBUG": "false"
}
}
}
}Option B: Local Workspace Setup (This project only)
- Create a folder named
.vscodeat the root of your project workspace. - Create a file named
mcp.jsoninside it (i.e..vscode/mcp.json). - If this is a new configuration file, paste the full JSON below. If you already have other servers configured, add the
"bollard"block inside your existing"servers"object:
{
"servers": {
"bollard": {
"command": "bollard-mcp",
"env": {
"BOLLARD_DEBUG": "false"
}
}
}
}VS Code (with Cline / Roo Code / Claude Dev)
To use Bollard with Claude/Roo agents in VS Code using the Cline extension:
- Click the Cline tab in the sidebar.
- Click the gear icon (Settings) in the top-right corner.
- Scroll down to the MCP Settings section and click Edit MCP Settings.
- Add the server configuration to the JSON file:
The configuration file is located at:
- Windows:
%APPDATA%\\Code\\User\\globalStorage\\saoudrizwan.claude-dev\\settings\\cline_mcp_settings.json - macOS:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
{
"mcpServers": {
"bollard": {
"command": "bollard-mcp",
"env": {
"BOLLARD_DEBUG": "false"
}
}
}
}Windsurf
To use Bollard inside Windsurf:
Add the configuration under your global Windsurf MCP configuration file located at:
- Windows:
%USERPROFILE%\\.codeium\\windsurf\\mcp_config.json - macOS/Linux:
~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"bollard": {
"command": "bollard-mcp",
"env": {
"BOLLARD_DEBUG": "false"
}
}
}
}Claude Desktop Client
To configure Bollard with the official Claude Desktop app:
Edit your Claude Desktop configuration file located at:
- Windows:
%APPDATA%\\Claude\\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"bollard": {
"command": "bollard-mcp",
"env": {
"BOLLARD_DEBUG": "false"
}
}
}
}If you check your IDE's MCP logs and see a Connection state: Error spawn bollard-mcp ENOENT error, it means your editor cannot find the bollard-mcp executable in your system's PATH.
How to fix:
- Open your terminal and run
where bollard-mcp(on Windows) orwhich bollard-mcp(on macOS/Linux). - Copy the returned absolute path to the executable.
- Replace
"command": "bollard-mcp"with the full path in your configuration JSON (for example,"C:\\\\Users\\\\username\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python310\\\\Scripts\\\\bollard-mcp.exe"on Windows, or"/home/username/.local/bin/bollard-mcp"on Linux).
OpenAI Codex
To configure Bollard with OpenAI Codex, you can add the server under the [mcp_servers] table in your Codex configuration file:
- Windows:
%USERPROFILE%\.codex\config.toml - macOS/Linux:
~/.codex/config.toml
[mcp_servers.bollard]
command = "python" # or "bollard-mcp" if installed globally via pipx
args = ["-m", "bollard_mcp.server"]
cwd = "/path/to/bollard-mcp" # optional: set workspace directoryIn standalone clients (like OpenAI Codex or Claude Desktop) that do not run the editor helper extension, Bollard automatically falls back to an In-Chat PIN Gate. When the AI attempts a write query, the server will block execution, generate a local 4-digit verification PIN, and print it directly in the chat. You simply need to copy-paste this PIN back into the chat prompt to authorize and run the write query safely.
Cross-Platform OS Binary Path Resolution
If your IDE cannot find the bollard-mcp command globally, replace "command": "bollard-mcp" with the full absolute path where Python installed the binary:
- Windows (Global Pip):
"C:\\\\Users\\\\YourUsername\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python310\\\\Scripts\\\\bollard-mcp.exe" - macOS/Linux (Global Pip):
"/usr/local/bin/bollard-mcp"or"/Users/YourUsername/.local/bin/bollard-mcp" - Virtual Environment:
"/path/to/your/project/.venv/bin/bollard-mcp"(macOS/Linux) or"C:\\\\path\\\\to\\\\your\\\\project\\\\.venv\\\\Scripts\\\\bollard-mcp.exe"(Windows)
3. Environment Variables
You can fine-tune Bollard using the following environment variables. Place them in your editor's MCP configuration settings or in a .env file in the server's working directory.
| Variable | Type | Default | Description |
|---|---|---|---|
BOLLARD_SERVER_NAME | string | "Bollard Database MCP" | Server identifier displayed in your editor client. |
BOLLARD_DEBUG | boolean | false | Enables verbose logging to standard error for debugging. |
BOLLARD_DEFAULT_MAX_ROWS | integer | 1000 | Hard limit applied to query result rows to protect context window tokens. |
BOLLARD_DEFAULT_QUERY_TIMEOUT | integer | 30 | Max running time in seconds before a query is aborted. |
BOLLARD_DEFAULT_MAX_COST | float | 100000.0 | Cost warning threshold. Evaluates estimated cost via EXPLAIN plans. |
BOLLARD_SESSION_HISTORY_LIMIT | integer | 100 | Max number of execution logs kept in the query history buffer. |
BOLLARD_SCHEMA_CACHE_TTL | integer | 300 | Lifespan in seconds for caching DB schema blueprints (5 minutes). |
BOLLARD_CREDENTIAL_BACKEND | string | "auto" | Backend for credential store. Options: auto, keyring, encrypted. |
BOLLARD_ENCRYPTION_KEY | string | null | Base64 Fernet key used to encrypt the credentials fallback file. |
BOLLARD_AI_ENABLED | boolean | false | Enables the internal AI query optimization advisor modules. |
BOLLARD_AI_PROVIDER | string | "anthropic" | AI provider endpoint target. Options: anthropic, nvidia_nim. |
BOLLARD_ANTHROPIC_API_KEY | string | null | Anthropic Developer API key credential. |
BOLLARD_NVIDIA_NIM_API_KEY | string | null | Nvidia NIM API key credential. |
BOLLARD_NVIDIA_NIM_BASE_URL | string | "https://integrate.api.nvidia.com/v1" | Nvidia NIM base service endpoint. |
BOLLARD_EXTENSION_PORT | integer | null | Port mapped to communicate with the active VS Code extension notification bridge. |
4. PgBouncer & Transaction Poolers
When connecting to transaction-pooled database endpoints (like Supabase's pooler.supabase.com on port 6543), database drivers often crash with a DuplicatePreparedStatementError.
PgBouncer routes queries across transient backend DB threads. Because prepared statements are stored in connection memory, this creates execution conflicts that cause client sessions to crash.
Bollard Solution: The database adapter checks if the connection URL contains "pooler" or "pgbouncer". If matched, it disables statement caching by setting statement_cache_size = 0 on the underlying asyncpg connection engine. This ensures query execution stability over pooled ports.
5. Connection String Examples by Provider
Here is the reference for connection formats required for popular database hosting providers:
Local Docker (PostgreSQL)
If you are running a local database inside a Docker container for development and testing:
- Connection String:
postgresql://[user]:[pass]@localhost:5432/[db_name]
Example:postgresql://postgres:postgres@localhost:5432/dbcopilot - Seeding the Database: You can seed a local test database populated with tables (users, orders, secrets) to test safety limits and query interception rules:
python examples/create_postgres_test_db.py
Supabase (PostgreSQL)
- Session (Direct Port 5432):
postgresql://postgres.[ref]:[pass]@aws-0-[region].pooler.supabase.com:5432/postgres - Transaction Pooler (Port 6543):
postgresql://postgres.[ref]:[pass]@aws-0-[region].pooler.supabase.com:6543/postgres?pgbouncer=true
Note: Bollard automatically disables statement caching on this port to prevent session crashes.
Neon (Serverless Postgres)
- Connection String:
postgresql://[user]:[pass]@[neon-id].aws.neon.tech/neondb?sslmode=require
Note: SSL is required by Neon. Bollard will automatically appendsslmode=requireif you omit it.
Render & Railway (PostgreSQL)
- Connection String:
postgresql://[user]:[pass]@[host].oregon-postgres.render.com/[db_name]?sslmode=require
Turso (Edge SQLite)
- Connection String:
sqlite+libsql://[db-name]-[org-name].turso.io?uri=...or standard local SQLite path:sqlite:///c:/path/to/local.db
MongoDB Atlas (Document Database)
- Connection String:
mongodb+srv://[user]:[pass]@[cluster].mongodb.net/[db_name]?retryWrites=true&w=majority
Note: Requires installing Bollard with MongoDB support:pip install bollard-mcp[mongodb].
