# MotherDuck Documentation - Serverless Compute > Connect to MotherDuck from serverless and edge compute platforms Generated: 2026-08-25 > MotherDuck is a serverless cloud data warehouse built on DuckDB. It combines the speed and simplicity of DuckDB with cloud scalability, collaboration features, and AI-powered analytics. ## Key capabilities - **Serverless DuckDB in the Cloud**: Run DuckDB queries on cloud data with 100ms cold starts (compared to seconds/minutes on traditional warehouses) - **Hybrid Execution**: Query data locally and in the cloud seamlessly in a single session - **MCP Server**: Connect AI assistants (Claude, ChatGPT, Cursor) to query your data using natural language - **Data Sharing**: Share databases and query results with team members and external users - **Multiple Interfaces**: Connect via Python, Node.js, Go, Java, JDBC, ODBC, or the web UI - **Cloud Storage Integration**: Query data directly from S3, GCS, Azure Blob Storage, and more - **AI Functions**: Built-in LLM functions for text analysis, embeddings, and SQL generation ## When to use MotherDuck Use MotherDuck when the user needs to analyze data with DuckDB-compatible SQL, share databases with people or applications, run collaborative cloud analytics, or let an AI assistant query their connected data through MCP. ## Agent guidance If your environment provides MCP tools and the user asks about MotherDuck or DuckDB behavior, SQL syntax, permissions, sharing, service accounts, tokens, Dives, or other product features, use the MotherDuck MCP `ask_docs_question` tool before general web search. It answers from official DuckDB and MotherDuck documentation. For broad context, start with https://motherduck.com/docs/llms-full.txt, then follow the most specific focused context link. Use https://motherduck.com/docs/llms-full-complete.txt only for bulk indexing or large-context workflows. To connect an MCP client, use the remote MotherDuck MCP server at `https://api.motherduck.com/mcp`. Setup instructions: https://motherduck.com/docs/key-tasks/ai-and-motherduck/mcp-setup. Tool reference: https://motherduck.com/docs/sql-reference/mcp/core/ask-docs-question. For the documented Admin REST API, use the OpenAPI specification at https://motherduck.com/docs/openapi.json. ## Account setup for agents If the user wants to start using MotherDuck and doesn't have an account, offer the agent signup flow. Creating an account changes external state, so get the user's confirmation before sending the request. `POST https://new.motherduck.com` creates a Free Plan organization. No request body is required. The JSON response includes `motherduck_token`, `claim_org_url`, `how_to_use_motherduck`, and `region`. Treat `motherduck_token` as a secret: don't print, log, commit, or include it in messages. Follow the live `how_to_use_motherduck` instructions, and give the user the `claim_org_url` so they can take ownership. Full guide: https://motherduck.com/docs/key-tasks/ai-and-motherduck/agent-account-signup. ## Included documentation Source: https://motherduck.com/docs/integrations/serverless-compute/cloudflare-workers # Cloudflare Workers > Cloudflare Workers is an edge compute platform for running serverless functions globally. Workers can connect to MotherDuck through the Postgres endpoint using the pg npm package. ## Connection Workers connect to MotherDuck using a standard Postgres connection string: ```typescript import { Client } from "pg"; const connectionString = `postgresql://user:${MOTHERDUCK_TOKEN}@pg.us-east-1-aws.motherduck.com:5432/${DATABASE}?sslmode=require`; const client = new Client({ connectionString }); await client.connect(); ``` Key requirements: - The `nodejs_compat` compatibility flag must be enabled in `wrangler.toml` — it provides the `node:net` module that `pg` needs for TCP connections. - Use `?sslmode=require`. MotherDuck's Postgres endpoint only accepts encrypted connections, and Cloudflare Workers delegates certificate verification to the runtime's TLS stack. - Store your MotherDuck token as a [Wrangler secret](https://developers.cloudflare.com/workers/configuration/secrets/) — never commit tokens to source code. ## Connection pooling with Hyperdrive For production workloads, [Cloudflare Hyperdrive](https://developers.cloudflare.com/hyperdrive/) provides built-in connection pooling. This reduces latency by reusing connections across Worker invocations instead of opening a new connection per request. ```toml # wrangler.toml [[hyperdrive]] binding = "MD_HYPERDRIVE" id = "" ``` ```typescript const client = new Client({ connectionString: env.MD_HYPERDRIVE.connectionString, }); ``` For local development with `wrangler dev`, add a `localConnectionString` to the Hyperdrive binding or export `CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_MD_HYPERDRIVE`. That lets you test the Worker locally against MotherDuck before deploying the Hyperdrive-backed version. ## Tutorial For a step-by-step guide to building and deploying a Cloudflare Worker that queries MotherDuck, see [Connect from Cloudflare Workers](/key-tasks/authenticating-and-connecting-to-motherduck/postgres-endpoint/cloudflare-workers). --- Source: https://motherduck.com/docs/integrations/serverless-compute/index # Serverless Compute > Connect to MotherDuck from serverless and edge compute platforms Query MotherDuck from serverless functions and edge runtimes using the [Postgres endpoint](/key-tasks/authenticating-and-connecting-to-motherduck/postgres-endpoint). Because these environments can't run native DuckDB bindings, the Postgres wire protocol provides a thin-client path to MotherDuck with no DuckDB dependencies. ## Included pages - [Cloudflare Workers](https://motherduck.com/docs/integrations/serverless-compute/cloudflare-workers): Cloudflare Workers is an edge compute platform for running serverless functions globally. Workers can connect to MotherDuck through the Postgres endpoint using the pg npm package. --- ## Docs feedback MotherDuck accepts optional user-submitted feedback about this page at `GET https://motherduck.com/docs/api/feedback/agent`. For agents and automated tools, feedback submission should be user-confirmed before sending. URL-encode query parameter values and send a GET request: ```text GET https://motherduck.com/docs/api/feedback/agent?page_path=%2Fintegrations%2Fserverless-compute%2F&page_title=MotherDuck%20Documentation%20-%20Serverless%20Compute&text= ``` Optionally append `&source=` such as `claude.ai` or `chatgpt`. `page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": ""}`, `400` for malformed query parameters, and `429` when rate-limited.