# FMF SQL Check > Check SQL before you run it: syntax validation with the real PostgreSQL 18 parser and the real SQLite engine (MySQL / MariaDB via node-sql-parser, measured against real MySQL 8.4 and MariaDB 11.8 servers), with the exact error position; 18 lint rules that catch real bugs (UPDATE/DELETE without WHERE, = NULL, NOT IN with NULLs, LIMIT without ORDER BY, comma joins, injection tautologies, non-sargable filters, destructive DDL); and a formatter for 19 dialects that refuses to return output unless it provably means the same query (same PostgreSQL parse tree, same tokens). The SQL is never executed. ## Docs (free) - Human docs with copy-paste examples: https://sql-check.fmf-x402.workers.dev/docs - OpenAPI 3.1: https://sql-check.fmf-x402.workers.dev/openapi.json - This file: https://sql-check.fmf-x402.workers.dev/llms.txt - MCP server (Streamable HTTP): https://sql-check.fmf-x402.workers.dev/mcp - Health: https://sql-check.fmf-x402.workers.dev/health - Attribution counters (no PII): https://sql-check.fmf-x402.workers.dev/stats/refs ## How to pay No account and no API key. Unpaid calls receive HTTP 402 with an MPP challenge on Tempo (USDC.e or pathUSD). Official clients pay the challenge and retry automatically. A short funding guide is at https://tools.fmf-x402.workers.dev/funds. POST JSON (or GET with query params) to any paid route and pay the MPP 402 challenge on Tempo (USDC.e or pathUSD). Invalid input (including malformed JSON) is a free 400. An upstream failure returns 402 with an error, or 429/503 with Retry-After, and you are not charged. Optional ?ref=channel or header X-FMF-Ref attributes the call for our coverage map (ignored by the tool). ## Quick start mppx CLI (creates/uses a Tempo account in your keychain): ```bash npx mppx https://sql-check.fmf-x402.workers.dev/v1/sql/validate -X POST -H 'content-type: application/json' -d '{"sql":"SELECT id FROM users WHERE email = 'a@b.co' LIMIT 1","dialect":"postgresql"}' ``` TypeScript (mppx). After Mppx.create(), global fetch handles 402: ```ts import { Mppx, tempo } from 'mppx/client' import { privateKeyToAccount } from 'viem/accounts' Mppx.create({ methods: [tempo({ account: privateKeyToAccount(process.env.TEMPO_PRIVATE_KEY) })], }) // Global fetch now pays the 402 automatically. const res = await fetch('https://sql-check.fmf-x402.workers.dev/v1/sql/validate', { method: 'POST', headers: { 'content-type': 'application/json', }, body: JSON.stringify({"sql":"SELECT id FROM users WHERE email = 'a@b.co' LIMIT 1","dialect":"postgresql"}), }) console.log(await res.json()) ``` Python (pympp): ```python # pip install pympp # Docs: https://mpp.dev/sdk/python import asyncio from mpp.client import Mpp from mpp.methods.tempo import TempoAccount from mpp.methods.tempo import client as tempo account = TempoAccount.from_key("0x...") async def main(): async with Mpp(methods=[tempo.charge(account=account)]) as mpp: response = await mpp.fetch("https://sql-check.fmf-x402.workers.dev/v1/sql/validate", method="POST", json={"sql":"SELECT id FROM users WHERE email = 'a@b.co' LIMIT 1","dialect":"postgresql"}) print(await response.json()) asyncio.run(main()) ``` An unpaid curl shows the 402 (you are not charged): ```bash curl -i -X POST https://sql-check.fmf-x402.workers.dev/v1/sql/validate -H 'content-type: application/json' -d '{"sql":"SELECT id FROM users WHERE email = 'a@b.co' LIMIT 1","dialect":"postgresql"}' ``` ## MCP Add this to Cursor / Claude Desktop / VS Code MCP settings (Streamable HTTP): ```json { "mcpServers": { "fmf-mpp-sql-check": { "url": "https://sql-check.fmf-x402.workers.dev/mcp" } } } ``` `tools/list` is free. `tools/call` requires an MPP Payment credential in the Authorization header (or just call the HTTP route with mppx). The wrapper does not settle payment on its own and stores nothing. ## Routes - POST https://sql-check.fmf-x402.workers.dev/v1/sql/validate ($0.001) Validate SQL syntax (real PostgreSQL / SQLite parsers): Is this SQL syntactically valid? PostgreSQL is checked by the PostgreSQL 18 parser itself (libpg_query) and SQLite by the SQLite engine, so the answer matches the database; MySQL and MariaDB use node-sql-parser (agreement with real MySQL 8.4 / MariaDB 11.8 servers is published). Returns valid, statement count and types, or the error message with position, line, column and the text near it. Unknown tables or columns are not syntax errors. The SQL is never executed. Example: `npx mppx https://sql-check.fmf-x402.workers.dev/v1/sql/validate -X POST -H 'content-type: application/json' -d '{"sql":"SELECT id FROM users WHERE email = 'a@b.co' LIMIT 1","dialect":"postgresql"}'` - POST https://sql-check.fmf-x402.workers.dev/v1/sql/lint ($0.002) Lint SQL for bugs, safety and performance: Find real problems before a query runs: UPDATE / DELETE without WHERE, = NULL comparisons, NOT IN (subquery) NULL trap, LIMIT without ORDER BY, comma (cartesian) joins, INSERT without a column list, always-true injection signatures (OR 1=1), stacked statements, destructive DDL, non-sargable filters (LOWER(col) = ...), leading-wildcard LIKE, large OFFSET, ORDER BY ordinals, UNION vs UNION ALL, SELECT *, COUNT(col). Each finding has rule, severity, line, column, snippet and a fix. Includes the syntax check. The SQL is never executed. Example: `npx mppx https://sql-check.fmf-x402.workers.dev/v1/sql/lint -X POST -H 'content-type: application/json' -d '{"sql":"UPDATE accounts SET balance = 0","dialect":"mysql","min_severity":"warning"}'` - POST https://sql-check.fmf-x402.workers.dev/v1/sql/format ($0.001) Format SQL (verified to mean the same query): Pretty-print SQL for 19 dialects (postgresql, mysql, sqlite, bigquery, snowflake, transactsql, redshift, trino, spark, duckdb, ...): keyword case, indent, tabular styles, expression width. Before returning, every output is checked: same token sequence as the input (comments kept), and for PostgreSQL the same parse tree from the real PostgreSQL parser. If a check fails the output is refused and you are not charged. Example: `npx mppx https://sql-check.fmf-x402.workers.dev/v1/sql/format -X POST -H 'content-type: application/json' -d '{"sql":"select a,b from t where x=1","dialect":"mysql","keyword_case":"upper","indent":4}'` ## Sources and licences Engines bundled in the worker: libpg_query (PostgreSQL 18 parser, BSD/PostgreSQL licence via libpg-query, MIT), SQLite via sql.js (public domain / MIT), node-sql-parser (Apache-2.0), sql-formatter (MIT). No database access; your SQL is never executed or stored. Operated by FMF Tools (fmf-tools@agentmail.to). Pay per call; invalid input returns 402 and is not charged. ## Sister services - [Doc Tools](https://mpp-docs.fmf-x402.workers.dev/docs?ref=cross-sql-check): Pay-per-call PDF, Office, OCR, speech-to-text, voice memo and meeting notes - [Web & Data](https://mpp-agent-data.fmf-x402.workers.dev/docs?ref=cross-sql-check): Pay-per-call scrape, extract, SEC filings, weather and FX - [Utility Tools](https://mpp-tools.fmf-x402.workers.dev/docs?ref=cross-sql-check): Tempo chain, attestation, QR, DNS, email, IP, geo, timezone, tech detect, math - [AI Tools](https://mpp-ai.fmf-x402.workers.dev/docs?ref=cross-sql-check): Pay-per-call chat, translation, embeddings and rerank, no API key - [Browser](https://mpp-browser.fmf-x402.workers.dev/docs?ref=cross-sql-check): Pay-per-call headless Chrome screenshots, JS render and page-to-PDF - [Research](https://mpp-research.fmf-x402.workers.dev/docs?ref=cross-sql-check): Papers, FDA drug labels, recalls, clinical trials and LEI - [EVM Decoder](https://mpp-chain.fmf-x402.workers.dev/docs?ref=cross-sql-check): Pay-per-call calldata and event-log decoder, selectors, verified ABIs, no RPC - [Deepgram-compatible STT](https://mpp-stt.fmf-x402.workers.dev/docs?ref=cross-sql-check): Drop-in /deepgram/transcribe and /v1/listen speech-to-text at $0.008, no API key - [Compat APIs](https://mpp-compat.fmf-x402.workers.dev/docs?ref=cross-sql-check): OpenWeather-, Mapbox- and EDGAR-compatible routes at a third of the price (MPP + x402) - [Domain & Web Checks](https://mpp-domain.fmf-x402.workers.dev/docs?ref=cross-sql-check): RDAP WHOIS, domain age and availability, HTTP status, security headers, SPF/DMARC (MPP + x402) - [Dev & Data Utils](https://mpp-utils.fmf-x402.workers.dev/docs?ref=cross-sql-check): IBAN, GTIN, ISIN, crypto address, JWT, hash, cron, RRULE, semver, CSV at $0.001 (MPP + x402) - [MTG Sim](https://mtg-sim.fmf-x402.workers.dev/docs?ref=cross-sql-check): Magic: The Gathering deck check, draw odds, land count and goldfish simulator - [Control-plane](https://controlplane-x402.fmf-x402.workers.dev/docs?ref=cross-sql-check): Who controls this contract? MPP + x402 snapshots and Tempo token data - [Pokémon TCG Sim](https://pokemon-tcg-sim.fmf-x402.workers.dev/docs?ref=cross-sql-check): Pokémon TCG simulator: goldfish, prize and draw sims, free Standard/Expanded deck check - [Yu-Gi-Oh Sim](https://yugioh-sim.fmf-x402.workers.dev/docs?ref=cross-sql-check): Yu-Gi-Oh! simulator: goldfish, combo and hand-trap odds, free TCG/OCG/GOAT banlist deck check - [Crypto Tax Calculator](https://mpp-cryptotax.fmf-x402.workers.dev/docs?ref=cross-sql-check): Crypto capital gains, cost basis (FIFO/HIFO/ACB), Form 8949 boxes G-L, Canada Schedule 3, tax-loss harvesting - [Business Docs & Data](https://mpp-biz.fmf-x402.workers.dev/docs?ref=cross-sql-check): Invoice/receipt PDFs with pay-in-crypto QR, payment URIs, phone validation, barcodes - [Lorcana Sim](https://lorcana-sim.fmf-x402.workers.dev/docs?ref=cross-sql-check): Disney Lorcana simulator: goldfish, ink and draw sims, free Core/Infinity deck check - [One Piece Sim](https://onepiece-sim.fmf-x402.workers.dev/docs?ref=cross-sql-check): One Piece Card Game simulator: goldfish, DON!! curve, Life and draw odds, free deck check - [Hearthstone Sim](https://hearthstone-sim.fmf-x402.workers.dev/docs?ref=cross-sql-check): Hearthstone simulator: mulligan odds, curve goldfish, draw odds, free deck check - [Chess Sim](https://chess-sim.fmf-x402.workers.dev/docs?ref=cross-sql-check): Chess tools: forced-mate finder, best move, legal moves, free opening names and position check - [Dota 2 Sim](https://dota2-sim.fmf-x402.workers.dev/docs?ref=cross-sql-check): Dota 2 simulator: right-click duel sim, build stats, EHP and DPS calculator - [CS2 Sim](https://cs2-sim.fmf-x402.workers.dev/docs?ref=cross-sql-check): CS2 economy simulator: loss bonus, buy or eco, half simulation ## Attribution Append `?ref=your-channel` or send header `X-FMF-Ref: your-channel` on any request (including unpaid 402s and /docs). We count hits and paid successes per channel so we can see what actually drives calls. The parameter is ignored by the tool. ## Related - Related: FMF Recipes — which paid API to call for any agent task. https://agent-recipes.fmf-x402.workers.dev/mpp/recipes/find ($0.003, empty call works) · MCP https://agent-recipes.fmf-x402.workers.dev/mcp · https://agent-recipes.fmf-x402.workers.dev/llms.txt - Also: FMF Tools Etsy Movers — today's top 20 Etsy shops by sales acceleration. https://etsy-movers.fmf-x402.workers.dev/etsy/movers/today ($0.01, no input) · MCP https://etsy-movers.fmf-x402.workers.dev/mcp · https://etsy-movers.fmf-x402.workers.dev/llms.txt ## Pay without a wallet (prepaid credits, free trial) - Free trial: add header X-FMF-Trial: 1 to any paid route (one free call per network, IPv4 address or IPv6 /64, for life). - API key: POST https://fmf-credits.fmf-x402.workers.dev/keys (free, includes trial calls), then send X-API-Key: fmf_... ; each call debits its listed price; failed calls are refunded. - Top up credits with x402/MPP USDC (https://fmf-credits.fmf-x402.workers.dev/mpp/credits/topup-5) or card via Stripe Checkout (https://fmf-credits.fmf-x402.workers.dev/pricing). - Prices: https://sql-check.fmf-x402.workers.dev/pricing. The per-call x402/MPP 402 flow is unchanged.