Skip to content
DataZooDEPublic

About

API Framework heavily relying on the power of DuckDB and DuckDB extensions. Ready to build performant and cost-efficient APIs on top of BigQuery or Snowflake for AI Agents and Data Apps

Topics

Resources

Stars

75 stars

Watchers

3 watching

Forks

Latest commit

Β 

History

672 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

flAPI logo

flAPI

SQL β†’ REST APIs and MCP tools, from one config

License: BSL 1.1 DuckDB 2.0.1 Build PyPI flapi-io MCP 2026-07-28 Claude Code plugin

Write a SQL template and a few lines of YAML. flAPI serves the result as a REST endpoint and as an MCP tool for AI agents. Both use the same parameter validators and the same cache, and each has its own access control. It ships as one binary with DuckDB inside, so it reads Parquet, CSV, Postgres, BigQuery, S3 and 50+ more sources.

πŸ€– Using Claude Code? flAPI ships a Claude Code plugin with skills for scaffolding projects, writing endpoints and MCP tools, designing caches, and deploying and debugging flAPI. CI checks every example in the skills against the real binary.

Install with /plugin marketplace add DataZooDE/flapi, then /plugin install flapi@flapi.

flAPI demo: one SQL template served as a REST endpoint and an MCP tool

✨ Key Features

πŸ”Œ REST and MCP from one config

Guides: Building a REST endpoint Β· Creating MCP tools

  • One file, two protocols: url-path makes a REST endpoint, and mcp-tool makes the same SQL an MCP tool. mcp-resource and mcp-prompt complete the set
  • Current MCP (2026-07-28) and older clients on the same endpoint, with long-running tools (Tasks), typed results and OAuth discovery
  • Agent safety: roles per tool, dry runs, per-tool rate limits, and a scanner that flags prompt injection in tool descriptions
  • OpenAPI 3.0 document at /doc.yaml and a Swagger UI at /doc

πŸ—„οΈ Data sources

Guides: Connecting data sources Β· Reading from cloud storage

  • Everything DuckDB reads: Parquet, CSV, JSON, Iceberg, Delta, Postgres, MySQL, SQLite, BigQuery, SAP ERP and BW (via ERPL), and S3 / GCS / Azure / HTTP
  • Configs and templates can live in object storage: flapi -c s3://bucket/flapi.yaml (also gs://, az://, https://)

🧩 SQL templates and validation

Guide: Writing SQL templates

  • Mustache templates with params.*, conn.*, auth.* and whitelisted env.*
  • Typed parameters are bound as prepared statements: a {{ params.x }} (or {{{ }}} at a value site) on a typed field, outside a {{#…}} section, becomes a bound ?, so it cannot inject SQL. Inside a section, the validator is the defence
  • Validators for int, number, boolean, string (length, regex), email, uuid, enum, date and time. A bad request gets a 400 before any SQL runs
  • Writes (POST/PUT/PATCH/DELETE) with RETURNING rows and cache invalidation

⚑ Caching (DuckLake)

Guide: Caching an expensive query

  • Full refresh, append or merge, inferred from cursor / primary-key, on a schedule
  • Snapshots and time travel, retention and garbage collection, refresh on demand (flapii cache refresh), and prebuilt caches for serverless

πŸ” Security

Guide: Authentication and authorization

  • Auth: Basic, Bearer/JWT and OIDC, with roles per endpoint, PBKDF2 password hashes, users from AWS Secrets Manager, and {{env.X}} for every secret
  • Hardened by default where it matters: SQL templates of a remote config run with DuckDB external access restricted (duckdb-hardening), so they can't read other files, buckets or hosts
  • CORS allowlist, per-user rate limits, a JSONL audit log, direct TLS, and a config auditor that runs at startup

πŸ”­ Observability

Guide: Observability

  • OpenTelemetry tracing: one span per request with the query inside, joined to the calling agent's trace
  • request_id on every response and log line, runtime metrics, /health and /health/live
  • log-http-requests logs every HTTP request DuckDB makes (S3, GCS, HTTP), with userinfo and query strings redacted (a debugging switch)

πŸ“¦ Deployment

Guides: Shipping one self-contained binary Β· Serverless Β· Managing flAPI from the command line

  • One binary, with the DuckDB extensions it needs shipped next to it in extensions/
  • Self-packaging: flapi pack folds the config, templates and small data files, and optionally the extensions (--with-extensions), into the binary itself. Then scp is the whole deploy. Secrets stay out: pack refuses *.env, .env.*, secrets/*, *.pem and *.key. Builds are reproducible (SOURCE_DATE_EPOCH), and macOS builds can be notarised
  • Docker (ghcr.io/datazoode/flapi), scale-to-zero platforms (Cloud Run, App Runner, Container Apps, Knative) and PyPI (flapi-io)

πŸ“‹ Table of Contents

πŸ€– Claude Code plugin

The repository is also a Claude Code plugin marketplace:

/plugin marketplace add DataZooDE/flapi
/plugin install flapi@flapi
Phase Skills
Setup flapi-setup: install, project init, connections, env whitelist, validation
Develop flapi-rest, flapi-mcp, flapi-auth, flapi-testing, flapi-live-config
Caching flapi-cache-design: full / append / merge, deletes, write-through, replicas, prebuilt caches, time travel. flapi-cache-tuning: measuring and shortening refresh time
Deploy flapi-deploy: flapi pack, Docker, Cloud Run, offline extensions
Operate flapi-operate: health, runtime metrics, logs, tracing, troubleshooting

Slash commands: /flapi:init, /flapi:new-endpoint, /flapi:add-cache, /flapi:auth-setup, /flapi:deploy-check, /flapi:diagnose, /flapi:metrics.

The plugin also registers your running flAPI as an MCP server. It adds a hook that validates and hot-reloads the config after each edit. See Using flAPI with Claude Code. To try local changes, run claude --plugin-dir ./plugins/flapi.

πŸ“₯ Installation

PyPI (both commands, no Docker)

uvx --from flapi-io flapi --version     # run without installing
pip install flapi-io                     # or install: provides `flapi` (server) and `flapii` (CLI)

The package is flapi-io because "flapi" was taken on PyPI. It carries both the flapi server and the flapii CLI.

Release binaries

GitHub Releases has archives for Linux (amd64, arm64), macOS (arm64) and Windows (amd64). Each archive holds the flapi binary and an extensions/ directory with the DuckDB extensions it loads by default. Keep the two together.

Docker

docker pull ghcr.io/datazoode/flapi:latest
docker run --rm -p 8080:8080 -v "$PWD/demo:/config" ghcr.io/datazoode/flapi -c /config/flapi.yaml

This serves the demo/ project from the Quick Start below. Mount any directory that holds a flapi.yaml.

:latest and :v<version> come from releases; :main and :sha-<commit> come from main. The image carries the default extensions. The -runtime variant (for example :v26.11.25-runtime or :main-runtime) also carries bigquery. One port (8080) serves both REST and MCP (/mcp/jsonrpc).

πŸš€ Quick Start

You need uv and network access: the PyPI package downloads its DuckDB extensions on first start. CI runs these blocks against every build (with the freshly built binaries in place of uvx).

1. Create a project. This scaffolds demo/: a config, a sample CSV, and a /sample endpoint with an id filter.

uvx --from flapi-io flapii project init demo

2. Make the endpoint an MCP tool too. It's the same file and the same SQL; add three lines:

cat >> demo/sqls/sample.yaml <<'EOF'
mcp-tool:
  name: get_sample
  description: Look up sample products, optionally by id
EOF

3. Start the server. It runs in the foreground on port 8080; stop it with Ctrl+C. It prints a security warning that MCP has no auth yet, which is expected for a local demo; see Authentication.

uvx --from flapi-io flapi -c demo/flapi.yaml

4. Call it, in a second terminal: once over REST, once as an agent would over MCP.

curl -s 'http://localhost:8080/sample?id=2'
# {"data":[{"id":2,"name":"Gadget","category":"tools","price":19.5}],"next":"","total_count":1}
curl -s http://localhost:8080/mcp/jsonrpc -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_sample","arguments":{"id":"2"}}}'
# {"jsonrpc":"2.0","id":1,"result":{"content":[...],"structuredContent":{"rows":[{"id":2,"name":"Gadget",...}],"row_count":1}}}

The Swagger UI is at http://localhost:8080/doc. To connect Claude Code to the tool, run claude mcp add --transport http flapi http://localhost:8080/mcp/jsonrpc.

Next: Getting started walks through your own data, parameters and validation.

🧭 One config, two protocols

One endpoint file serves GET /customers and the MCP tool get_customers. REST and MCP are protected separately: the endpoint's auth: guards REST, and the top-level mcp.auth with the tool's allowed-roles guards tools/call.

# sqls/customers.yaml
url-path: /customers
mcp-tool:
  name: get_customers
  description: Retrieve customers, optionally by id
  allowed-roles: [reader]          # who may call the tool (with mcp.auth enabled)

request:
  - field-name: id
    field-in: query
    required: false
    validators:
      - type: int
        min: 1

template-source: customers.sql
connection: [customers-parquet]

auth:                              # REST only
  enabled: true
  type: basic
  users:
    - username: reader
      password: '{{env.READER_PASSWORD}}'   # never a literal password; the variable may hold a
                                            # $pbkdf2-sha256$ hash, and must match template.environment-whitelist
      roles: [reader]
-- sqls/customers.sql
SELECT * FROM read_parquet('{{{ conn.path }}}')
WHERE 1=1
{{#params.id}}
  AND customer_id = {{ params.id }}
{{/params.id}}

GET endpoints are paginated by default (?limit= / ?offset=, 100 rows per page), so the template has no LIMIT. MCP is on by default on the same port (mcp: {enabled: false} turns it off; GET /mcp/health reports its state). Files can also define an mcp-resource or mcp-prompt alone. For the mcp.auth block, see Creating MCP tools.

πŸ“š Documentation

Start at the documentation index. It routes you from what you're trying to do to the right page.

I want to… Guide
Serve my first endpoint Getting started
Add validation, filters, pagination Building a REST endpoint
Write templates that are safe and fast Writing SQL templates
Connect Postgres, SQLite, BigQuery, Snowflake, files … Connecting data sources
Let an AI agent call it Creating MCP tools for AI agents
Make a slow query fast Caching an expensive query
Require a login, restrict by role, filter rows per caller Authentication and authorization
Read from S3, GCS or Azure Reading from cloud storage
Stop copy-pasting config blocks Reusing config and reading the environment
Deploy one self-contained binary Shipping one self-contained binary
Run on Cloud Run and other scale-to-zero platforms Serverless
Debug a failed request, probe health, trace, audit Observability
Manage a running server from the shell or CI Managing flAPI from the command line
Let Claude Code build and run it with me Using flAPI with Claude Code
Reference Covers
Configuration every flapi.yaml and endpoint key
CLI server flags and subcommands (pack, cache, extensions, …)
MCP the MCP protocol as flAPI implements it
Config Service API runtime configuration over REST, used by flapii
Architecture & design how it works inside, and why
Changelog what changed in each release, with upgrade notes

MCP Registry

flAPI is listed in the official MCP Registry under the name below (this line also serves as the registry's PyPI ownership marker):

mcp-name: io.github.datazoode/flapi

🏭 Building from source

flAPI is C++20 and builds much like DuckDB. The CI workflow build.yaml and its build images (.github/docker/) are the reference for every platform.

On Linux, you need:

  • A C++20 compiler, CMake, Ninja, git, curl, zip/unzip, pkg-config, autoconf and the OpenSSL headers. On Ubuntu: sudo apt-get install -y build-essential cmake ninja-build git curl zip unzip pkg-config autoconf libssl-dev
  • vcpkg, bootstrapped, with VCPKG_ROOT pointing at it. The build does not install vcpkg for you.
git clone --recurse-submodules https://github.com/DataZooDE/flapi.git
cd flapi
make release            # build/release/flapi
make test               # C++ unit tests

DuckDB v2.0.1 is a git submodule. vcpkg provides crow, argparse, jwt-cpp, fmt, libarchive, curl, zstd, lz4, catch2, aws-sdk-cpp and opentelemetry-cpp; crow and opentelemetry-cpp use the overlay ports in ports/. yaml-cpp comes in through CMake. The Makefile lists the integration-test targets.

πŸ“Š Telemetry

flAPI sends anonymous, aggregate usage events: server_started at boot, $exception on a failed request, and at most once a minute per route and status a count with durations (REST, MCP tool and auth outcomes). It sends route templates, never filled request paths, query data, SQL, credentials or personal information. TELEMETRY.md lists every property.

Opt out (any one is enough):

flapi --no-telemetry -c flapi.yaml   # CLI flag
export DATAZOO_DISABLE_TELEMETRY=1   # or FLAPI_NO_TELEMETRY=1
telemetry:          # flapi.yaml
  enabled: false

πŸ“„ License

Business Source License 1.1 (BSL 1.1)

βœ… Free for production use: use it inside your business βœ… Free to copy, modify and build on βœ… Free for development and research

❌ Not offered to third parties on a hosted or embedded basis without a commercial license ❌ No rights to the flAPI or DataZoo trademarks

πŸ”„ Converts to MPL 2.0 on each version's Change Date (see LICENSE)

For a commercial license (embedding flAPI in a product, or offering it as a hosted service), contact [email protected]. The LICENSE file has the full terms. Licensor: DataZoo GmbH.

🀝 Contributing

We welcome contributions. Open an issue to discuss a change, or send a pull request. CLAUDE.md describes the code layout, conventions and test targets.

πŸ“ž Support

πŸŽ“ Citation

@software{flapi,
  title  = {flAPI: SQL to REST APIs and MCP tools},
  author = {Joachim Rosskopf and DataZoo GmbH},
  year   = {2026},
  url    = {https://github.com/DataZooDE/flapi}
}

πŸ† Acknowledgments

Built on DuckDB, DuckLake, Crow, yaml-cpp, jwt-cpp, OpenTelemetry C++ and the Model Context Protocol.


Feedback

If flAPI misbehaves (an endpoint that won't serve, a cache that won't invalidate, an auth flow that won't complete), please open an issue. Deployments differ in ways we can't reproduce here, so a report with your config is the fastest way to a fix. A failed request answers 500 with a request_id. The details are in the server log under that id, so quote the matching log lines in the report.

If it saved you time, a star on the repo helps other people find it.

On an interactive start, a small banner says the same thing once a day. Under a container or systemd there is no terminal, so it never prints; the startup log line carries the pointer instead. Silence both with DATAZOO_NO_BANNER=1.

About

API Framework heavily relying on the power of DuckDB and DuckDB extensions. Ready to build performant and cost-efficient APIs on top of BigQuery or Snowflake for AI Agents and Data Apps

Topics

Resources

Stars

75 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages