NI

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.

Quick Install
npx -y @niledatabase/nile-mcp-server

Overview

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)

  1. Run a Postgres instance (example with Docker):
docker run -d --name pg \
  -e POSTGRES_PASSWORD=postgres \
  -e POSTGRES_DB=nile \
  -p 5432:5432 \
  postgres:15
  1. Run Nile MCP Server (example):
docker run -it --rm \
  -e DATABASE_URL=postgresql://postgres:[email protected]:5432/nile \
  -e JWT_SECRET=replace-with-secure-secret \
  -e PORT=8080 \
  -p 8080:8080 \
  ghcr.io/niledatabase/nile-mcp-server:latest

From source (typical Git workflow)

git clone https://github.com/niledatabase/nile-mcp-server.git
cd nile-mcp-server
# follow repo README to install dependencies (example: npm install or make)
# then run:
npm start

Example environment variables

VariablePurposeExample
DATABASE_URLPostgres connection stringpostgresql://user:pass@host:5432/db
JWT_SECRETSecret for signing auth tokenssuper-secret-value
PORTHTTP server port8080
MCP_MODEOptional: enables MCP-specific behaviorsproduction / development
AUDIT_LOG_PATHOptional: 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

  1. 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.
  2. 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.
  3. 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.
  4. 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
curl -X POST http://localhost:8080/tenants -H "Content-Type: application/json" \
  -d '{"name":"Acme Corp","plan":"enterprise"}'

# Create user and obtain token
curl -X POST http://localhost:8080/auth/signup -d '{"email":"[email protected]","password":"pwd"}'

# Run a tenant-scoped query (use Authorization header)
curl -X POST http://localhost:8080/query \
  -H "Authorization: Bearer <JWT>" \
  -d '{"sql":"SELECT id, name FROM orders WHERE tenant_id = $1","params":[123]}'

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