mcp-server-motherduck 0.6.4__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. mcp_server_motherduck-0.7.0/.github/workflows/publish-mcp.yml +74 -0
  2. {mcp_server_motherduck-0.6.4 → mcp_server_motherduck-0.7.0}/PKG-INFO +34 -3
  3. {mcp_server_motherduck-0.6.4 → mcp_server_motherduck-0.7.0}/README.md +33 -2
  4. {mcp_server_motherduck-0.6.4 → mcp_server_motherduck-0.7.0}/pyproject.toml +1 -1
  5. mcp_server_motherduck-0.7.0/server.json +91 -0
  6. {mcp_server_motherduck-0.6.4 → mcp_server_motherduck-0.7.0}/src/mcp_server_motherduck/configs.py +1 -1
  7. {mcp_server_motherduck-0.6.4 → mcp_server_motherduck-0.7.0}/src/mcp_server_motherduck/database.py +70 -2
  8. {mcp_server_motherduck-0.6.4 → mcp_server_motherduck-0.7.0}/uv.lock +157 -156
  9. mcp_server_motherduck-0.6.4/.github/workflows/python-publish.yml +0 -33
  10. mcp_server_motherduck-0.6.4/.idea/.gitignore +0 -8
  11. mcp_server_motherduck-0.6.4/.idea/mcp-server-motherduck.iml +0 -9
  12. mcp_server_motherduck-0.6.4/.idea/misc.xml +0 -5
  13. mcp_server_motherduck-0.6.4/.idea/modules.xml +0 -8
  14. mcp_server_motherduck-0.6.4/.idea/vcs.xml +0 -6
  15. mcp_server_motherduck-0.6.4/.idea/workspace.xml +0 -106
  16. mcp_server_motherduck-0.6.4/server.json +0 -31
  17. {mcp_server_motherduck-0.6.4 → mcp_server_motherduck-0.7.0}/.gitignore +0 -0
  18. {mcp_server_motherduck-0.6.4 → mcp_server_motherduck-0.7.0}/LICENSE +0 -0
  19. {mcp_server_motherduck-0.6.4 → mcp_server_motherduck-0.7.0}/makefile +0 -0
  20. {mcp_server_motherduck-0.6.4 → mcp_server_motherduck-0.7.0}/src/mcp_server_motherduck/__init__.py +0 -0
  21. {mcp_server_motherduck-0.6.4 → mcp_server_motherduck-0.7.0}/src/mcp_server_motherduck/prompt.py +0 -0
  22. {mcp_server_motherduck-0.6.4 → mcp_server_motherduck-0.7.0}/src/mcp_server_motherduck/server.py +0 -0
@@ -0,0 +1,74 @@
1
+ name: Publish to PyPI and MCP Registry
2
+
3
+ on:
4
+ workflow_dispatch: # Allows manual triggering from GitHub Actions UI
5
+
6
+ jobs:
7
+ publish:
8
+ runs-on: ubuntu-latest
9
+ permissions:
10
+ id-token: write # Required for OIDC authentication
11
+ contents: read
12
+
13
+ steps:
14
+ - name: Checkout code
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Setup Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: '3.11'
21
+
22
+ - name: Install uv
23
+ uses: astral-sh/setup-uv@v5
24
+ with:
25
+ enable-cache: true
26
+ cache-dependency-glob: "uv.lock"
27
+
28
+ - name: Install dependencies
29
+ run: uv sync --all-extras --dev
30
+
31
+ - name: Build package
32
+ run: uv build
33
+
34
+ - name: Publish to PyPI
35
+ id: pypi-publish
36
+ continue-on-error: true
37
+ run: |
38
+ uv publish --token ${{ secrets.PYPI_TOKEN }} 2>&1 | tee publish_output.txt
39
+ exit_code=${PIPESTATUS[0]}
40
+ if [ $exit_code -eq 0 ]; then
41
+ echo "✅ Successfully published to PyPI"
42
+ echo "pypi_status=success" >> $GITHUB_OUTPUT
43
+ elif grep -q "already exists" publish_output.txt || grep -q "File already exists" publish_output.txt; then
44
+ echo "⚠️ Package version already exists on PyPI, skipping..."
45
+ echo "pypi_status=already_exists" >> $GITHUB_OUTPUT
46
+ exit 0
47
+ else
48
+ echo "❌ Failed to publish to PyPI"
49
+ echo "pypi_status=failed" >> $GITHUB_OUTPUT
50
+ exit 1
51
+ fi
52
+ env:
53
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
54
+
55
+ - name: Setup Node.js (for schema validation)
56
+ uses: actions/setup-node@v4
57
+ with:
58
+ node-version: '20'
59
+
60
+ - name: Install MCP Publisher
61
+ run: |
62
+ # Clone and build the MCP publisher
63
+ git clone https://github.com/modelcontextprotocol/registry publisher-repo
64
+ cd publisher-repo
65
+ make publisher
66
+ cp bin/mcp-publisher ../mcp-publisher
67
+ cd ..
68
+ chmod +x mcp-publisher
69
+
70
+ - name: Login to MCP Registry
71
+ run: ./mcp-publisher login github-oidc
72
+
73
+ - name: Publish to MCP Registry
74
+ run: ./mcp-publisher publish
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-server-motherduck
3
- Version: 0.6.4
3
+ Version: 0.7.0
4
4
  Summary: A MCP server for MotherDuck and local DuckDB
5
5
  Author-email: tdoehmen <till@motherduck.com>
6
6
  License-File: LICENSE
@@ -19,7 +19,7 @@ Description-Content-Type: text/markdown
19
19
 
20
20
  An MCP server implementation that interacts with DuckDB and MotherDuck databases, providing SQL analytics capabilities to AI Assistants and IDEs.
21
21
 
22
- [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](cursor://anysphere.cursor-deeplink/mcp/install?name=DuckDB&config=eyJjb21tYW5kIjoidXZ4IG1jcC1zZXJ2ZXItbW90aGVyZHVjayAtLWRiLXBhdGggOm1lbW9yeToiLCJlbnYiOnsibW90aGVyZHVja190b2tlbiI6IiJ9fQ%3D%3D)
22
+ [<img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install in Cursor">](https://cursor.com/en/install-mcp?name=DuckDB&config=eyJjb21tYW5kIjoidXZ4IG1jcC1zZXJ2ZXItbW90aGVyZHVjayAtLWRiLXBhdGggOm1lbW9yeToiLCJlbnYiOnsibW90aGVyZHVja190b2tlbiI6IiJ9fQ%3D%3D)
23
23
 
24
24
  ## Resources
25
25
  - [Close the Loop: Faster Data Pipelines with MCP, DuckDB & AI (Blogpost)](https://motherduck.com/blog/faster-data-pipelines-with-mcp-duckdb-ai/)
@@ -59,7 +59,7 @@ The MCP server supports the following parameters:
59
59
  |-----------|------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
60
60
  | `--transport` | Choice | `stdio` | Transport type. Options: `stdio`, `sse`, `stream` |
61
61
  | `--port` | Integer | `8000` | Port to listen on for sse and stream transport mode |
62
- | `--db-path` | String | `md:` | Path to local DuckDB database file or MotherDuck database |
62
+ | `--db-path` | String | `md:` | Path to local DuckDB database file, MotherDuck database, or S3 URL (e.g., `s3://bucket/path/to/db.duckdb`) |
63
63
  | `--motherduck-token` | String | `None` | Access token to use for MotherDuck database connections (uses `motherduck_token` env var by default) |
64
64
  | `--read-only` | Flag | `False` | Flag for connecting to DuckDB or MotherDuck in read-only mode. For DuckDB it uses short-lived connections to enable concurrent access |
65
65
  | `--home-dir` | String | `None` | Home directory for DuckDB (uses `HOME` env var by default) |
@@ -354,6 +354,37 @@ modeling data within duckdb and then an MCP client (Windsurf/Cline/Claude/Cursor
354
354
  was used for exploring the database. The short lived connections allow each tool
355
355
  to run and then release their connection, allowing the next tool to connect.
356
356
 
357
+ ## Connect to DuckDB on S3
358
+
359
+ You can connect to DuckDB databases stored on Amazon S3 by providing an S3 URL as the database path. The server will automatically configure the necessary S3 credentials from your environment variables.
360
+
361
+ ```json
362
+ {
363
+ "mcpServers": {
364
+ "mcp-server-motherduck": {
365
+ "command": "uvx",
366
+ "args": [
367
+ "mcp-server-motherduck",
368
+ "--db-path",
369
+ "s3://your-bucket/path/to/database.duckdb"
370
+ ],
371
+ "env": {
372
+ "AWS_ACCESS_KEY_ID": "<your_key>",
373
+ "AWS_SECRET_ACCESS_KEY": "<your_secret>",
374
+ "AWS_DEFAULT_REGION": "<your_region>"
375
+ }
376
+ }
377
+ }
378
+ }
379
+ ```
380
+
381
+
382
+ **Note**: For S3 connections:
383
+ - AWS credentials must be provided via environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and optionally `AWS_DEFAULT_REGION`)
384
+ - The S3 database is attached to an in-memory DuckDB instance
385
+ - The httpfs extension is automatically installed and configured for S3 access
386
+ - Both read and write operations are supported
387
+
357
388
  ## Example Queries
358
389
 
359
390
  Once configured, you can e.g. ask Claude to run queries like:
@@ -2,7 +2,7 @@
2
2
 
3
3
  An MCP server implementation that interacts with DuckDB and MotherDuck databases, providing SQL analytics capabilities to AI Assistants and IDEs.
4
4
 
5
- [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](cursor://anysphere.cursor-deeplink/mcp/install?name=DuckDB&config=eyJjb21tYW5kIjoidXZ4IG1jcC1zZXJ2ZXItbW90aGVyZHVjayAtLWRiLXBhdGggOm1lbW9yeToiLCJlbnYiOnsibW90aGVyZHVja190b2tlbiI6IiJ9fQ%3D%3D)
5
+ [<img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install in Cursor">](https://cursor.com/en/install-mcp?name=DuckDB&config=eyJjb21tYW5kIjoidXZ4IG1jcC1zZXJ2ZXItbW90aGVyZHVjayAtLWRiLXBhdGggOm1lbW9yeToiLCJlbnYiOnsibW90aGVyZHVja190b2tlbiI6IiJ9fQ%3D%3D)
6
6
 
7
7
  ## Resources
8
8
  - [Close the Loop: Faster Data Pipelines with MCP, DuckDB & AI (Blogpost)](https://motherduck.com/blog/faster-data-pipelines-with-mcp-duckdb-ai/)
@@ -42,7 +42,7 @@ The MCP server supports the following parameters:
42
42
  |-----------|------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
43
43
  | `--transport` | Choice | `stdio` | Transport type. Options: `stdio`, `sse`, `stream` |
44
44
  | `--port` | Integer | `8000` | Port to listen on for sse and stream transport mode |
45
- | `--db-path` | String | `md:` | Path to local DuckDB database file or MotherDuck database |
45
+ | `--db-path` | String | `md:` | Path to local DuckDB database file, MotherDuck database, or S3 URL (e.g., `s3://bucket/path/to/db.duckdb`) |
46
46
  | `--motherduck-token` | String | `None` | Access token to use for MotherDuck database connections (uses `motherduck_token` env var by default) |
47
47
  | `--read-only` | Flag | `False` | Flag for connecting to DuckDB or MotherDuck in read-only mode. For DuckDB it uses short-lived connections to enable concurrent access |
48
48
  | `--home-dir` | String | `None` | Home directory for DuckDB (uses `HOME` env var by default) |
@@ -337,6 +337,37 @@ modeling data within duckdb and then an MCP client (Windsurf/Cline/Claude/Cursor
337
337
  was used for exploring the database. The short lived connections allow each tool
338
338
  to run and then release their connection, allowing the next tool to connect.
339
339
 
340
+ ## Connect to DuckDB on S3
341
+
342
+ You can connect to DuckDB databases stored on Amazon S3 by providing an S3 URL as the database path. The server will automatically configure the necessary S3 credentials from your environment variables.
343
+
344
+ ```json
345
+ {
346
+ "mcpServers": {
347
+ "mcp-server-motherduck": {
348
+ "command": "uvx",
349
+ "args": [
350
+ "mcp-server-motherduck",
351
+ "--db-path",
352
+ "s3://your-bucket/path/to/database.duckdb"
353
+ ],
354
+ "env": {
355
+ "AWS_ACCESS_KEY_ID": "<your_key>",
356
+ "AWS_SECRET_ACCESS_KEY": "<your_secret>",
357
+ "AWS_DEFAULT_REGION": "<your_region>"
358
+ }
359
+ }
360
+ }
361
+ }
362
+ ```
363
+
364
+
365
+ **Note**: For S3 connections:
366
+ - AWS credentials must be provided via environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and optionally `AWS_DEFAULT_REGION`)
367
+ - The S3 database is attached to an in-memory DuckDB instance
368
+ - The httpfs extension is automatically installed and configured for S3 access
369
+ - Both read and write operations are supported
370
+
340
371
  ## Example Queries
341
372
 
342
373
  Once configured, you can e.g. ask Claude to run queries like:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mcp-server-motherduck"
3
- version = "0.6.4"
3
+ version = "0.7.0"
4
4
  description = "A MCP server for MotherDuck and local DuckDB"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -0,0 +1,91 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
3
+ "name": "io.github.motherduckdb/mcp-server-motherduck",
4
+ "description": "Fast analytics and data processing with DuckDB and MotherDuck",
5
+ "status": "active",
6
+ "repository": {
7
+ "url": "https://github.com/motherduckdb/mcp-server-motherduck",
8
+ "source": "github"
9
+ },
10
+ "version": "0.7.0",
11
+ "packages": [
12
+ {
13
+ "registry_type": "pypi",
14
+ "registry_base_url": "https://pypi.org",
15
+ "identifier": "mcp-server-motherduck",
16
+ "version": "0.7.0",
17
+ "transport": {
18
+ "type": "stdio"
19
+ },
20
+ "package_arguments": [
21
+ {
22
+ "type": "named",
23
+ "name": "--transport",
24
+ "description": "Transport type for MCP server",
25
+ "default": "stdio",
26
+ "choices": ["stdio", "sse", "stream"],
27
+ "is_required": false
28
+ },
29
+ {
30
+ "type": "named",
31
+ "name": "--port",
32
+ "description": "Port to listen on for sse and stream transport mode",
33
+ "default": "8000",
34
+ "format": "number",
35
+ "is_required": false
36
+ },
37
+ {
38
+ "type": "named",
39
+ "name": "--db-path",
40
+ "description": "Path to local DuckDB database file or MotherDuck database",
41
+ "default": "md:",
42
+ "is_required": false
43
+ },
44
+ {
45
+ "type": "named",
46
+ "name": "--motherduck-token",
47
+ "description": "Access token to use for MotherDuck database connections",
48
+ "is_required": false,
49
+ "is_secret": true
50
+ },
51
+ {
52
+ "type": "named",
53
+ "name": "--read-only",
54
+ "description": "Flag for connecting to DuckDB or MotherDuck in read-only mode",
55
+ "is_required": false
56
+ },
57
+ {
58
+ "type": "named",
59
+ "name": "--home-dir",
60
+ "description": "Home directory for DuckDB",
61
+ "is_required": false
62
+ },
63
+ {
64
+ "type": "named",
65
+ "name": "--saas-mode",
66
+ "description": "Flag for connecting to MotherDuck in SaaS mode (disables filesystem and write permissions for local DuckDB)",
67
+ "is_required": false
68
+ },
69
+ {
70
+ "type": "named",
71
+ "name": "--json-response",
72
+ "description": "Enable JSON responses for HTTP stream (only supported for stream transport)",
73
+ "is_required": false
74
+ }
75
+ ],
76
+ "environment_variables": [
77
+ {
78
+ "name": "motherduck_token",
79
+ "description": "Access token to use for MotherDuck database connections",
80
+ "is_required": false,
81
+ "is_secret": true
82
+ },
83
+ {
84
+ "name": "HOME",
85
+ "description": "Home directory for DuckDB (used as default if --home-dir not specified)",
86
+ "is_required": false
87
+ }
88
+ ]
89
+ }
90
+ ]
91
+ }
@@ -1,6 +1,6 @@
1
1
  from typing import Any
2
2
 
3
- SERVER_VERSION = "0.6.4"
3
+ SERVER_VERSION = "0.7.0"
4
4
 
5
5
  SERVER_LOCALHOST = "127.0.0.1"
6
6
 
@@ -36,6 +36,10 @@ class DatabaseClient:
36
36
 
37
37
  logger.info(f"🔌 Connecting to {self.db_type} database")
38
38
 
39
+ # S3 databases don't support read-only mode
40
+ if self.db_type == "s3" and self._read_only:
41
+ raise ValueError("Read-only mode is not supported for S3 databases")
42
+
39
43
  if self.db_type == "duckdb" and self._read_only:
40
44
  # check that we can connect, issue a `select 1` and then close + return None
41
45
  try:
@@ -53,6 +57,66 @@ class DatabaseClient:
53
57
  logger.error(f"❌ Read-only check failed: {e}")
54
58
  raise
55
59
 
60
+ # Check if this is an S3 path
61
+ if self.db_type == "s3":
62
+ # For S3, we need to create an in-memory connection and attach the S3 database
63
+ conn = duckdb.connect(':memory:')
64
+
65
+ # Install and load the httpfs extension for S3 support
66
+ import io
67
+ from contextlib import redirect_stdout, redirect_stderr
68
+
69
+ null_file = io.StringIO()
70
+ with redirect_stdout(null_file), redirect_stderr(null_file):
71
+ try:
72
+ conn.execute("INSTALL httpfs;")
73
+ except:
74
+ pass # Extension might already be installed
75
+ conn.execute("LOAD httpfs;")
76
+
77
+ # Configure S3 credentials from environment variables using CREATE SECRET
78
+ aws_access_key = os.environ.get('AWS_ACCESS_KEY_ID')
79
+ aws_secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY')
80
+ aws_region = os.environ.get('AWS_DEFAULT_REGION', 'us-east-1')
81
+
82
+
83
+ if aws_access_key and aws_secret_key:
84
+ # Use CREATE SECRET for better credential management
85
+ conn.execute(f"""
86
+ CREATE SECRET IF NOT EXISTS s3_secret (
87
+ TYPE S3,
88
+ KEY_ID '{aws_access_key}',
89
+ SECRET '{aws_secret_key}',
90
+ REGION '{aws_region}'
91
+ );
92
+ """)
93
+
94
+ # Attach the S3 database
95
+ try:
96
+ # For S3, we always attach as READ_ONLY since S3 storage is typically read-only
97
+ # Even when not in read_only mode, we attach as READ_ONLY for S3
98
+ conn.execute(f"ATTACH '{self.db_path}' AS s3db (READ_ONLY);")
99
+ # Use the attached database
100
+ conn.execute("USE s3db;")
101
+ logger.info(f"✅ Successfully connected to {self.db_type} database (attached as read-only)")
102
+ except Exception as e:
103
+ logger.error(f"Failed to attach S3 database: {e}")
104
+ # If the database doesn't exist and we're not in read-only mode, try to create it
105
+ if "database does not exist" in str(e) and not self._read_only:
106
+ logger.info("S3 database doesn't exist, attempting to create it...")
107
+ try:
108
+ # Create a new database at the S3 location
109
+ conn.execute(f"ATTACH '{self.db_path}' AS s3db;")
110
+ conn.execute("USE s3db;")
111
+ logger.info(f"✅ Created new S3 database at {self.db_path}")
112
+ except Exception as create_error:
113
+ logger.error(f"Failed to create S3 database: {create_error}")
114
+ raise
115
+ else:
116
+ raise
117
+
118
+ return conn
119
+
56
120
  conn = duckdb.connect(
57
121
  self.db_path,
58
122
  config={"custom_user_agent": f"mcp-server-motherduck/{SERVER_VERSION}"},
@@ -65,8 +129,12 @@ class DatabaseClient:
65
129
 
66
130
  def _resolve_db_path_type(
67
131
  self, db_path: str, motherduck_token: str | None = None, saas_mode: bool = False
68
- ) -> tuple[str, Literal["duckdb", "motherduck"]]:
132
+ ) -> tuple[str, Literal["duckdb", "motherduck", "s3"]]:
69
133
  """Resolve and validate the database path"""
134
+ # Handle S3 paths
135
+ if db_path.startswith("s3://"):
136
+ return db_path, "s3"
137
+
70
138
  # Handle MotherDuck paths
71
139
  if db_path.startswith("md:"):
72
140
  if motherduck_token:
@@ -102,7 +170,7 @@ class DatabaseClient:
102
170
 
103
171
  def _execute(self, query: str) -> str:
104
172
  if self.conn is None:
105
- # open short lived readonly connection, run query, close connection, return result
173
+ # open short lived readonly connection for local DuckDB, run query, close connection, return result
106
174
  conn = duckdb.connect(
107
175
  self.db_path,
108
176
  config={"custom_user_agent": f"mcp-server-motherduck/{SERVER_VERSION}"},