db4app-mcp-server
v0.1.9
Published
MCP server for db4.app - enables LLMs to interact with browser-based Postgres databases via Model Context Protocol
Maintainers
Readme
db4app-mcp-server
MCP server for db4.app - enables LLMs to interact with browser-based Postgres databases via Model Context Protocol using the Postgres TCP protocol.
Installation
npm install -g db4app-mcp-serverOr use with npx (no installation needed):
npx db4app-mcp-serverUsage
Important: This MCP server uses the Postgres TCP protocol to connect directly to your browser database, just like psql or other Postgres clients. It uses TLS encryption and password authentication.
With LM Studio
Locate your
mcp.jsonfile:- macOS:
~/Library/Application Support/LM Studio/mcp.json - Windows:
%APPDATA%\LM Studio\mcp.json - Linux:
~/.config/LM Studio/mcp.json
- macOS:
Get your Connection ID and Auth Token:
- Open the Database page in your browser
- Your Connection ID is displayed in the Connection Info section
- Your Auth Token is also shown in the Connection Info section (this is your password)
Add this to the
mcpServersobject in yourmcp.json:
{
"mcpServers": {
"db4app": {
"command": "npx",
"args": [
"-y",
"[email protected]"
],
"env": {
"MCP_POSTGRES_URL": "postgres://postgres:YOUR_AUTH_TOKEN@YOUR_CONNECTION_ID.pg.db4.app",
"LM_STUDIO_EMBEDDING_URL": "http://localhost:1234/v1/embeddings",
"LM_STUDIO_EMBEDDING_MODEL": "text-embedding-qwen3-embedding-4b",
"MCP_SCHEMA": "rag_mcp"
}
}
}
}Note:
- Replace
YOUR_AUTH_TOKENwith your actual auth token from step 2 - Replace
YOUR_CONNECTION_IDwith your Connection ID from step 2 - The connection string format is:
postgres://postgres:AUTH_TOKEN@CONNECTION_ID.pg.db4.app - Postgres TCP Protocol: This server uses the standard Postgres wire protocol with TLS encryption, just like
psqlor DBeaver
Install an Embedding Model (Required for RAG features):
- Open LM Studio → Search tab
- Search for embedding models (e.g., "bge", "e5", "text-embedding")
- Download and load an embedding-capable model
- Update
LM_STUDIO_EMBEDDING_MODELin yourmcp.jsonwith the exact model name - Enable headless server mode in LM Studio
Restart LM Studio to load the configuration.
With Claude Desktop
Get your Connection ID and Auth Token (same as LM Studio setup above)
Add to your
claude_desktop_config.json:
{
"mcpServers": {
"db4app": {
"command": "npx",
"args": [
"-y",
"[email protected]"
],
"env": {
"MCP_POSTGRES_URL": "postgres://postgres:YOUR_AUTH_TOKEN@YOUR_CONNECTION_ID.pg.db4.app",
"LM_STUDIO_EMBEDDING_URL": "http://localhost:1234/v1/embeddings",
"LM_STUDIO_EMBEDDING_MODEL": "text-embedding-qwen3-embedding-4b",
"MCP_SCHEMA": "rag_mcp"
}
}
}
}Note:
- Replace
YOUR_AUTH_TOKENwith your actual auth token - Replace
YOUR_CONNECTION_IDwith your Connection ID - The connection string format is:
postgres://postgres:AUTH_TOKEN@CONNECTION_ID.pg.db4.app
Configuration
All configuration is done via environment variables:
MCP_POSTGRES_URL- Required: Postgres connection string. Format:postgres://postgres:AUTH_TOKEN@CONNECTION_ID.pg.db4.app. Get your Connection ID and Auth Token from the Database page → Connection Info section.MCP_CONNECTION_ID- Optional: Browser connection ID. Used to construct connection URL ifMCP_POSTGRES_URLis not provided (requiresMCP_AUTH_TOKEN).MCP_AUTH_TOKEN- Optional: Auth token for authentication. Used to construct connection URL ifMCP_POSTGRES_URLis not provided (requiresMCP_CONNECTION_ID).LM_STUDIO_EMBEDDING_URL- LM Studio embedding API endpoint (default:http://localhost:1234/v1/embeddings)LM_STUDIO_EMBEDDING_MODEL- Optional model name for embeddingsMCP_SCHEMA- Optional: Schema name for RAG functions (remember,search_memory). Defaults topublic. For recipes, set this to the recipe's schema (e.g.,rag_mcp).POSTHOG_API_KEY- Optional: PostHog API key for performance tracking. If provided, the server will track query performance metrics (connection time, query time, array sizes, timeouts) to help diagnose performance issues.POSTHOG_HOST- Optional: PostHog host URL (default:https://us.i.posthog.com). Only used ifPOSTHOG_API_KEYis set.
Note: This MCP server uses the Postgres TCP protocol with TLS encryption, just like standard Postgres clients. No HTTP or RSA-OAEP encryption is used.
Available Tools
query_database- Execute SQL queries against the databaselist_tables- List tables in the databaseremember- Store information in memory with automatic embedding (usesMCP_SCHEMAfor the target schema)search_memory- Search through stored memories using semantic similarity (usesMCP_SCHEMAfor the target schema)
Security
This MCP server uses the standard Postgres TCP protocol with:
- TLS encryption: All connections are encrypted using TLS (same as
psqlwith SSL) - Password authentication: Uses the auth token as the password
Note: With password authentication, anyone with the auth token can connect with any Postgres client and access all tables. The security model relies on:
- Not sharing the auth token
- Schema isolation (recipes operate in their own schemas)
- Standard Postgres access control (if you have the password, you have access)
Requirements
- Node.js 18+
- Browser tab with db4.app open and relay connected
- Connection ID and Auth Token from the Database page
- For RAG features: LM Studio with embedding-capable model loaded
Connection String Format
The connection string follows the standard Postgres URL format:
postgres://postgres:AUTH_TOKEN@CONNECTION_ID.pg.db4.appWhere:
postgresis the username (fixed)AUTH_TOKENis your auth token (password)CONNECTION_IDis your connection ID (hostname)- Port defaults to 5432 (standard Postgres port)
License
MIT
