PostgreBase logo

PostgreBase

Community
zhenruyan

AI-Native No-Code API Development Platform Based on PocketBase, with native PostgreSQL/MySQL/SQLite support, built-in MCP server, hybrid caching (Redis / memory), and 100% PocketBase API compatibility.

Publisherzhenruyan
Repositorypostgrebase
LanguageGo
Forks
10
Stars
96
Available tools
0
Transport typestdio, streamable-http
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    PostgreBase exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    96 stars and 10 forks from the linked repository.

PostgreBase — AI原生的无代码API开发工具

PostgreBase 是 AI 原生的无代码 API 开发平台,基于 PocketBase 重构。内置 MCP (Model Context Protocol) 服务器,让 AI 工具(Claude、Cursor、Windsurf)直接操作你的数据。支持 PostgreSQL、MySQL、SQLite 三种数据库,提供即时 REST API + 实时订阅 + Admin UI,5分钟上线你的后端服务。

Features

  • Three Database Engines:
    • PostgreSQL (default) — production-grade concurrency, clustering, and complex queries.
    • MySQL — fully compatible via the mysql:// DSN prefix.
    • SQLite (pure Go, no CGO) — zero-dependency local development and testing via sqlite:// DSN or .db file path.
  • Cluster-Ready Architecture: No reliance on local database files means multiple instances can run behind a load balancer with a shared PostgreSQL/MySQL backend.
  • Hybrid Caching:
    • Redis Cache (--redisDsn) — distributed caching for cluster environments; SSE Realtime subscriptions synchronize across nodes via Redis Pub/Sub.
    • In-Memory Cache — automatic fallback to high-performance local memory caching when Redis is not configured.
  • MCP (Model Context Protocol) Server:
    • JSON-RPC 2.0 protocol enabling AI tools (Claude Desktop, Cursor, Windsurf) to interact with your data.
    • 8 built-in tools: list_collections, get_collection, list_records, get_record, create_record, update_record, delete_record, search_records.
    • Resources: postgrebase://collections, postgrebase://settings.
    • Three transport modes: SSE (HTTP), Streamable HTTP, and Stdio.
    • MCP-specific API tokens with expiration support, manageable from the Admin UI.
  • Zero External Dependencies for SQLite: Uses modernc.org/sqlite (pure Go transpilation of SQLite), builds with CGO_ENABLED=0.

Quick Start

Prerequisites

  • Go 1.26.2+
  • PostgreSQL, MySQL, or nothing (SQLite works out of the box)

Build

bash
git clone https://github.com/zhenruyan/postgrebase.git
cd postgrebase
go build -o pb ./build/

For static builds (no CGO):

bash
CGO_ENABLED=0 go build -o pb ./build/

Run

SQLite (Local Development)

bash
# Using sqlite:// prefix
./pb serve --dataDsn "sqlite://./pb_data/dev.db"

# Or just pass a .db file path
./pb serve --dataDsn "./pb_data/dev.db"

PostgreSQL (Recommended for Production)

bash
./pb serve --dataDsn "postgresql://user:password@127.0.0.1:5432/dbname?sslmode=disable"

MySQL

bash
./pb serve --dataDsn "mysql://user:password@tcp(127.0.0.1:3306)/dbname"

With Redis Cache

bash
./pb serve --dataDsn "postgres://..." --redisDsn "redis://127.0.0.1:6379/0"

Docker

bash
# Build the image
docker build -t postgrebase .

# Run with SQLite
docker run -p 8090:8090 -v pb_data:/pb/pb_data postgrebase serve --dataDsn "sqlite:///pb/pb_data/dev.db"

# Run with PostgreSQL
docker run -p 8090:8090 postgrebase serve --dataDsn "postgres://user:pass@host:5432/db?sslmode=disable"

# Run with Redis
docker run -p 8090:8090 postgrebase serve --dataDsn "postgres://..." --redisDsn "redis://host:6379/0"

On startup the server prints its endpoints:

├─ REST API: http://127.0.0.1:8090/api/
├─ MCP SSE:  http://127.0.0.1:8090/api/mcp/sse
└─ Admin UI: http://127.0.0.1:8090/_/

Configuration Flags

FlagDescriptionExample
--dataDsnDatabase connection stringsqlite://pb_data/data.db
--redisDsn(Optional) Redis connection string. Falls back to in-memory cache if omittedredis://localhost:6379/0
--dirData directory for file uploads, backups, etc../pb_data
--encryptionEnvEnvironment variable name for settings encryption keyPB_ENCRYPTION
--debugEnable debug mode with detailed logs(flag)

DSN Formats

EngineFormat
PostgreSQLpostgres://user:pass@host:port/db?sslmode=disable or postgresql://...
MySQLmysql://user:pass@tcp(host:port)/db
SQLitesqlite:///path/to/file.db, sqlite3://..., or simply ./file.db

MCP (Model Context Protocol)

PostgreBase includes a built-in MCP server that allows AI tools to interact with your data via a standardized JSON-RPC 2.0 protocol.

Transport Modes

SSE (Server-Sent Events) — HTTP

Available when running ./pb serve. Connect to:

GET  http://localhost:8090/api/mcp/sse      # SSE event stream
POST http://localhost:8090/api/mcp/message   # Send JSON-RPC requests
POST http://localhost:8090/api/mcp/stream    # Streamable HTTP (single request/response)

Stdio — CLI

Run the MCP server as a standalone process communicating over stdin/stdout:

bash
./pb mcp --dataDsn "sqlite://./dev.db" --mcp-token "YOUR_TOKEN"

# Or disable auth (NOT recommended for production)
./pb mcp --dataDsn "sqlite://./dev.db" --mcp-no-auth
FlagDescription
--mcp-tokenAdmin JWT token or MCP-specific token for authentication
--mcp-no-authDisable authentication (development only)

Claude Desktop Configuration

json
{
  "mcpServers": {
    "postgrebase": {
      "command": "/path/to/pb",
      "args": ["mcp", "--dataDsn", "sqlite:///path/to/dev.db", "--mcp-no-auth"]
    }
  }
}

MCP Tokens

For production use, create dedicated MCP tokens (prefixed with mcp_) from the Admin UI under Settings → MCP Tokens. These tokens:

  • Are separate from admin JWT tokens.
  • Can be revoked individually.
  • Support optional expiration dates.
  • Are shown in full only once at creation time.

Available Tools

ToolDescription
list_collectionsList all collections
get_collectionGet a collection's schema and settings
list_recordsList records with pagination, filtering, and sorting
get_recordGet a single record by ID
create_recordCreate a new record
update_recordUpdate an existing record
delete_recordDelete a record
search_recordsSearch records using PostgreBase filter expressions

Available Resources

URIDescription
postgrebase://collectionsAll collections with their schemas
postgrebase://settingsApplication settings (sanitized, no secrets)

Development

Building Admin UI

If you modify the Admin UI, rebuild the embedded assets before compiling the Go binary:

bash
cd ui
npm install
npm run build
cd ..
go build -o pb ./build/

Project Structure

postgrebase/
├── build/           # Main server entry point (main.go)
├── core/            # Application logic, DB connection, caching
├── daos/            # Data access objects (CRUD operations)
├── models/          # Data models and schema definitions
├── apis/            # HTTP API handlers (REST + MCP routes)
├── mcp/             # MCP server: protocol, tools, resources, transports
├── migrations/      # Database migrations (Postgres/MySQL/SQLite)
├── cmd/             # CLI commands (serve, mcp, admin)
├── dbx/             # Database query builder (fork of ozzo-dbx)
├── tools/           # Shared utilities (security, types, search, etc.)
├── ui/              # Admin UI (Svelte + Vite)
├── vendor/          # Go dependencies (preserved for offline builds)
└── postgrebase.go  # Root package: CLI setup, config, bootstrap

Running Tests

bash
go test ./tools/... ./models/... ./daos/...

Contributing

  1. Fork the repository.
  2. Create your feature branch (git checkout -b feature/amazing-feature).
  3. Commit your changes (git commit -m 'Add some amazing feature').
  4. Push to the branch (git push origin feature/amazing-feature).
  5. Open a Pull Request.

Credits

This project is a fork of PocketBase. Special thanks to Gani Georgiev for the original amazing work.

License

Licensed under the MIT license.

Installation

TypingMind
{
  "mcpServers": {
    "postgrebase": {
      "command": "./pb",
      "args": [
        "mcp",
        "--dataDsn",
        "sqlite://./dev.db",
        "--mcp-no-auth"
      ],
      "env": {
        "DATA_DSN": "<DATA_DSN>"
      }
    }
  }
}

Use PostgreBase MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once PostgreBase is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. You can run MCP locally on your device or connect to a remote MCP server URL.

Option 1: Use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add PostgreBase as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the PostgreBase MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "postgrebase": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the PostgreBase MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the PostgreBase MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use PostgreBase to help me with this task?
PostgreBase
Sure. I read it.
Here is what I found using PostgreBase.

Option 2: Add an MCP server URL

Use this when PostgreBase is already hosted remotely or your team wants one shared connector that multiple users can access.

1

Open MCP connectors

In TypingMind, go to Plugins, open MCP connectors, then choose Add URL.

  1. Open TypingMind in your browser.
  2. Go to Plugins.
  3. Open MCP connectors.
  4. Click Add URL.
TypingMind Add Custom MCP Server URL form
2

Paste the server URL

Enter the MCP server URL from the provider in the Server URL field. Add a connection name, description, icon, custom HTTP headers, or OAuth client settings if the server requires them.

  1. Paste the MCP server URL from the provider into the Server URL field.
  2. Enter a connection name for PostgreBase.
  3. Add a description and icon if you want it to be easier to identify.
  4. Add custom HTTP headers or OAuth client details if the server requires authentication.
3

Create the connection

Click Create connection, then return to the Plugins list and confirm the new MCP connection is active.

  1. Click Create connection.
  2. Return to the MCP connectors list.
  3. Confirm the PostgreBase connection appears as active.
  4. Refresh the plugin list if the connection does not appear immediately.
4

Switch models without reconnecting

Start a chat with your preferred model, enable the PostgreBase tools from Plugins, and switch to another model whenever needed. The MCP connection stays available to the TypingMind workspace.

  1. Start a new chat in TypingMind.
  2. Select the AI model you want to use.
  3. Enable the PostgreBase tools from Plugins.
  4. Ask the model to use the tool when needed.
  5. Switch to another AI model and reuse the same MCP connection.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use PostgreBase to help me with this task?
PostgreBase
Sure. I read it.
Here is what I found using PostgreBase.

Frequently asked questions

What is the PostgreBase MCP server used for?

PostgreBase is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use PostgreBase MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use PostgreBase with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use PostgreBase MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With PostgreBase connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect PostgreBase MCP to TypingMind?

PostgreBase can be connected in TypingMind with the local MCP connector or by adding a remote MCP server URL. Use the local connector when the server needs access to files, apps, or private resources on your device, and use a server URL when the MCP server is hosted remotely.

What tools does PostgreBase MCP provide in TypingMind?

PostgreBase exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use PostgreBase MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If PostgreBase requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇