
QueryWeaver
com.falkordb由 falkordb.com 发布v0.0.11更新于 Oct 24, 2026
An MCP server for Text2SQL: transforms natural language into SQL using graph schema understanding.
概览
QueryWeaver 是一个开源 Text2SQL 服务器,借助图结构理解数据库模式,把自然语言问题转换为 SQL 并在 PostgreSQL 或 MySQL 上执行。
- 可以做什么
- 列出并连接数据库,将数据库模式加载为图
- 查看数据库模式,包括表、字段与外键关系
- 用自然语言提问,返回生成的 SQL 与查询结果
- 进行多轮对话式查询,可附加自定义指令与单次请求的模型覆盖
- 对 INSERT、UPDATE、DELETE 等破坏性 SQL 先请求确认,确认后再执行
- 适用场景
- 适合希望用自然语言向 PostgreSQL 或 MySQL 数据库提问、而不必手写 SQL 的场景,也适合先了解陌生数据库结构再起草查询。
- 运行要求
- 以本地 Docker 容器(镜像 falkordb/queryweaver)运行并在 /mcp 暴露 HTTP MCP 接口,或以 Python 3.12+ 包运行。需要 FalkorDB 实例、LLM 服务商 API 密钥(OPENAI_API_KEY、GEMINI_API_KEY、ANTHROPIC_API_KEY、COHERE_API_KEY 或 AZURE_API_KEY,或本地 Ollama 模型)、FASTAPI_SECRET_KEY,以及目标 PostgreSQL 或 MySQL 数据库。使用 Anthropic 时还需 VOYAGE_API_KEY 或 EMBEDDING_MODEL 提供向量。MCP 端点需 Bearer 令牌。
安装
在 SourceWeft 中
- 打开 控制台中的 QueryWeaver,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
QueryWeaver (Text2SQL)
REST API · MCP · Graph-powered
QueryWeaver is an open-source Text2SQL tool that converts plain-English questions into SQL using graph-powered schema understanding. It helps you ask databases natural-language questions and returns SQL and results.
Connect and ask questions: [Discord]
Get Started
Docker
💡 Recommended for evaluation purposes (Local Python or Node are not required)
Launch: http://localhost:5000
Use an .env file (Recommended)
Create a local .env by copying .env.example and passing it to Docker. This is the simplest way to provide all required configuration:
Alternative: Pass individual environment variables
If you prefer to pass variables on the command line, use -e flags (less convenient for many variables):
APP_ENV=developmentis what makes the login work on the plain-HTTPhttp://localhost:5000this command serves. Drop it (or set anything else) when you put QueryWeaver behind HTTPS, so the session cookie is markedSecure. See Application environment.
Note: QueryWeaver supports multiple AI providers. You can use
OPENAI_API_KEY,GEMINI_API_KEY,ANTHROPIC_API_KEY, orAZURE_API_KEY. See the AI/LLM configuration section for details.
For a full list of configuration options, consult
.env.example.
Memory TTL (optional)
QueryWeaver stores per-user conversation memory in FalkorDB. By default these graphs persist indefinitely. Set MEMORY_TTL_SECONDS to apply a Redis TTL (in seconds) so idle memory graphs are automatically cleaned up.
The TTL is refreshed on every user interaction, so active users keep their memory.
MCP server: host or connect (optional)
QueryWeaver includes optional support for the Model Context Protocol (MCP). You can either have QueryWeaver expose an MCP-compatible HTTP surface (so other services can call QueryWeaver as an MCP server), or configure QueryWeaver to call an external MCP server for model/context services.
What QueryWeaver provides
-
The app registers MCP operations focused on Text2SQL flows:
list_databasesconnect_databasedatabase_schemaquery_database
-
To disable the built-in MCP endpoints set
DISABLE_MCP=truein your.envor environment (default: MCP enabled). -
Configuration
-
DISABLE_MCP— disable QueryWeaver's built-in MCP HTTP surface. Set totrueto disable. Default:false(MCP enabled).
Examples
Disable the built-in MCP when running with Docker:
Calling the built-in MCP endpoints (example)
- The MCP surface is exposed as HTTP endpoints.
Server Configuration
Below is a minimal example mcp.json client configuration that targets a local QueryWeaver instance exposing the MCP HTTP surface at /mcp.
REST API
API Documentation
Swagger UI: https://app.queryweaver.ai/docs
OpenAPI JSON: https://app.queryweaver.ai/openapi.json
Overview
QueryWeaver exposes a small REST API for managing graphs (database schemas) and running Text2SQL queries. All endpoints that modify or access user-scoped data require authentication. In the browser the app uses a signed session cookie established by OAuth or email/password; for CLI and scripts you can use an API token (see tokens routes or the web UI to create one).
Core endpoints
- GET /graphs — list available graphs for the authenticated user
- GET /graphs/{graph_id}/data — return nodes/links (tables, columns, foreign keys) for the graph
- POST /graphs — upload or create a graph (JSON payload or file upload)
- POST /graphs/{graph_id} — run a Text2SQL chat query against the named graph (streaming response)
Authentication
- Add an Authorization header:
Authorization: Bearer <API_TOKEN>
Three separate credentials
QueryWeaver keeps its three kinds of "login" independent of one another, so a failure in one never looks like a failure in another:
Because the browser login is a signed cookie, staying logged in costs no database
round trip and survives a FalkorDB outage in an already-running process — you
keep your session and only the operations that genuinely need the graph fail.
Requests that supply an API token explicitly are always checked against the
database and are answered with 503 (not 401) when it cannot be reached, so
clients retry instead of re-authenticating.
Note the scope: this is about staying logged in, not about booting. QueryWeaver still connects to FalkorDB at startup and will not start without it, so a restart during an outage is not covered.
A browser login lasts 24 hours by default; set BROWSER_SESSION_TTL_HOURS to
change that. Logging out clears the session cookie. No API token is issued to
the browser, so there is none to revoke — tokens are created explicitly from the
tokens API and revoked there. (A legacy api_token cookie left over from an
older release is cleared and revoked on logout too.)
Email signup is verified before the account exists
Signing up with an email address and password does not create an account. The submitted details are parked, a six-digit confirmation code is mailed to the address, and the account — and the session — come into being only when that code is typed back into the signup form. So an address the registrant does not control never becomes an account at all, and there is no half-real user for the rest of the system to reason about.
A code rather than an emailed link, because the code has to come back to the session that submitted the form. A link can be opened by anyone who receives it: a stranger could submit your address with a password of their choosing, and your single click would create an account they knew the password to. Nobody can be signed up by someone else here, because the person who fills in the form is the only one who ever holds both halves.
The code is single-use, expires after 15 minutes and tolerates only a handful of wrong guesses before the pending signup is discarded — a short code is only safe while the number of attempts is small. It is also only redeemable in the browser that submitted the form: each submission mints a ticket that stays in that browser's session, and a code presented without its ticket is refused. Entering it signs the browser in directly: the password was chosen minutes earlier, and asking for it again would prove nothing. A code can be re-sent from the same screen, subject to a per-address rate limit; the send budget is per pending signup, so it starts over once the pending signup expires and an address can always be signed up again later. Typing a code that has expired is not one of the wrong guesses and does not discard anything — the pending signup is left where it is so the same screen can send a fresh code.
In development, a message with no mail server configured is written to the
application log instead of being sent, so the flow can be completed by copying
the code out of the log. This needs APP_ENV=development — anywhere else an
unconfigured process refuses the send rather than logging the code and
reporting success. Set MAIL_SERVER (plus MAIL_PORT, MAIL_USERNAME,
MAIL_PASSWORD, MAIL_DEFAULT_SENDER) to send for real; any provider with an
SMTP endpoint works. EMAIL_VERIFICATION_TTL_MINUTES,
EMAIL_VERIFICATION_MAX_ATTEMPTS, EMAIL_VERIFICATION_RESEND_SECONDS and
EMAIL_VERIFICATION_MAX_SENDS tune the lifetime and the limits. See
.env.example for the full list.
The trade-off of a signed session cookie is that it cannot be revoked from
the server before it expires: the TTL bounds the damage, and rotating
FASTAPI_SECRET_KEY invalidates every browser login at once. API tokens keep
their server-side record and so can still be revoked individually and
immediately. Shorten BROWSER_SESSION_TTL_HOURS if you need a tighter window.
Examples
- List graphs (GET)
curl example:
Python example:
- Get graph schema (GET)
curl example:
Python example:
- Load a graph (POST) — JSON payload
Or upload a file (multipart/form-data):
- Query a graph (POST) — run a chat-based Text2SQL request
The POST /graphs/{graph_id} endpoint accepts a JSON body with at least a chat field (an array of messages). The endpoint streams processing steps and the final SQL back as server-sent-message chunks delimited by a special boundary used by the frontend. For simple scripting you can call it and read the final JSON object from the streamed messages.
Example payload:
curl example (simple, collects whole response):
Python example (stream-aware):
Notes & tips
- Graph IDs are namespaced per-user. When calling the API directly use the plain graph id (the server will namespace by the authenticated user). For uploaded files the
databasefield determines the saved graph id. - The streaming response includes intermediate reasoning steps, follow-up questions (if the query is ambiguous or off-topic), and the final SQL. The frontend expects the boundary string
|||FALKORDB_MESSAGE_BOUNDARY|||between messages. - For destructive SQL (INSERT/UPDATE/DELETE etc) the service will include a confirmation step in the stream; the frontend handles this flow. If you automate destructive operations, ensure you handle confirmation properly (see the
ConfirmRequestmodel in the code).
Python SDK
The QueryWeaver Python SDK allows you to use Text2SQL functionality directly in your Python applications without running a web server.
Installation
Quick Start
Context Manager
Multiple Instances
Multiple QueryWeaver instances can run side-by-side in the same process.
Each holds its own FalkorDB connection and passes it explicitly through
every call, so there is no shared global state to collide over.
Available Methods
Advanced Query Options
For multi-turn conversations, custom instructions, or per-request LLM overrides:
Handling Destructive Operations
INSERT, UPDATE, DELETE operations require confirmation:
Requirements
- Python 3.12+
- FalkorDB instance (local or remote)
- OpenAI or Azure OpenAI API key (for LLM)
- Target SQL database (PostgreSQL or MySQL)
Development
Follow these steps to run and develop QueryWeaver from source.
Prerequisites
- Python 3.12+
- uv (Python package manager)
- A FalkorDB instance (local or remote)
- Node.js and npm (for the React frontend)
Install and configure
Quickstart (recommended for development):
If you prefer to set up manually or need a custom environment, use uv:
Run the app locally
The server will be available at http://localhost:5000
Alternatively, the repository provides Make targets for running the app:
Frontend build (when needed)
The frontend is a modern React + Vite app in app/. Build before production runs or after frontend changes:
OAuth configuration
QueryWeaver supports Google and GitHub OAuth. Create OAuth credentials for each provider and paste the client IDs/secrets into your .env file.
- Google: set authorized origin and callback
http://localhost:5000/login/google/authorized - GitHub: set homepage and callback
http://localhost:5000/login/github/authorized
Environment-specific OAuth settings
For production/staging deployments, session cookies are HTTPS-only by default. Only an APP_ENV that reads as development once trimmed and lower-cased turns that off, so a deployment that forgets the variable still gets secure cookies. Set APP_ENV=development for plain-HTTP local runs, otherwise the browser drops the cookie and you get OAuth CSRF state mismatch errors.
The signed session cookie is the browser's only credential. An api_token is never written to a browser cookie - a bearer token in a cookie sits on disk in clear text for its whole lifetime - so programmatic clients fetch one from the tokens API instead. Sessions issued before this change keep working: the legacy api_token cookie is still accepted, just no longer handed out.
Important: If you're getting "mismatching_state: CSRF Warning!" errors on a plain-HTTP environment, ensure APP_ENV is set to development.
AI/LLM configuration
QueryWeaver supports multiple AI providers. Set one API key and QueryWeaver auto-detects which provider to use.
Priority order: Ollama > OpenAI > Gemini > Anthropic > Cohere > Azure (default)
* Anthropic has no native embeddings. You must set VOYAGE_API_KEY or EMBEDDING_MODEL for embeddings, otherwise startup will fail with an error.
Optional: Override default models
Both must match your API key's provider.
To change only one provider's defaults, set <PROVIDER>_MODEL / <PROVIDER>_EMBEDDING_MODEL to a bare model name (e.g. AZURE_MODEL=my-gpt-deployment). COMPLETION_MODEL / EMBEDDING_MODEL take precedence over these. Anthropic has no ANTHROPIC_EMBEDDING_MODEL; its embeddings come from VOYAGE_API_KEY (fixed voyage/voyage-3) or EMBEDDING_MODEL.
Docker examples with AI configuration
Using OpenAI:
Using Google Gemini:
Using Anthropic:
Using Azure OpenAI:
Testing
Quick note: many tests require FalkorDB to be available. Use the included helper to run a test DB in Docker if needed.
Prerequisites
- Install dev dependencies:
uv sync - Start FalkorDB (see
make docker-falkordb) - Install Playwright browsers:
uv run playwright install
Quick commands
Recommended: prepare the development/test environment using the Make helper (installs dependencies and Playwright browsers):
Alternatively, you can run the E2E-specific setup script and then run tests manually:
Test types
- Unit tests: focus on individual modules and utilities. Run with
make test-unitoruv run python -m pytest tests/ -k "not e2e". - End-to-end (E2E) tests: run via Playwright and exercise UI flows, OAuth, file uploads, schema processing, chat queries, and API endpoints. Use
make test-e2e.
See tests/e2e/README.md for full E2E test instructions.
CI/CD
GitHub Actions run unit and E2E tests on pushes and pull requests. Failures capture screenshots and artifacts for debugging.
Troubleshooting
- FalkorDB connection issues: start the DB helper
make docker-falkordbor check network/host settings. - Playwright/browser failures: install browsers with
uv run playwright installand ensure system deps are present. - Missing environment variables: copy
.env.exampleand fill required values. - OAuth "mismatching_state: CSRF Warning!" errors: Session cookies are HTTPS-only unless
APP_ENVreads asdevelopmentonce trimmed and lower-cased. SetAPP_ENV=developmentfor plain-HTTP environments; useproductionorstaging(or leave the variable out entirely) for HTTPS deployments.
Project layout (high level)
api/– FastAPI backendapp/– React + Vite frontendtests/– unit and E2E tests
License
Licensed under the GNU Affero General Public License (AGPL). See LICENSE.
Copyright FalkorDB Ltd. 2025
来源:README.md,提交 df8d122
工具
0版本历史
1- v0.0.11最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分