Skip to content

Add Multi-Database-Schema Support and Improved Configuration #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
71 changes: 49 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,23 @@ The server offers six core tools:
- Returns: Confirmation of table creation

#### Schema Tools
- `list_databases`
- Get a list of all databases in the Snowflake instance.
- No input required
- Returns: Array of database names.

- `list_schemas`
- Get a list of all schemas in a specific database.
- Input:
- `database` (string): Name of the database.
- Returns: Array of schema names.

- `list_tables`
- Get a list of all tables in the database
- No input required
- Returns: Array of table names
- Get a list of all tables in a specific database and schema.
- Input:
- `database` (string): Name of the database.
- `schema` (string): Name of the schema.
- Returns: Array of table metadata.

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

### Installing via UVX
### Installing via UVX

```python
# Add the server to your claude_desktop_config.json
# Add the server to your claude_desktop_config.json (Claude -> Settings -> Developer -> Edit Config)
"mcpServers": {
"snowflake_pip": {
"command": "uvx",
Expand Down Expand Up @@ -99,35 +112,49 @@ npx -y @smithery/cli install mcp_snowflake_server --client claude
```

### Installing locally

1. Install [Claude AI Desktop App](https://claude.ai/download)

2. Install `uv` by:
```
curl -LsSf https://astral.sh/uv/install.sh | sh
```

3. Create a `.env` file using the following template under this dir
```
SNOWFLAKE_USER="[email protected]"
SNOWFLAKE_ACCOUNT="XXX"
SNOWFLAKE_ROLE="XXX" # This determines the access scope of the MCP
SNOWFLAKE_DATABASE="XXX" # This doesn't affect the MCP's access scope
SNOWFLAKE_SCHEMA="XXX" # This doesn't affect the MCP's access scope
SNOWFLAKE_WAREHOUSE="XXX"
SNOWFLAKE_PASSWORD="XXX"
# Alternatively, you can use external browser for authentication without specifying the password
# SNOWFLAKE_AUTHENTICATOR="externalbrowser"
```

4. [Optional] Modify the `exclude_patterns` in `runtime_config.json` to filter out the resources you want to exclude.

5. Test locally using
```
uv --directory /absolute/path/to/mcp_snowflake_server run mcp_snowflake_server
```

6. Add the server to your `claude_desktop_config.json` (Claude -> Settings -> Developer -> Edit Config)
```python
# Add the server to your claude_desktop_config.json
"mcpServers": {
"snowflake_local": {
"command": "uv",
"command": "/absolute/path/to/uv", # obtained by using `which uv`
"args": [
"--directory",
"/absolute/path/to/mcp_snowflake_server",
"run",
"mcp_snowflake_server",
"--account",
"the_account",
"--warehouse",
"the_warehouse",
"--user",
"the_user",
"--password",
"their_password",
"--role",
"the_role"
"--database",
"the_database",
"--schema",
"the_schema",
# Optionally: "--allow_write" (but not recommended)
# Optionally: "--log_dir", "/absolute/path/to/logs"
# Optionally: "--log_level", "DEBUG"/"INFO"/"WARNING"/"ERROR"/"CRITICAL"
# Optionally: "--exclude_tools", "{tool name}", ["{other tool name}"]
]
}
}
```
```
14 changes: 14 additions & 0 deletions runtime_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"exclude_patterns": {
"databases": [
"temp"
],
"schemas": [
"temp",
"information_schema"
],
"tables": [
"temp"
]
}
}
6 changes: 3 additions & 3 deletions src/mcp_snowflake_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def parse_args():
"--prefetch",
action="store_true",
dest="prefetch",
default=True,
default=False,
help="Prefetch table descriptions (when enabled, list_tables and describe_table are disabled)",
)
parser.add_argument(
Expand Down Expand Up @@ -88,10 +88,10 @@ def main():

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

asyncio.run(
server.main(
Expand Down
Loading