{"id":33863464,"url":"https://github.com/sidequery/duckdb-acp","last_synced_at":"2026-04-06T08:31:20.733Z","repository":{"id":327602537,"uuid":"1108096134","full_name":"sidequery/duckdb-acp","owner":"sidequery","description":"Use Claude Code \u0026 other agents from inside DuckDB","archived":false,"fork":false,"pushed_at":"2025-12-07T06:22:48.000Z","size":60,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-07T23:43:49.406Z","etag":null,"topics":["acp","agents","claude-code","duckdb","duckdb-extension"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sidequery.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-02T02:42:32.000Z","updated_at":"2025-12-07T06:22:52.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sidequery/duckdb-acp","commit_stats":null,"previous_names":["sidequery/duckdb-acp"],"tags_count":1,"template":false,"template_full_name":"duckdb/extension-template","purl":"pkg:github/sidequery/duckdb-acp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidequery%2Fduckdb-acp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidequery%2Fduckdb-acp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidequery%2Fduckdb-acp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidequery%2Fduckdb-acp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sidequery","download_url":"https://codeload.github.com/sidequery/duckdb-acp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidequery%2Fduckdb-acp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31464604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"online","status_checked_at":"2026-04-06T02:00:07.287Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acp","agents","claude-code","duckdb","duckdb-extension"],"created_at":"2025-12-09T11:00:30.500Z","updated_at":"2026-04-06T08:31:20.728Z","avatar_url":"https://github.com/sidequery.png","language":"Rust","readme":"# DuckDB ACP\n\nA DuckDB extension that enables natural language to SQL using the [Agent Client Protocol (ACP)](https://agentclientprotocol.com/). Query your data with plain English.\n\n## Features\n\n- **Natural language queries**: Write queries in plain English instead of SQL\n- **Statement syntax**: `CLAUDE show me the top 10 customers by revenue`\n- **Table function**: `SELECT * FROM claude('what products sold the most last month?')`\n- **Schema-aware**: The agent explores your database schema to generate accurate queries\n- **Safe mode**: Blocks mutation queries (INSERT, UPDATE, DELETE) by default\n\n## Supported Agents\n\n- [x] [Claude Code](https://docs.anthropic.com/en/docs/claude-code)\n- [ ] Codex\n- [ ] Gemini\n\n## Quick Start\n\n```sql\n-- Load the extension\nLOAD 'acp.duckdb_extension';\n\n-- Create some sample data\nCREATE TABLE sales (id INT, product VARCHAR, amount DECIMAL, sale_date DATE);\nINSERT INTO sales VALUES\n    (1, 'Widget', 99.99, '2024-01-15'),\n    (2, 'Gadget', 149.99, '2024-01-16'),\n    (3, 'Widget', 99.99, '2024-01-17');\n\n-- Query with natural language (statement syntax)\nCLAUDE what is the total revenue by product?\n\n-- Or use the table function\nSELECT * FROM claude('which product has the highest average sale amount?');\n```\n\n## Requirements\n\n- DuckDB 1.1.0+\n- [bun](https://bun.sh/) or [Node.js](https://nodejs.org/) (for npx)\n- Valid Anthropic API credentials configured for Claude Code\n\n## Configuration\n\n| Setting | Type | Default | Description |\n|---------|------|---------|-------------|\n| `acp_agent` | VARCHAR | `claude-code` | Agent command or path |\n| `acp_safe_mode` | BOOLEAN | `true` | Block mutation queries |\n| `acp_debug` | BOOLEAN | `false` | Enable verbose debug output |\n| `acp_show_messages` | BOOLEAN | `false` | Stream agent thinking to output |\n| `acp_show_sql` | BOOLEAN | `false` | Print generated SQL before executing |\n| `acp_show_summary` | BOOLEAN | `false` | Show analysis summary from agent |\n| `acp_show_datasources` | BOOLEAN | `false` | Show datasources and calculations |\n| `acp_timeout` | INTEGER | `300` | Timeout in seconds |\n\n```sql\n-- Disable safe mode to allow mutations (use with caution)\nSET acp_safe_mode = false;\n\n-- See the agent's thinking process\nSET acp_show_messages = true;\n\n-- See the generated SQL before it runs\nSET acp_show_sql = true;\n\n-- Show analysis summary\nSET acp_show_summary = true;\n\n-- Show datasources and calculations\nSET acp_show_datasources = true;\n\n-- Enable verbose debug output\nSET acp_debug = true;\n\n-- Increase timeout for complex queries\nSET acp_timeout = 600;\n```\n\n## Safety\n\nBy default, all mutation queries all blocked (unless you override the `acp_safe_mode` setting in DuckDB exposed by this extension. All default agent tools are blocked; the underlying agaent only has access to run SQL against the host DuckDB database.\n\n## Architecture\n\n```\n┌─────────────────────────────────────────────────────────────────────┐\n│                          DuckDB Process                             │\n│                                                                     │\n│  ┌───────────────────────────────────────────────────────────────┐  │\n│  │                    ACP Extension (C++)                        │  │\n│  │  - Parses CLAUDE statements and claude() function calls       │  │\n│  │  - Invokes Rust FFI for agent communication                   │  │\n│  │  - Executes generated SQL and returns results                 │  │\n│  └───────────────────────────────────────────────────────────────┘  │\n│                                │                                    │\n│                                ▼                                    │\n│  ┌───────────────────────────────────────────────────────────────┐  │\n│  │                Rust Core (duckdb_acp_core)                    │  │\n│  │  - ACP client: spawns agent, communicates via stdio           │  │\n│  │  - MCP server: HTTP server exposing run_sql, final_sql tools  │  │\n│  │  - Tool execution via SQL callback to C++                     │  │\n│  └───────────────────────────────────────────────────────────────┘  │\n│                    │ stdio (ACP)           ▲                        │\n│                    ▼                       │ HTTP (MCP)             │\n│             ┌─────────────┐                │                        │\n│             │ Claude Code │────────────────┘                        │\n│             └─────────────┘                                         │\n│                                                                     │\n└─────────────────────────────────────────────────────────────────────┘\n```\n\n### How It Works\n\n1. **Query parsing**: The extension intercepts `CLAUDE \u003cquery\u003e` statements or `claude('query')` function calls\n2. **MCP server startup**: An HTTP MCP server starts on a random localhost port, providing two tools:\n   - `run_sql`: Execute SQL for schema exploration and query testing\n   - `final_query`: Submit the final SQL answer\n3. **Agent invocation**: The `claude-code-acp` agent is spawned via stdio and given access to the MCP server\n4. **Schema exploration**: The agent uses `run_sql` to discover tables, columns, and data patterns\n5. **Query generation**: The agent constructs and tests SQL queries iteratively\n6. **Result capture**: When the agent calls `final_query`, the SQL is captured and executed\n7. **Cleanup**: The agent process and MCP server are terminated\n\n### Key Design Decisions\n\n- **Embedded MCP server**: The MCP server runs in-process, eliminating external binary dependencies\n- **HTTP transport**: Uses HTTP MCP transport (not stdio) for reliable tool communication\n- **Safe mode default**: Mutation queries are blocked by default to prevent accidental data modification\n- **Timeout protection**: Agent sessions have a configurable timeout to prevent runaway queries\n\n## Building from Source\n\n### Prerequisites\n\n- CMake 3.15+\n- C++17 compiler\n- Rust 1.70+\n- DuckDB source (as submodule)\n\n### Build Steps\n\n```bash\n# Clone with submodules\ngit clone --recurse-submodules https://github.com/yourusername/duckdb-acp.git\ncd duckdb-acp\n\n# Build\nmake\n\n# The extension will be at:\n# build/release/extension/acp/acp.duckdb_extension\n```\n\n### Project Structure\n\n```\n.\n├── src/\n│   ├── acp_extension.cpp      # DuckDB extension entry point\n│   └── include/\n│       └── acp_extension.hpp  # Extension header\n├── duckdb_acp_core/           # Rust core library\n│   ├── src/\n│   │   ├── lib.rs             # Library entry\n│   │   ├── ffi.rs             # C FFI interface\n│   │   └── mcp_server.rs      # Embedded HTTP MCP server\n│   └── Cargo.toml\n├── duckdb/                    # DuckDB submodule\n└── CMakeLists.txt\n```\n\n## Limitations\n\n- Requires an active internet connection for the Claude API\n- Query latency depends on agent response time (typically 5-30 seconds)\n- Complex analytical queries may require multiple agent iterations\n- The agent cannot access external files or network resources\n\n## License\n\nMIT\n\n## Acknowledgments\n\n- [DuckDB](https://duckdb.org/) for the excellent embeddable database\n- [Zed Industries](https://zed.dev/) for the [ACP specification](https://github.com/zed-industries/agent-client-protocol)\n- [Anthropic](https://www.anthropic.com/) for Claude and MCP\n- [rmcp](https://github.com/anthropics/rmcp) for the Rust MCP implementation\n","funding_links":[],"categories":["Extensions"],"sub_categories":["[Community Extensions](https://duckdb.org/community_extensions/)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsidequery%2Fduckdb-acp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsidequery%2Fduckdb-acp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsidequery%2Fduckdb-acp/lists"}