|
1 | | -# Wetlands MCP Server |
2 | | - |
3 | | -An MCP server specialized for analyzing wetlands datasets using DuckDB. This server provides AI assistants and IDEs with the ability to query and analyze comprehensive wetlands data, including spatial information, temporal trends, and ecological metrics. |
4 | | - |
5 | | -This server is based on [MotherDuck's DuckDB MCP Server](https://github.com/motherduckdb/mcp-server-motherduck) and extends it with wetlands-specific prompts and context. |
6 | | - |
7 | | -## Features |
8 | | - |
9 | | -- **Wetlands-specific**: Pre-configured prompts and context for wetlands data analysis |
10 | | -- **Hybrid execution**: Query data from local DuckDB or cloud-based MotherDuck databases |
11 | | -- **Cloud storage integration**: Access wetlands data stored in Amazon S3 or other cloud storage |
12 | | -- **Spatial analytics**: Leverage DuckDB's spatial extensions for geospatial wetlands analysis |
13 | | -- **SQL analytics**: Use DuckDB's SQL dialect to query wetlands datasets directly from your AI Assistant or IDE |
14 | | -- **Serverless architecture**: Run analytics without needing to configure instances or clusters |
15 | | - |
16 | | -## Components |
17 | | - |
18 | | -### Prompts |
19 | | - |
20 | | -The server accepts custom prompts with --custom-prompt argument. |
21 | | - |
22 | | -### Tools |
23 | | - |
24 | | -The server offers one tool: |
25 | | - |
26 | | -- `query`: Execute a SQL query on the DuckDB or MotherDuck database |
27 | | - - **Inputs**: |
28 | | - - `query` (string, required): The SQL query to execute |
29 | | - |
30 | | -All interactions with both DuckDB and MotherDuck are done through writing SQL queries. |
31 | | - |
32 | | -**Result Limiting**: Query results are automatically limited to prevent using up too much context: |
33 | | -- Maximum 1024 rows by default (configurable with `--max-rows`) |
34 | | -- Maximum 50,000 characters by default (configurable with `--max-chars`) |
35 | | -- Truncated responses include a note about truncation |
36 | | - |
37 | | -## Command Line Parameters |
38 | | - |
39 | | -The MCP server supports the following parameters: |
40 | | - |
41 | | -| Parameter | Type | Default | Description | |
42 | | -|-----------|------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
43 | | -| `--transport` | Choice | `stdio` | Transport type. Options: `stdio`, `sse`, `stream` | |
44 | | -| `--port` | Integer | `8000` | Port to listen on for sse and stream transport mode | |
45 | | -| `--host` | String | `127.0.0.1` | Host to bind the MCP server for sse and stream transport mode | |
46 | | -| `--db-path` | String | `md:` | Path to local DuckDB database file, MotherDuck database, or S3 URL (e.g., `s3://bucket/path/to/db.duckdb`) | |
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 | | -| `--home-dir` | String | `None` | Home directory for DuckDB (uses `HOME` env var by default) |
49 | | -| `--json-response` | Flag | `False` | Enable JSON responses for HTTP stream. Only supported for `stream` transport | |
50 | | -| `--max-rows` | Integer | `1024` | Maximum number of rows to return from queries. | |
51 | | -| `--max-chars` | Integer | `50000` | Maximum number of characters in query results. | |
52 | | -| `--query-timeout` | Integer | `-1` | Query execution timeout in seconds. Set to -1 to disable timeout (default). | |
53 | | -| `--custom-prompt` | String | `None` | Path to a custom prompt markdown file. Use this to provide domain-specific context instead of the built-in wetlands data prompt. The custom prompt will be combined with the DuckDB prompt. | |
54 | | - |
55 | | -### Quick Usage Examples |
56 | | - |
57 | | -```bash |
58 | | -# Connect to local DuckDB file in read-only mode |
59 | | -uvx mcp-data-server --db-path /path/to/local.db --read-only |
60 | | - |
61 | | -# Connect to local DuckDB file in read-only mode |
62 | | -uvx mcp-data-server --db-path /path/to/local.db --read-only |
63 | | - |
64 | | -# Customize result truncation limits for large wetlands queries |
65 | | -uvx mcp-data-server --max-rows 2048 --max-chars 100000 |
66 | | - |
67 | | -# Enable query timeout (5 minutes) for complex spatial queries |
68 | | -uvx mcp-data-server --query-timeout 300 |
69 | | - |
70 | | -# Use a custom prompt file for different datasets |
71 | | -uvx mcp-data-server --custom-prompt /path/to/custom-prompt.md |
72 | | -``` |
73 | | - |
74 | | -## Getting Started |
75 | | - |
76 | | -### General Prerequisites |
77 | | - |
78 | | -- `uv` installed, you can install it using `pip install uv` or `brew install uv` |
79 | | - |
80 | | -If you plan to use the MCP with Claude Desktop or any other MCP compatible client, the client needs to be installed. |
81 | | - |
82 | | -### Development Setup |
83 | | - |
84 | | -1. Clone the repository |
85 | | -2. Create and activate a virtual environment: |
86 | | -```bash |
87 | | -uv venv |
88 | | -source .venv/bin/activate # On Linux/Mac |
89 | | -``` |
90 | | - |
91 | | -3. Install the package in development mode: |
92 | | -```bash |
93 | | -uv pip install -e . |
94 | | -``` |
95 | | - |
96 | | -4. Install the MCP Python SDK for testing: |
97 | | -```bash |
98 | | -uv pip install mcp |
99 | | -``` |
100 | | - |
101 | | -5. Run the test suite: |
102 | | -```bash |
103 | | -python3 test_server.py |
104 | | -``` |
105 | | - |
106 | | -### Prerequisites for DuckDB |
107 | | - |
108 | | -- No prerequisites. The MCP server can create an in-memory database on-the-fly |
109 | | -- Or connect to an existing local DuckDB database file, or one stored on remote object storage (e.g., AWS S3) |
110 | | -- Wetlands datasets can be loaded from S3 or other sources as needed |
111 | | - |
112 | | - |
113 | | -#### Manual Installation |
114 | | - |
115 | | - |
116 | | -Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace. This will allow you to share the configuration with others. |
117 | | - |
118 | | -```json |
119 | | -{ |
120 | | - "servers": { |
121 | | - "wetlands": { |
122 | | - "command": "uvx", |
123 | | - "args": [ |
124 | | - "mcp-data-server" |
125 | | - ] |
126 | | - } |
127 | | - } |
128 | | -} |
129 | | -``` |
130 | | - |
131 | | -### Usage with Claude Code |
132 | | - |
133 | | -Claude Code supports MCP servers through CLI commands or JSON configuration. Add the server using a JSON configuration: |
134 | | - |
135 | | -```bash |
136 | | -claude mcp add-json mcp-data-server '{ |
137 | | - "command": "uvx", |
138 | | - "args": [ |
139 | | - "mcp-data-server", |
140 | | - "--db-path" |
141 | | - ] |
142 | | -}' |
143 | | -``` |
144 | | - |
145 | | -**Scoping Options**: |
146 | | -- Use `--local` (default) for project-specific configuration |
147 | | -- Use `--project` to share the configuration with your team via `.mcp.json` |
148 | | -- Use `--user` to make the server available across all your projects |
149 | | - |
150 | | - |
151 | | - |
152 | | -## Running in SSE mode |
153 | | - |
154 | | -The server can run in SSE mode in two ways: |
155 | | - |
156 | | -### Direct SSE mode |
157 | | - |
158 | | -Run the server directly in SSE mode using the `--transport sse` flag: |
159 | | - |
160 | | -```bash |
161 | | -uvx mcp-data-server --transport sse --port 8000 --db-path md: --motherduck-token <your_motherduck_token> |
162 | | -``` |
163 | | - |
164 | | -This will start the server listening on the specified port (default 8000) and you can point your clients directly to this endpoint. |
165 | | - |
166 | | -### Using supergateway |
167 | | - |
168 | | -Alternatively, you can run SSE mode using `supergateway`: |
169 | | - |
170 | | -```bash |
171 | | -npx -y supergateway --stdio "uvx mcp-data-server --db-path md: --motherduck-token <your_motherduck_token>" |
172 | | -``` |
173 | | - |
174 | | -Both methods allow you to point your clients such as Claude Desktop, Cursor to the SSE endpoint. |
175 | | - |
176 | | -## Development configuration |
177 | | - |
178 | | -To run the server from a local development environment, use the following configuration: |
179 | | - |
180 | | -```json |
181 | | - { |
182 | | - "mcpServers": { |
183 | | - "mcp-data-server": { |
184 | | - "command": "uv", |
185 | | - "args": [ |
186 | | - "--directory", |
187 | | - "/path/to/your/local/mcp-data-server", |
188 | | - "run", |
189 | | - "mcp-data-server", |
190 | | - "--db-path", |
191 | | - "md:", |
192 | | - "--motherduck-token", |
193 | | - "<YOUR_MOTHERDUCK_TOKEN_HERE>" |
194 | | - ] |
195 | | - } |
196 | | - } |
197 | | -} |
198 | | -``` |
199 | | - |
200 | | -## Troubleshooting |
201 | | - |
202 | | -- If you encounter connection issues, verify your MotherDuck token is correct |
203 | | -- For local file access problems, ensure the `--home-dir` parameter is set correctly |
204 | | -- Check that the `uvx` command is available in your PATH |
205 | | -- If you encounter `spawn uvx ENOENT` errors, try specifying the full path to `uvx` (output of `which uvx`) |
206 | | -- In version previous for v0.4.0 we used environment variables, now we use parameters |
207 | | - |
208 | | -## License |
209 | | - |
210 | | -This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository. |
211 | | - |
212 | | -## |
213 | | -mcp-name: io.github.boettiger-lab/mcp-data-server |
| 1 | +Minimal stdio-based server |
0 commit comments