Nile MCP Server — LLM-Powered Postgres for B2B
Manage B2B tenants, users, auth, and queries with the Nile MCP server—an LLM-powered Postgres to streamline database and multi-tenant operations.
npx -y @niledatabase/nile-mcp-serverOverview
Nile MCP Server provides a focused backend for B2B applications that need tenant, user, authentication, and query management on top of Postgres. It implements the Model Context Protocol (MCP) pattern to glue application tenancy and security rules to database access while enabling integrations with LLMs and automation layers. In practice, Nile acts like an “LLM-powered Postgres” control plane: it centralizes tenant lifecycle, user auth, and query routing so teams can build multi-tenant products without re-implementing boilerplate.
For developers, Nile reduces the friction of managing per-tenant databases, role-based access, and secure query execution. It is designed to work alongside a Postgres instance and exposes HTTP/JSON APIs and configuration hooks so you can plug it into existing systems or use LLMs to enrich query context, auditing, or intent parsing.
Features
- Tenant lifecycle management: create, update, and isolate tenant resources
- User management and authentication: user signup, login, and role assignment
- Query routing and access control: run SQL queries with tenant scoping and guards
- Integration points for LLMs: add contextual model prompts or schema-aware helpers
- Audit logging: capture query metadata and user activity for compliance
- Configuration-driven: environment variables and config files for DB and auth
- Lightweight HTTP API: easy to call from services, CLI, or scripts
- Designed for B2B/multi-tenant patterns and best practices
Installation / Configuration
The project is hosted on GitHub: https://github.com/niledatabase/nile-mcp-server
Quick start (Docker)
- Run a Postgres instance (example with Docker):
- Run Nile MCP Server (example):
From source (typical Git workflow)
# follow repo README to install dependencies (example: npm install or make)
# then run:
Example environment variables
| Variable | Purpose | Example |
|---|---|---|
| DATABASE_URL | Postgres connection string | postgresql://user:pass@host:5432/db |
| JWT_SECRET | Secret for signing auth tokens | super-secret-value |
| PORT | HTTP server port | 8080 |
| MCP_MODE | Optional: enables MCP-specific behaviors | production / development |
| AUDIT_LOG_PATH | Optional: path or endpoint for audit logs | /var/log/nile-audit.log |
Configuration file alternative (YAML)
server:
port: 8080
database:
url: "postgresql://user:pass@localhost:5432/nile"
auth:
jwt_secret: "replace-with-secret"
logging:
audit: "/var/log/nile-audit.log"
Available Resources
- GitHub repository: https://github.com/niledatabase/nile-mcp-server — source, issues, and contribution guidelines
- API surface: the server exposes REST/JSON endpoints for tenant, user, auth, and query operations (see repo docs for full reference)
- MCP concept docs: read the Model Context Protocol specification used by Nile to understand context injection and model-aware operations (check repo or linked docs)
- Example integrations: sample apps and scripts in the repository demonstrate common patterns (onboarding flows, query proxies, and audit sinks)
Use Cases
Multi-tenant SaaS onboarding
- Use Nile to create a tenant record, set up tenant-specific roles and policies, and provision a scoped connection for that tenant. The server can centralize the lifecycle so your product code only calls a single API to onboard new customers.
Secure query proxy for client apps
- Client applications send queries (or natural-language prompts) to Nile rather than directly to Postgres. Nile enforces tenant scoping, role checks, and audit logging, reducing risk of accidental cross-tenant access.
LLM-assisted analytics
- Integrate an LLM to convert user intents into SQL or enrich queries with schema-aware context via MCP hooks. Nile can inject model context (table schemas, column descriptions, policies) before executing or logging a query.
Centralized auditing and compliance
- Route all database activity through Nile so you have a single stream of authenticated actions, timestamps, and request metadata suitable for audits, alerts, or usage billing.
Example API flow (illustrative)
# Create tenant
# Create user and obtain token
# Run a tenant-scoped query (use Authorization header)
Notes and best practices
- Secure your JWT secrets and database credentials; rotate regularly.
- Use network policies and VPCs for Postgres connectivity in production.
- Review audit logs and retention policies for compliance requirements.
- Check the repository for up-to-date API specs and example clients.
For detailed API reference, examples, and advanced configuration, consult the project repository: https://github.com/niledatabase/nile-mcp-server