Skip to main content

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 contact@data-zoo.de. 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.

Metadata

Release files for flapi-io 26.11.26

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for flapi-io 26.11.26
File Actions
flapi_io-26.11.26-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for flapi_io-26.11.26-py3-none-win_amd64.whl
flapi_io-26.11.26-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for flapi_io-26.11.26-py3-none-manylinux_2_17_x86_64.whl
flapi_io-26.11.26-py3-none-manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for flapi_io-26.11.26-py3-none-manylinux_2_17_aarch64.whl
flapi_io-26.11.26-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for flapi_io-26.11.26-py3-none-macosx_11_0_arm64.whl

Total release size: 314.0 MB

Release files / flapi_io-26.11.26-py3-none-win_amd64.whl

Download URL flapi_io-26.11.26-py3-none-win_amd64.whl
Size 76.4 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
000842ad7acc555ea014b847f9c09cff99659a67e92ac3a5afd2c51a2942b30d
BLAKE2b-256 checksum
How to use checksums
7416811fbaa4e70a084b171ea1ea8e8e5a684edfa1885c5d2820389dd3610ecb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / flapi_io-26.11.26-py3-none-manylinux_2_17_x86_64.whl

Download URL flapi_io-26.11.26-py3-none-manylinux_2_17_x86_64.whl
Size 86.7 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
831bd71c911bff55c8c7cec43a6c03957e25eb917f9cbbf8f3e571d1d395fb77
BLAKE2b-256 checksum
How to use checksums
174d278534b756b37dc8c20317a5601903a6e57ca53fe5f93853508ba5486370
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / flapi_io-26.11.26-py3-none-manylinux_2_17_aarch64.whl

Download URL flapi_io-26.11.26-py3-none-manylinux_2_17_aarch64.whl
Size 84.2 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
b1ec71d64de95ee8b4f0c4bdf621f6ffa2fa2d6473a14ffd0ffa3bd50fc8290c
BLAKE2b-256 checksum
How to use checksums
76c6099040278b949f468e4efc130b875f9c19f6545c221f39ff47132a358153
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / flapi_io-26.11.26-py3-none-macosx_11_0_arm64.whl

Download URL flapi_io-26.11.26-py3-none-macosx_11_0_arm64.whl
Size 66.6 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
670b230411179c31844f76c4e61f5b6c98afaf0423d41f483786ffa03374a31e
BLAKE2b-256 checksum
How to use checksums
3f1d4bd2989238adbeacf84c65425ea7013ca0ef3854d268e53654740748ec78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for flapi-io 26.11.26

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for flapi_io-26.11.26-py3-none-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

26.11.26 This release

4 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page