Skip to content
Back to search

postgrebase

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.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/zhenruyan--postgrebase/badge.svg)](/listings/zhenruyan--postgrebase)

HTML

<a href="/listings/zhenruyan--postgrebase"><img src="/api/listings/zhenruyan--postgrebase/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Prerequisites

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

Build

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

For static builds (no CGO):

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

Run

SQLite (Local Development)

# 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)

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

MySQL

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

With Redis Cache

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

Docker

# 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/_/

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 243 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # PostgreBase — AI原生的无代码API开发工具
  2. PostgreBase 是 AI 原生的无代码 API 开发平台,基于 [PocketBase](https://pocketbase.io) 重构。内置 MCP (Model Context Protocol) 服务器,让 AI 工具(Claude、Cursor、Windsurf)直接操作你的数据。支持 PostgreSQL、MySQL、SQLite 三种数据库,提供即时 REST API + 实时订阅 + Admin UI,5分钟上线你的后端服务。
  3. ## Features
  4. - **Three Database Engines:**
  5. - **PostgreSQL** (default) — production-grade concurrency, clustering, and complex queries.
  6. - **MySQL** — fully compatible via the `mysql://` DSN prefix.
  7. - **SQLite** (pure Go, no CGO) — zero-dependency local development and testing via `sqlite://` DSN or `.db` file path.
  8. - **Cluster-Ready Architecture:** No reliance on local database files means multiple instances can run behind a load balancer with a shared PostgreSQL/MySQL backend.
  9. - **Hybrid Caching:**
  10. - **Redis Cache** (`--redisDsn`) — distributed caching for cluster environments; SSE Realtime subscriptions synchronize across nodes via Redis Pub/Sub.
  11. - **In-Memory Cache** — automatic fallback to high-performance local memory caching when Redis is not configured.
  12. - **MCP (Model Context Protocol) Server:**
  13. - JSON-RPC 2.0 protocol enabling AI tools (Claude Desktop, Cursor, Windsurf) to interact with your data.
  14. - 8 built-in tools: `list_collections`, `get_collection`, `list_records`, `get_record`, `create_record`, `update_record`, `delete_record`, `search_records`.
  15. - Resources: `postgrebase://collections`, `postgrebase://settings`.
  16. - Three transport modes: SSE (HTTP), Streamable HTTP, and Stdio.
  17. - MCP-specific API tokens with expiration support, manageable from the Admin UI.
  18. - **Zero External Dependencies for SQLite:** Uses `modernc.org/sqlite` (pure Go transpilation of SQLite), builds with `CGO_ENABLED=0`.
  19. ## Quick Start
  20. ### Prerequisites
  21. - Go 1.26.2+
  22. - PostgreSQL, MySQL, or nothing (SQLite works out of the box)
  23. ### Build
  24. ```bash
  25. git clone https://github.com/zhenruyan/postgrebase.git
  26. cd postgrebase
  27. go build -o pb ./build/
  28. ```
  29. For static builds (no CGO):
  30. ```bash
  31. CGO_ENABLED=0 go build -o pb ./build/
  32. ```
  33. ### Run
  34. #### SQLite (Local Development)
  35. ```bash
  36. # Using sqlite:// prefix
  37. ./pb serve --dataDsn "sqlite://./pb_data/dev.db"
  38. # Or just pass a .db file path
  39. ./pb serve --dataDsn "./pb_data/dev.db"
  40. ```
  41. #### PostgreSQL (Recommended for Production)
  42. ```bash
  43. ./pb serve --dataDsn "postgresql://user:password@127.0.0.1:5432/dbname?sslmode=disable"
  44. ```
  45. #### MySQL
  46. ```bash
  47. ./pb serve --dataDsn "mysql://user:password@tcp(127.0.0.1:3306)/dbname"
  48. ```
  49. #### With Redis Cache
  50. ```bash
  51. ./pb serve --dataDsn "postgres://..." --redisDsn "redis://127.0.0.1:6379/0"
  52. ```
  53. #### Docker
  54. ```bash
  55. # Build the image
  56. docker build -t postgrebase .
  57. # Run with SQLite
  58. docker run -p 8090:8090 -v pb_data:/pb/pb_data postgrebase serve --dataDsn "sqlite:///pb/pb_data/dev.db"
  59. # Run with PostgreSQL
  60. docker run -p 8090:8090 postgrebase serve --dataDsn "postgres://user:pass@host:5432/db?sslmode=disable"
  61. # Run with Redis
  62. docker run -p 8090:8090 postgrebase serve --dataDsn "postgres://..." --redisDsn "redis://host:6379/0"
  63. ```
  64. On startup the server prints its endpoints:
  65. ```
  66. ├─ REST API: http://127.0.0.1:8090/api/
  67. ├─ MCP SSE: http://127.0.0.1:8090/api/mcp/sse
  68. └─ Admin UI: http://127.0.0.1:8090/_/
  69. ```
  70. ## Configuration Flags
  71. | Flag | Description | Example |
  72. |------|-------------|---------|
  73. | `--dataDsn` | Database connection string | `sqlite://pb_data/data.db` |
  74. | `--redisDsn` | (Optional) Redis connection string. Falls back to in-memory cache if omitted | `redis://localhost:6379/0` |
  75. | `--dir` | Data directory for file uploads, backups, etc. | `./pb_data` |
  76. | `--encryptionEnv` | Environment variable name for settings encryption key | `PB_ENCRYPTION` |
  77. | `--debug` | Enable debug mode with detailed logs | _(flag)_ |
  78. ### DSN Formats
  79. | Engine | Format |
  80. |--------|--------|
  81. | PostgreSQL | `postgres://user:pass@host:port/db?sslmode=disable` or `postgresql://...` |
  82. | MySQL | `mysql://user:pass@tcp(host:port)/db` |
  83. | SQLite | `sqlite:///path/to/file.db`, `sqlite3://...`, or simply `./file.db` |
  84. ## MCP (Model Context Protocol)
  85. PostgreBase includes a built-in MCP server that allows AI tools to interact with your data via a standardized JSON-RPC 2.0 protocol.
  86. ### Transport Modes
  87. #### SSE (Server-Sent Events) — HTTP
  88. Available when running `./pb serve`. Connect to:
  89. ```
  90. GET http://localhost:8090/api/mcp/sse # SSE event stream
  91. POST http://localhost:8090/api/mcp/message # Send JSON-RPC requests
  92. POST http://localhost:8090/api/mcp/stream # Streamable HTTP (single request/response)
  93. ```
  94. #### Stdio — CLI
  95. Run the MCP server as a standalone process communicating over stdin/stdout:
  96. ```bash
  97. ./pb mcp --dataDsn "sqlite://./dev.db" --mcp-token "YOUR_TOKEN"
  98. # Or disable auth (NOT recommended for production)
  99. ./pb mcp --dataDsn "sqlite://./dev.db" --mcp-no-auth
  100. ```
  101. | Flag | Description |
  102. |------|-------------|
  103. | `--mcp-token` | Admin JWT token or MCP-specific token for authentication |
  104. | `--mcp-no-auth` | Disable authentication (development only) |
  105. ### Claude Desktop Configuration
  106. ```json
  107. {
  108. "mcpServers": {
  109. "postgrebase": {
  110. "command": "/path/to/pb",
  111. "args": ["mcp", "--dataDsn", "sqlite:///path/to/dev.db", "--mcp-no-auth"]
  112. }
  113. }
  114. }
  115. ```
  116. ### MCP Tokens
  117. For production use, create dedicated MCP tokens (prefixed with `mcp_`) from the Admin UI under **Settings → MCP Tokens**. These tokens:
  118. - Are separate from admin JWT tokens.
  119. - Can be revoked individually.
  120. - Support optional expiration dates.
  121. - Are shown in full only once at creation time.
  122. ### Available Tools
  123. | Tool | Description |
  124. |------|-------------|
  125. | `list_collections` | List all collections |
  126. | `get_collection` | Get a collection's schema and settings |
  127. | `list_records` | List records with pagination, filtering, and sorting |
  128. | `get_record` | Get a single record by ID |
  129. | `create_record` | Create a new record |
  130. | `update_record` | Update an existing record |
  131. | `delete_record` | Delete a record |
  132. | `search_records` | Search records using PostgreBase filter expressions |
  133. ### Available Resources
  134. | URI | Description |
  135. |-----|-------------|
  136. | `postgrebase://collections` | All collections with their schemas |
  137. | `postgrebase://settings` | Application settings (sanitized, no secrets) |
  138. ## Development
  139. ### Building Admin UI
  140. If you modify the Admin UI, rebuild the embedded assets before compiling the Go binary:
  141. ```bash
  142. cd ui
  143. npm install
  144. npm run build
  145. cd ..
  146. go build -o pb ./build/
  147. ```
  148. ### Project Structure
  149. ```
  150. postgrebase/
  151. ├── build/ # Main server entry point (main.go)
  152. ├── core/ # Application logic, DB connection, caching
  153. ├── daos/ # Data access objects (CRUD operations)
  154. ├── models/ # Data models and schema definitions
  155. ├── apis/ # HTTP API handlers (REST + MCP routes)
  156. ├── mcp/ # MCP server: protocol, tools, resources, transports
  157. ├── migrations/ # Database migrations (Postgres/MySQL/SQLite)
  158. ├── cmd/ # CLI commands (serve, mcp, admin)
  159. ├── dbx/ # Database query builder (fork of ozzo-dbx)
  160. ├── tools/ # Shared utilities (security, types, search, etc.)
  161. ├── ui/ # Admin UI (Svelte + Vite)
  162. ├── vendor/ # Go dependencies (preserved for offline builds)
  163. └── postgrebase.go # Root package: CLI setup, config, bootstrap
  164. ```
  165. ### Running Tests
  166. ```bash
  167. go test ./tools/... ./models/... ./daos/...
  168. ```
  169. ### Contributing
  170. 1. Fork the repository.
  171. 2. Create your feature branch (`git checkout -b feature/amazing-feature`).
  172. 3. Commit your changes (`git commit -m 'Add some amazing feature'`).
  173. 4. Push to the branch (`git push origin feature/amazing-feature`).
  174. 5. Open a Pull Request.
  175. ## Credits
  176. This project is a fork of [PocketBase](https://pocketbase.io). Special thanks to [Gani Georgiev](https://github.com/ganigeorgiev) for the original amazing work.
  177. ## License
  178. Licensed under the [MIT license](https://opensource.org/licenses/MIT).

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.