mcp-server-motherduck 0.4.1__py3-none-any.whl → 0.4.2__py3-none-any.whl
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.
Potentially problematic release.
This version of mcp-server-motherduck might be problematic. Click here for more details.
- mcp_server_motherduck/__init__.py +6 -0
- mcp_server_motherduck/server.py +11 -4
- {mcp_server_motherduck-0.4.1.dist-info → mcp_server_motherduck-0.4.2.dist-info}/METADATA +137 -19
- mcp_server_motherduck-0.4.2.dist-info/RECORD +8 -0
- mcp_server_motherduck-0.4.1.dist-info/RECORD +0 -8
- {mcp_server_motherduck-0.4.1.dist-info → mcp_server_motherduck-0.4.2.dist-info}/WHEEL +0 -0
- {mcp_server_motherduck-0.4.1.dist-info → mcp_server_motherduck-0.4.2.dist-info}/entry_points.txt +0 -0
- {mcp_server_motherduck-0.4.1.dist-info → mcp_server_motherduck-0.4.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -26,6 +26,11 @@ def main():
|
|
|
26
26
|
default=None,
|
|
27
27
|
help="(Default: env var `HOME`) Home directory for DuckDB",
|
|
28
28
|
)
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"--saas-mode",
|
|
31
|
+
action="store_true",
|
|
32
|
+
help="Flag for connecting to MotherDuck in SaaS mode",
|
|
33
|
+
)
|
|
29
34
|
# This is experimental and will change in the future
|
|
30
35
|
parser.add_argument(
|
|
31
36
|
"--result-format",
|
|
@@ -45,6 +50,7 @@ def main():
|
|
|
45
50
|
motherduck_token=args.motherduck_token,
|
|
46
51
|
result_format=args.result_format,
|
|
47
52
|
home_dir=args.home_dir,
|
|
53
|
+
saas_mode=args.saas_mode,
|
|
48
54
|
)
|
|
49
55
|
)
|
|
50
56
|
|
mcp_server_motherduck/server.py
CHANGED
|
@@ -12,7 +12,7 @@ from mcp.server.models import InitializationOptions
|
|
|
12
12
|
from .prompt import PROMPT_TEMPLATE
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
SERVER_VERSION = "0.4.
|
|
15
|
+
SERVER_VERSION = "0.4.2"
|
|
16
16
|
|
|
17
17
|
logger = logging.getLogger("mcp_server_motherduck")
|
|
18
18
|
|
|
@@ -24,9 +24,10 @@ class DatabaseClient:
|
|
|
24
24
|
motherduck_token: str | None = None,
|
|
25
25
|
result_format: Literal["markdown", "duckbox", "text"] = "markdown",
|
|
26
26
|
home_dir: str | None = None,
|
|
27
|
+
saas_mode: bool = False,
|
|
27
28
|
):
|
|
28
29
|
self.db_path, self.db_type = self._resolve_db_path_type(
|
|
29
|
-
db_path, motherduck_token
|
|
30
|
+
db_path, motherduck_token, saas_mode
|
|
30
31
|
)
|
|
31
32
|
logger.info(f"Database client initialized in `{self.db_type}` mode")
|
|
32
33
|
|
|
@@ -52,14 +53,18 @@ class DatabaseClient:
|
|
|
52
53
|
return conn
|
|
53
54
|
|
|
54
55
|
def _resolve_db_path_type(
|
|
55
|
-
self, db_path: str, motherduck_token: str | None = None
|
|
56
|
+
self, db_path: str, motherduck_token: str | None = None, saas_mode: bool = False
|
|
56
57
|
) -> tuple[str, Literal["duckdb", "motherduck"]]:
|
|
57
58
|
"""Resolve and validate the database path"""
|
|
58
59
|
# Handle MotherDuck paths
|
|
59
60
|
if db_path.startswith("md:"):
|
|
60
61
|
if motherduck_token:
|
|
61
62
|
logger.info("Using MotherDuck token to connect to database `md:`")
|
|
62
|
-
|
|
63
|
+
if saas_mode:
|
|
64
|
+
logger.info("Connecting to MotherDuck in SaaS mode")
|
|
65
|
+
return f"{db_path}?motherduck_token={motherduck_token}&saas_mode=true", "motherduck"
|
|
66
|
+
else:
|
|
67
|
+
return f"{db_path}?motherduck_token={motherduck_token}", "motherduck"
|
|
63
68
|
elif os.getenv("motherduck_token"):
|
|
64
69
|
logger.info(
|
|
65
70
|
"Using MotherDuck token from env to connect to database `md:`"
|
|
@@ -112,6 +117,7 @@ async def main(
|
|
|
112
117
|
motherduck_token: str | None = None,
|
|
113
118
|
result_format: Literal["markdown", "duckbox", "text"] = "markdown",
|
|
114
119
|
home_dir: str | None = None,
|
|
120
|
+
saas_mode: bool = False,
|
|
115
121
|
):
|
|
116
122
|
logger.info("Starting MotherDuck MCP Server")
|
|
117
123
|
server = Server("mcp-server-motherduck")
|
|
@@ -120,6 +126,7 @@ async def main(
|
|
|
120
126
|
result_format=result_format,
|
|
121
127
|
motherduck_token=motherduck_token,
|
|
122
128
|
home_dir=home_dir,
|
|
129
|
+
saas_mode=saas_mode,
|
|
123
130
|
)
|
|
124
131
|
|
|
125
132
|
logger.info("Registering handlers")
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp-server-motherduck
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: A MCP server for MotherDuck and local DuckDB
|
|
5
5
|
Author-email: tdoehmen <till@motherduck.com>
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Requires-Python: >=3.10
|
|
8
|
-
Requires-Dist: duckdb==1.2.
|
|
8
|
+
Requires-Dist: duckdb==1.2.2
|
|
9
9
|
Requires-Dist: mcp>=1.3.0
|
|
10
10
|
Requires-Dist: pandas>=2.0.0
|
|
11
11
|
Requires-Dist: tabulate>=0.9.0
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
|
|
14
|
-
# MotherDuck MCP Server
|
|
14
|
+
# MotherDuck's DuckDB MCP Server
|
|
15
15
|
|
|
16
|
-
An MCP server implementation that
|
|
16
|
+
An MCP server implementation that interacts with DuckDB and MotherDuck databases, providing SQL analytics capabilities to AI Assistants and IDEs.
|
|
17
17
|
|
|
18
18
|
## Features
|
|
19
19
|
|
|
20
|
-
- **Hybrid execution**: query data from
|
|
20
|
+
- **Hybrid execution**: query data from local DuckDB or/and cloud-based MotherDuck databases
|
|
21
21
|
- **Cloud storage integration**: access data stored in Amazon S3 or other cloud storage thanks to MotherDuck's integrations
|
|
22
22
|
- **Data sharing**: create and share databases
|
|
23
|
-
- **SQL analytics**: use DuckDB's SQL dialect to query any size of data directly from
|
|
23
|
+
- **SQL analytics**: use DuckDB's SQL dialect to query any size of data directly from your AI Assistant or IDE
|
|
24
24
|
- **Serverless architecture**: run analytics without needing to configure instances or clusters
|
|
25
25
|
|
|
26
26
|
## Components
|
|
@@ -35,7 +35,7 @@ The server provides one prompt:
|
|
|
35
35
|
|
|
36
36
|
The server offers one tool:
|
|
37
37
|
|
|
38
|
-
- `query`: Execute a SQL query on the
|
|
38
|
+
- `query`: Execute a SQL query on the DuckDB or MotherDuck database
|
|
39
39
|
- **Inputs**:
|
|
40
40
|
- `query` (string, required): The SQL query to execute
|
|
41
41
|
|
|
@@ -43,19 +43,49 @@ All interactions with both DuckDB and MotherDuck are done through writing SQL qu
|
|
|
43
43
|
|
|
44
44
|
## Getting Started
|
|
45
45
|
|
|
46
|
-
### Prerequisites
|
|
47
|
-
|
|
48
|
-
- A MotherDuck account (sign up at [motherduck.com](https://motherduck.com))
|
|
49
|
-
- A MotherDuck access token
|
|
46
|
+
### General Prerequisites
|
|
50
47
|
- `uv` installed, you can install it using `pip install uv` or `brew install uv`
|
|
51
48
|
|
|
52
|
-
If you plan to use
|
|
49
|
+
If you plan to use the MCP with Claude Desktop or any other MCP comptabile client, the client need to be installed.
|
|
50
|
+
|
|
51
|
+
### Prerequisites for DuckDB
|
|
52
|
+
|
|
53
|
+
- No prerequisites. The MCP server can create an in-memory database on-the-fly
|
|
54
|
+
- Or connect to an existing local DuckDB database file , or one stored on remote object storage (e.g., AWS S3).
|
|
55
|
+
|
|
56
|
+
See [Connect to local DuckDB](#connect-to-local-duckdb).
|
|
57
|
+
|
|
58
|
+
### Prerequisites for MotherDuck
|
|
59
|
+
|
|
60
|
+
- Sign up for a [MotherDuck account](https://app.motherduck.com/?auth_flow=signup)
|
|
61
|
+
- Generate an access token via the [MotherDuck UI](https://app.motherduck.com/settings/tokens?auth_flow=signup)
|
|
62
|
+
- Store the token securely for use in the configuration
|
|
53
63
|
|
|
54
|
-
###
|
|
64
|
+
### Usage with Cursor
|
|
55
65
|
|
|
56
|
-
1.
|
|
57
|
-
|
|
58
|
-
|
|
66
|
+
1. Install Cursor from [cursor.com/downloads](https://www.cursor.com/downloads) if you haven't already
|
|
67
|
+
|
|
68
|
+
2. Open Cursor:
|
|
69
|
+
|
|
70
|
+
- To set it up globally for the first time, go to Settings->MCP and click on "+ Add new global MCP server".
|
|
71
|
+
- This will open a `mcp.json` file to which you add the following configuration:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"mcpServers": {
|
|
76
|
+
"mcp-server-motherduck": {
|
|
77
|
+
"command": "uvx",
|
|
78
|
+
"args": [
|
|
79
|
+
"mcp-server-motherduck",
|
|
80
|
+
"--db-path",
|
|
81
|
+
"md:",
|
|
82
|
+
"--motherduck-token",
|
|
83
|
+
"<YOUR_MOTHERDUCK_TOKEN_HERE>"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
59
89
|
|
|
60
90
|
### Usage with VS Code
|
|
61
91
|
|
|
@@ -140,7 +170,7 @@ Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace
|
|
|
140
170
|
"md:",
|
|
141
171
|
"--motherduck-token",
|
|
142
172
|
"<YOUR_MOTHERDUCK_TOKEN_HERE>"
|
|
143
|
-
]
|
|
173
|
+
]
|
|
144
174
|
}
|
|
145
175
|
}
|
|
146
176
|
}
|
|
@@ -152,9 +182,73 @@ Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace
|
|
|
152
182
|
- Replace `YOUR_HOME_FOLDER_PATH` with the path to your home directory (needed by DuckDB for file operations). For example, on macOS, it would be `/Users/your_username`
|
|
153
183
|
- The `HOME` environment variable is required for DuckDB to function properly.
|
|
154
184
|
|
|
185
|
+
## Securing your MCP Server when querying MotherDuck
|
|
186
|
+
|
|
187
|
+
If the MCP server is exposed to third parties and should only have read access to data, we recommend using a read scaling token and running the MCP server in SaaS mode.
|
|
188
|
+
|
|
189
|
+
**Read Scaling Tokens** are special access tokens that enable scalable read operations by allowing up to 4 concurrent read replicas, improving performance for multiple end users while *restricting write capabilities*.
|
|
190
|
+
Refer to the [Read Scaling documentation](https://motherduck.com/docs/key-tasks/authenticating-and-connecting-to-motherduck/read-scaling/#creating-a-read-scaling-token) to learn how to create a read-scaling token.
|
|
191
|
+
|
|
192
|
+
**SaaS Mode** in MotherDuck enhances security by restricting it's access to local files, databases, extensions, and configurations, making it ideal for third-party tools that require stricter environment protection. Learn more about it in the [SaaS Mode documentation](https://motherduck.com/docs/key-tasks/authenticating-and-connecting-to-motherduck/authenticating-to-motherduck/#authentication-using-saas-mode).
|
|
193
|
+
|
|
194
|
+
**Secure Configuration**
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"mcpServers": {
|
|
198
|
+
"mcp-server-motherduck": {
|
|
199
|
+
"command": "uvx",
|
|
200
|
+
"args": [
|
|
201
|
+
"mcp-server-motherduck",
|
|
202
|
+
"--db-path",
|
|
203
|
+
"md:",
|
|
204
|
+
"--motherduck-token",
|
|
205
|
+
"<YOUR_READ_SCALING_TOKEN_HERE>",
|
|
206
|
+
"--saas-mode"
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Connect to local DuckDB
|
|
214
|
+
|
|
215
|
+
To connect to a local DuckDB, instead of using the MotherDuck token, specify the path to your local DuckDB database file or use `:memory:` for an in-memory database.
|
|
216
|
+
|
|
217
|
+
In-memory database:
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"mcpServers": {
|
|
221
|
+
"mcp-server-motherduck": {
|
|
222
|
+
"command": "uvx",
|
|
223
|
+
"args": [
|
|
224
|
+
"mcp-server-motherduck",
|
|
225
|
+
"--db-path",
|
|
226
|
+
":memory:"
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Local DuckDB file:
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"mcpServers": {
|
|
237
|
+
"mcp-server-motherduck": {
|
|
238
|
+
"command": "uvx",
|
|
239
|
+
"args": [
|
|
240
|
+
"mcp-server-motherduck",
|
|
241
|
+
"--db-path",
|
|
242
|
+
"/path/to/your/local.db"
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
155
249
|
## Example Queries
|
|
156
250
|
|
|
157
|
-
Once configured, you can ask Claude to run queries like:
|
|
251
|
+
Once configured, you can e.g. ask Claude to run queries like:
|
|
158
252
|
|
|
159
253
|
- "Create a new database and table in MotherDuck"
|
|
160
254
|
- "Query data from my local CSV file"
|
|
@@ -195,7 +289,7 @@ If you don't specify a database path but have set the `motherduck_token` environ
|
|
|
195
289
|
|
|
196
290
|
## Running in SSE mode
|
|
197
291
|
|
|
198
|
-
The server could also be
|
|
292
|
+
The server could also be running SSE mode using `supergateway` by running the following command:
|
|
199
293
|
|
|
200
294
|
```bash
|
|
201
295
|
npx -y supergateway --stdio "uvx mcp-server-motherduck --db-path md: --motherduck-token <your_motherduck_token>"
|
|
@@ -203,6 +297,30 @@ npx -y supergateway --stdio "uvx mcp-server-motherduck --db-path md: --motherduc
|
|
|
203
297
|
|
|
204
298
|
And you can point your clients such as Claude Desktop, Cursor to this endpoint.
|
|
205
299
|
|
|
300
|
+
## Development configuration
|
|
301
|
+
|
|
302
|
+
To run the server from a local development environment, use the following configuration:
|
|
303
|
+
|
|
304
|
+
```json
|
|
305
|
+
{
|
|
306
|
+
"mcpServers": {
|
|
307
|
+
"mcp-server-motherduck": {
|
|
308
|
+
"command": "uv",
|
|
309
|
+
"args": [
|
|
310
|
+
"--directory",
|
|
311
|
+
"/path/to/your/local/mcp-server-motherduck",
|
|
312
|
+
"run",
|
|
313
|
+
"mcp-server-motherduck",
|
|
314
|
+
"--db-path",
|
|
315
|
+
"md:",
|
|
316
|
+
"--motherduck-token",
|
|
317
|
+
"<YOUR_MOTHERDUCK_TOKEN_HERE>"
|
|
318
|
+
]
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
206
324
|
## Troubleshooting
|
|
207
325
|
|
|
208
326
|
- If you encounter connection issues, verify your MotherDuck token is correct
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
mcp_server_motherduck/__init__.py,sha256=dugvMESmREMXUK0u7gRBLOQFFz29RhR7C3DemivAWo4,1826
|
|
2
|
+
mcp_server_motherduck/prompt.py,sha256=P7BrmhVXwDkPeSHQ3f25WMP6lpBpN2BxDzYPOQ3fxX8,56699
|
|
3
|
+
mcp_server_motherduck/server.py,sha256=Z_jDV_CgodFB8JpBYxB8H0iHRHulg-y86GvTC5Szkjc,9446
|
|
4
|
+
mcp_server_motherduck-0.4.2.dist-info/METADATA,sha256=HmnpB0LPxj2s-Nb-Sec_08VLH3K0mLAQZ3pv37xH7zw,11366
|
|
5
|
+
mcp_server_motherduck-0.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
6
|
+
mcp_server_motherduck-0.4.2.dist-info/entry_points.txt,sha256=dRTgcvWJn40bz0PVuKPylK6w92cFN32lwunZOgo5j4s,69
|
|
7
|
+
mcp_server_motherduck-0.4.2.dist-info/licenses/LICENSE,sha256=Tj68w9jCiceFKTvZ3jET-008NjhozcQMXpm-fyL9WUI,1067
|
|
8
|
+
mcp_server_motherduck-0.4.2.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
mcp_server_motherduck/__init__.py,sha256=_HXXeC7-S1nr4oaNEQKt_TKJrdrS_1iWRt557_pX6kI,1642
|
|
2
|
-
mcp_server_motherduck/prompt.py,sha256=P7BrmhVXwDkPeSHQ3f25WMP6lpBpN2BxDzYPOQ3fxX8,56699
|
|
3
|
-
mcp_server_motherduck/server.py,sha256=gu00iJLnTNNxyC5UHA7Xt_7G_5iv32IVCi5RptjcCyk,9085
|
|
4
|
-
mcp_server_motherduck-0.4.1.dist-info/METADATA,sha256=39Ru2YTcZDBCwr4R5T0bBcbs1hYLYlsMRM4csQGk4hg,8006
|
|
5
|
-
mcp_server_motherduck-0.4.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
6
|
-
mcp_server_motherduck-0.4.1.dist-info/entry_points.txt,sha256=dRTgcvWJn40bz0PVuKPylK6w92cFN32lwunZOgo5j4s,69
|
|
7
|
-
mcp_server_motherduck-0.4.1.dist-info/licenses/LICENSE,sha256=Tj68w9jCiceFKTvZ3jET-008NjhozcQMXpm-fyL9WUI,1067
|
|
8
|
-
mcp_server_motherduck-0.4.1.dist-info/RECORD,,
|
|
File without changes
|
{mcp_server_motherduck-0.4.1.dist-info → mcp_server_motherduck-0.4.2.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{mcp_server_motherduck-0.4.1.dist-info → mcp_server_motherduck-0.4.2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|