Skip to content

Commit bee0595

Browse files
Merge pull request #11 from wenwu35/add-multi-db-schemas-support
Add Multi-Database-Schema Support and Improved Configuration
2 parents a64e093 + 09b9ef7 commit bee0595

File tree

4 files changed

+313
-54
lines changed

4 files changed

+313
-54
lines changed

README.md

+49-22
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,23 @@ The server offers six core tools:
3636
- Returns: Confirmation of table creation
3737

3838
#### Schema Tools
39+
- `list_databases`
40+
- Get a list of all databases in the Snowflake instance.
41+
- No input required
42+
- Returns: Array of database names.
43+
44+
- `list_schemas`
45+
- Get a list of all schemas in a specific database.
46+
- Input:
47+
- `database` (string): Name of the database.
48+
- Returns: Array of schema names.
49+
3950
- `list_tables`
40-
- Get a list of all tables in the database
41-
- No input required
42-
- Returns: Array of table names
51+
- Get a list of all tables in a specific database and schema.
52+
- Input:
53+
- `database` (string): Name of the database.
54+
- `schema` (string): Name of the schema.
55+
- Returns: Array of table metadata.
4356

4457
- `describe-table`
4558
- View column information for a specific table
@@ -66,10 +79,10 @@ To install Snowflake Server for Claude Desktop automatically via [Smithery](http
6679
npx -y @smithery/cli install mcp_snowflake_server --client claude
6780
```
6881

69-
### Installing via UVX
82+
### Installing via UVX
7083

7184
```python
72-
# Add the server to your claude_desktop_config.json
85+
# Add the server to your claude_desktop_config.json (Claude -> Settings -> Developer -> Edit Config)
7386
"mcpServers": {
7487
"snowflake_pip": {
7588
"command": "uvx",
@@ -99,35 +112,49 @@ npx -y @smithery/cli install mcp_snowflake_server --client claude
99112
```
100113

101114
### Installing locally
115+
116+
1. Install [Claude AI Desktop App](https://claude.ai/download)
117+
118+
2. Install `uv` by:
119+
```
120+
curl -LsSf https://astral.sh/uv/install.sh | sh
121+
```
122+
123+
3. Create a `.env` file using the following template under this dir
124+
```
125+
SNOWFLAKE_USER="[email protected]"
126+
SNOWFLAKE_ACCOUNT="XXX"
127+
SNOWFLAKE_ROLE="XXX" # This determines the access scope of the MCP
128+
SNOWFLAKE_DATABASE="XXX" # This doesn't affect the MCP's access scope
129+
SNOWFLAKE_SCHEMA="XXX" # This doesn't affect the MCP's access scope
130+
SNOWFLAKE_WAREHOUSE="XXX"
131+
SNOWFLAKE_PASSWORD="XXX"
132+
# Alternatively, you can use external browser for authentication without specifying the password
133+
# SNOWFLAKE_AUTHENTICATOR="externalbrowser"
134+
```
135+
136+
4. [Optional] Modify the `exclude_patterns` in `runtime_config.json` to filter out the resources you want to exclude.
137+
138+
5. Test locally using
139+
```
140+
uv --directory /absolute/path/to/mcp_snowflake_server run mcp_snowflake_server
141+
```
142+
143+
6. Add the server to your `claude_desktop_config.json` (Claude -> Settings -> Developer -> Edit Config)
102144
```python
103-
# Add the server to your claude_desktop_config.json
104145
"mcpServers": {
105146
"snowflake_local": {
106-
"command": "uv",
147+
"command": "/absolute/path/to/uv", # obtained by using `which uv`
107148
"args": [
108149
"--directory",
109150
"/absolute/path/to/mcp_snowflake_server",
110151
"run",
111152
"mcp_snowflake_server",
112-
"--account",
113-
"the_account",
114-
"--warehouse",
115-
"the_warehouse",
116-
"--user",
117-
"the_user",
118-
"--password",
119-
"their_password",
120-
"--role",
121-
"the_role"
122-
"--database",
123-
"the_database",
124-
"--schema",
125-
"the_schema",
126153
# Optionally: "--allow_write" (but not recommended)
127154
# Optionally: "--log_dir", "/absolute/path/to/logs"
128155
# Optionally: "--log_level", "DEBUG"/"INFO"/"WARNING"/"ERROR"/"CRITICAL"
129156
# Optionally: "--exclude_tools", "{tool name}", ["{other tool name}"]
130157
]
131158
}
132159
}
133-
```
160+
```

runtime_config.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"exclude_patterns": {
3+
"databases": [
4+
"temp"
5+
],
6+
"schemas": [
7+
"temp",
8+
"information_schema"
9+
],
10+
"tables": [
11+
"temp"
12+
]
13+
}
14+
}

src/mcp_snowflake_server/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def parse_args():
2121
"--prefetch",
2222
action="store_true",
2323
dest="prefetch",
24-
default=True,
24+
default=False,
2525
help="Prefetch table descriptions (when enabled, list_tables and describe_table are disabled)",
2626
)
2727
parser.add_argument(
@@ -88,10 +88,10 @@ def main():
8888

8989
assert (
9090
"database" in connection_args
91-
), 'You must provide the account identifier as "--database" argument or "SNOWFLAKE_DATABASE" environment variable. This MCP server can only operate on a single database.'
91+
), 'You must provide the account identifier as "--database" argument or "SNOWFLAKE_DATABASE" environment variable.'
9292
assert (
9393
"schema" in connection_args
94-
), 'You must provide the username as "--schema" argument or "SNOWFLAKE_SCHEMA" environment variable. This MCP server can only operate on a single schema.'
94+
), 'You must provide the username as "--schema" argument or "SNOWFLAKE_SCHEMA" environment variable.'
9595

9696
asyncio.run(
9797
server.main(

0 commit comments

Comments
 (0)