snowflake-mcp 0.1.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.
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: snowflake-mcp
3
+ Version: 0.1.0
4
+ Summary: A Snowflake MCP client for Python
5
+ Requires-Python: >=3.14
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: dotenv>=0.9.9
8
+ Requires-Dist: fastmcp>=3.4.2
9
+ Requires-Dist: snowflake-connector-python[pandas]>=4.6.0
File without changes
@@ -0,0 +1,22 @@
1
+ [project]
2
+ name = "snowflake-mcp"
3
+ version = "0.1.0"
4
+ description = "A Snowflake MCP client for Python"
5
+ readme = "README.md"
6
+ requires-python = ">=3.14"
7
+ dependencies = [
8
+ "dotenv>=0.9.9",
9
+ "fastmcp>=3.4.2",
10
+ "snowflake-connector-python[pandas]>=4.6.0",
11
+ ]
12
+
13
+
14
+ [build-system]
15
+ requires = ["setuptools>=65.5.0", "wheel"]
16
+ build-backend = "setuptools.build_meta"
17
+
18
+ [tools.setuptools.packages.find]
19
+ where = ["src"]
20
+
21
+ [project.scripts]
22
+ snowflake-mcp = "snowflake_mcp.main:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ from snowflake_mcp import mcp
2
+
3
+ if __name__ == "__main__":
4
+ mcp.run(transport="stdio")
@@ -0,0 +1,115 @@
1
+ from snowflake.connector import connect
2
+ from typing import Optional
3
+ from snowflake.connector import SnowflakeConnection
4
+ from dotenv import load_dotenv
5
+ import os
6
+ from fastmcp import FastMCP
7
+
8
+ mcp = FastMCP("snowflake-mcp", instructions="version: 0.1.0, This is a Snowflake MCP that can execute SQL queries on a Snowflake database.")
9
+
10
+ load_dotenv() # Load environment variables from .env file
11
+
12
+ def get_query_type(sql):
13
+ first_word = sql.strip().split()[0].upper()
14
+
15
+ ddl = {
16
+ "CREATE", "ALTER", "DROP", "TRUNCATE",
17
+ "RENAME", "COMMENT"
18
+ }
19
+
20
+ dml = {
21
+ "INSERT", "UPDATE", "DELETE", "MERGE", "COPY"
22
+ }
23
+
24
+ query = {
25
+ "SELECT", "SHOW", "DESCRIBE", "DESC", "EXPLAIN"
26
+ }
27
+
28
+ tcl = {
29
+ "COMMIT", "ROLLBACK"
30
+ }
31
+
32
+ dcl = {
33
+ "GRANT", "REVOKE"
34
+ }
35
+
36
+ if first_word in ddl:
37
+ return "DDL"
38
+ elif first_word in dml:
39
+ return "DML"
40
+ elif first_word in dcl:
41
+ return "DCL"
42
+ elif first_word in tcl:
43
+ return "TCL"
44
+ elif first_word in query:
45
+ return "QUERY"
46
+
47
+ return "UNKNOWN"
48
+ def get_snowflake_connection(user: str, password: str, account: str, warehouse: Optional[str] = "COMPUTE_WH", role: Optional[str] = "PUBLIC", database: Optional[str] = "SNOWFLAKE_SAMPLE_DATA", schema: Optional[str] = "INFORMATION_SCHEMA") -> SnowflakeConnection:
49
+ """
50
+ Establishes a connection to a Snowflake database.
51
+
52
+ Parameters:
53
+ user (str): The username for the Snowflake account.
54
+ password (str): The password for the Snowflake account.
55
+ account (str): The Snowflake account identifier.
56
+ warehouse (str): The name of the warehouse to use.
57
+ role (str): The role to use for the connection.
58
+ database (str): The name of the database to connect to.
59
+ schema (str): The name of the schema to use.
60
+
61
+ Returns:
62
+ connection: A Snowflake connection object.
63
+ """
64
+ try:
65
+ connection = connect(
66
+ user=user,
67
+ password=password,
68
+ account=account,
69
+ warehouse=warehouse,
70
+ role=role,
71
+ database=database,
72
+ schema=schema
73
+ )
74
+ return connection
75
+ except Exception as e:
76
+ print(f"Error connecting to Snowflake: {e}")
77
+ return None
78
+
79
+
80
+ @mcp.tool()
81
+ def execute_query(query: str):
82
+ """
83
+ Executes a SQL query on the Snowflake database.
84
+
85
+ Parameters:
86
+ connection (SnowflakeConnection): The Snowflake connection object.
87
+ query (str): The SQL query to execute.
88
+
89
+ Returns:
90
+ result: The result of the query execution.
91
+ """
92
+
93
+ if get_query_type(query) != "QUERY":
94
+ print("Only SELECT queries are allowed.")
95
+ return None
96
+ try:
97
+ connection = get_snowflake_connection(
98
+ user=os.getenv("SNOWFLAKE_USER"),
99
+ password=os.getenv("SNOWFLAKE_PASSWORD"),
100
+ account=os.getenv("SNOWFLAKE_ACCOUNT"),
101
+ )
102
+ print(connection)
103
+ cursor = connection.cursor()
104
+ cursor.execute(query)
105
+ result = cursor.fetchall()
106
+ cursor.close()
107
+ return result
108
+ except Exception as e:
109
+ print(f"Error executing query: {e}")
110
+ return None
111
+
112
+
113
+
114
+ if __name__ == "__main__":
115
+ mcp.run(transport="stdio")
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: snowflake-mcp
3
+ Version: 0.1.0
4
+ Summary: A Snowflake MCP client for Python
5
+ Requires-Python: >=3.14
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: dotenv>=0.9.9
8
+ Requires-Dist: fastmcp>=3.4.2
9
+ Requires-Dist: snowflake-connector-python[pandas]>=4.6.0
@@ -0,0 +1,12 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/__init__.py
4
+ src/snowflake-mcp/__init__.py
5
+ src/snowflake-mcp/main.py
6
+ src/snowflake-mcp/snowflake_mcp.py
7
+ src/snowflake_mcp.egg-info/PKG-INFO
8
+ src/snowflake_mcp.egg-info/SOURCES.txt
9
+ src/snowflake_mcp.egg-info/dependency_links.txt
10
+ src/snowflake_mcp.egg-info/entry_points.txt
11
+ src/snowflake_mcp.egg-info/requires.txt
12
+ src/snowflake_mcp.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ snowflake-mcp = snowflake_mcp.main:main
@@ -0,0 +1,3 @@
1
+ dotenv>=0.9.9
2
+ fastmcp>=3.4.2
3
+ snowflake-connector-python[pandas]>=4.6.0
@@ -0,0 +1,2 @@
1
+ __init__
2
+ snowflake-mcp