zaturn 0.1.7__py3-none-any.whl → 0.2.0__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.
Files changed (45) hide show
  1. zaturn/mcp/__init__.py +97 -0
  2. zaturn/studio/__init__.py +5 -0
  3. zaturn/studio/agent_wrapper.py +131 -0
  4. zaturn/studio/app.py +288 -0
  5. zaturn/studio/static/fira_code.ttf +0 -0
  6. zaturn/studio/static/inter_ital_var.ttf +0 -0
  7. zaturn/studio/static/inter_var.ttf +0 -0
  8. zaturn/studio/static/js/htmx-multi-swap.js +44 -0
  9. zaturn/studio/static/js/htmx.min.js +1 -0
  10. zaturn/studio/static/logo.png +0 -0
  11. zaturn/studio/static/logo.svg +10 -0
  12. zaturn/studio/static/noto_emoji.ttf +0 -0
  13. zaturn/studio/storage.py +85 -0
  14. zaturn/studio/templates/_shell.html +38 -0
  15. zaturn/studio/templates/ai_message.html +4 -0
  16. zaturn/studio/templates/c_settings_updated.html +1 -0
  17. zaturn/studio/templates/c_source_card.html +19 -0
  18. zaturn/studio/templates/chat.html +22 -0
  19. zaturn/studio/templates/css/style.css +406 -0
  20. zaturn/studio/templates/function_call.html +7 -0
  21. zaturn/studio/templates/loader.html +1 -0
  22. zaturn/studio/templates/manage_sources.html +45 -0
  23. zaturn/studio/templates/nav.html +5 -0
  24. zaturn/studio/templates/new_conversation.html +13 -0
  25. zaturn/studio/templates/settings.html +29 -0
  26. zaturn/studio/templates/setup_prompt.html +6 -0
  27. zaturn/studio/templates/user_message.html +4 -0
  28. zaturn/tools/__init__.py +13 -0
  29. zaturn/{config.py → tools/config.py} +7 -9
  30. zaturn/tools/core.py +97 -0
  31. zaturn/{query_utils.py → tools/query_utils.py} +52 -2
  32. zaturn/tools/visualizations.py +267 -0
  33. zaturn-0.2.0.dist-info/METADATA +128 -0
  34. zaturn-0.2.0.dist-info/RECORD +39 -0
  35. {zaturn-0.1.7.dist-info → zaturn-0.2.0.dist-info}/WHEEL +1 -1
  36. zaturn-0.2.0.dist-info/entry_points.txt +3 -0
  37. zaturn/__init__.py +0 -14
  38. zaturn/core.py +0 -140
  39. zaturn/visualizations.py +0 -155
  40. zaturn-0.1.7.dist-info/METADATA +0 -185
  41. zaturn-0.1.7.dist-info/RECORD +0 -12
  42. zaturn-0.1.7.dist-info/entry_points.txt +0 -2
  43. /zaturn/{example_data → tools/example_data}/all_pokemon_data.csv +0 -0
  44. {zaturn-0.1.7.dist-info → zaturn-0.2.0.dist-info}/licenses/LICENSE +0 -0
  45. {zaturn-0.1.7.dist-info → zaturn-0.2.0.dist-info}/top_level.txt +0 -0
zaturn/visualizations.py DELETED
@@ -1,155 +0,0 @@
1
- from fastmcp import FastMCP, Image
2
- import math
3
- import os
4
- import plotly.express as px
5
- import time
6
- from typing import Any, Union, Optional
7
- from zaturn import config, query_utils
8
-
9
-
10
- mcp = FastMCP("Zaturn Visualizations")
11
-
12
-
13
- def _fig_to_image(fig) -> Union[str, Image]:
14
- filepath = os.path.join(config.VISUALS_DIR, str(int(time.time())) + '.png')
15
- fig.write_image(filepath)
16
- if config.RETURN_IMAGES:
17
- return Image(path=filepath)
18
- else:
19
- return filepath
20
-
21
-
22
- # Relationships
23
-
24
- @mcp.tool()
25
- def scatter_plot(
26
- query_id: str,
27
- x: str,
28
- y: str,
29
- color: str = None
30
- ):
31
- """
32
- Make a scatter plot with the dataframe obtained from running SQL Query against source
33
- If this returns an image, display it. If it returns a file path, mention it.
34
- Args:
35
- query_id: Previously run query to use for plotting
36
- x: Column name from SQL result to use for x-axis
37
- y: Column name from SQL result to use for y-axis
38
- color: Optional; column name from SQL result to use for coloring the points, with color representing another dimension
39
- """
40
- df = query_utils.load_query(query_id)
41
- fig = px.scatter(df, x=x, y=y, color=color)
42
- fig.update_xaxes(autotickangles=[0, 45, 60, 90])
43
- return _fig_to_image(fig)
44
-
45
-
46
- @mcp.tool()
47
- def line_plot(
48
- query_id: str,
49
- x: str,
50
- y: str,
51
- color: str = None
52
- ):
53
- """
54
- Make a line plot with the dataframe obtained from running SQL Query against source
55
- Args:
56
- query_id: Previously run query to use for plotting
57
- x: Column name from SQL result to use for x-axis
58
- y: Column name from SQL result to use for y-axis
59
- color: Optional; column name from SQL result to use for drawing multiple colored lines representing another dimension
60
- """
61
- df = query_utils.load_query(query_id)
62
- fig = px.line(df, x=x, y=y, color=color)
63
- fig.update_xaxes(autotickangles=[0, 45, 60, 90])
64
- return _fig_to_image(fig)
65
-
66
-
67
- # Distributions
68
-
69
- @mcp.tool()
70
- def histogram(
71
- query_id: str,
72
- column: str,
73
- color: str = None,
74
- nbins: int = None
75
- ):
76
- """
77
- Make a histogram with a column of the dataframe obtained from running SQL Query against source
78
- Args:
79
- query_id: Previously run query to use for plotting
80
- column: Column name from SQL result to use for the histogram
81
- color: Optional; column name from SQL result to use for drawing multiple colored histograms representing another dimension
82
- nbins: Optional; number of bins
83
- """
84
- df = query_utils.load_query(query_id)
85
- fig = px.histogram(df, x=column, color=color, nbins=nbins)
86
- fig.update_xaxes(autotickangles=[0, 45, 60, 90])
87
- return _fig_to_image(fig)
88
-
89
- # Categorical
90
-
91
- @mcp.tool()
92
- def strip_plot(
93
- query_id: str,
94
- x: str,
95
- y: str = None,
96
- color: str = None
97
- ):
98
- """
99
- Make a strip plot with the dataframe obtained from running SQL Query against source
100
- Args:
101
- query_id: Previously run query to use for plotting
102
- x: Column name from SQL result to use for x axis
103
- y: Optional; column name from SQL result to use for y axis
104
- color: Optional column name from SQL result to show multiple colored strips representing another dimension
105
- """
106
- df = query_utils.load_query(query_id)
107
- fig = px.strip(df, x=x, y=y, color=color)
108
- fig.update_xaxes(autotickangles=[0, 45, 60, 90])
109
- return _fig_to_image(fig)
110
-
111
-
112
- @mcp.tool()
113
- def box_plot(
114
- query_id: str,
115
- y: str,
116
- x: str = None,
117
- color: str = None
118
- ):
119
- """
120
- Make a box plot with the dataframe obtained from running SQL Query against source
121
- Args:
122
- query_id: Previously run query to use for plotting
123
- y: Column name from SQL result to use for y axis
124
- x: Optional; Column name from SQL result to use for x axis
125
- color: Optional column name from SQL result to show multiple colored bars representing another dimension
126
- """
127
- df = query_utils.load_query(query_id)
128
- fig = px.box(df, x=x, y=y, color=color)
129
- fig.update_xaxes(autotickangles=[0, 45, 60, 90])
130
- return _fig_to_image(fig)
131
-
132
-
133
- @mcp.tool()
134
- def bar_plot(
135
- query_id: str,
136
- x: str,
137
- y: str = None,
138
- color: str = None,
139
- orientation: str = 'v'
140
- ):
141
- """
142
- Make a bar plot with the dataframe obtained from running SQL Query against source
143
- Args:
144
- query_id: Previously run query to use for plotting
145
- x: Column name from SQL result to use for x axis
146
- y: Optional; column name from SQL result to use for y axis
147
- color: Optional column name from SQL result to use as a 3rd dimension by splitting each bar into colored sections
148
- orientation: Orientation of the box plot, use 'v' for vertical (default) and 'h' for horizontal. Be mindful of choosing the correct X and Y columns as per orientation
149
- """
150
- df = query_utils.load_query(query_id)
151
- fig = px.bar(df, x=x, y=y, color=color, orientation=orientation)
152
- fig.update_xaxes(autotickangles=[0, 45, 60, 90])
153
- return _fig_to_image(fig)
154
-
155
-
@@ -1,185 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: zaturn
3
- Version: 0.1.7
4
- Summary: AI Data Analysis MCP
5
- Author-email: Karthik Devan <krtdvn@gmail.com>
6
- Maintainer-email: Karthik Devan <krtdvn@gmail.com>
7
- Project-URL: Homepage, https://github.com/kdqed/zaturn
8
- Project-URL: Issues, https://github.com/kdqed/zaturn/issues
9
- Requires-Python: >=3.11
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
12
- Requires-Dist: clickhouse-connect>=0.8.17
13
- Requires-Dist: cryptography>=44.0.2
14
- Requires-Dist: duckdb>=1.2.1
15
- Requires-Dist: fastmcp>=0.4.1
16
- Requires-Dist: kaleido==0.2.1
17
- Requires-Dist: pandas>=2.2.3
18
- Requires-Dist: platformdirs>=4.3.7
19
- Requires-Dist: plotly[express]>=6.0.1
20
- Requires-Dist: psycopg2-binary>=2.9.10
21
- Requires-Dist: pyarrow>=19.0.1
22
- Requires-Dist: pymysql>=1.1.1
23
- Requires-Dist: python-lsp-server>=1.12.2
24
- Requires-Dist: seaborn>=0.13.2
25
- Requires-Dist: setuptools>=78.1.0
26
- Requires-Dist: sqlalchemy>=2.0.40
27
- Requires-Dist: tabulate>=0.9.0
28
- Dynamic: license-file
29
-
30
- <h1>
31
- <img src="https://github.com/kdqed/zaturn/raw/main/brand/logo.png" width="24" height="24">
32
- <span>Zaturn: Your Co-Pilot For Data Analytics & Business Insights</span>
33
- </h1>
34
-
35
- Zaturn let's you analyze your data using AI chat; without needing you to write SQL/Python code or fiddling with aesthetically pleasing (but overwhelming) dashboards.
36
-
37
- You can add Zaturn MCP to Claude Desktop (or any MCP client), connect your data sources, ask questions in natural language, and get instant insights with visualizations. With Zaturn, your AI can automatically understand the kind of data you have, query it, and give you useful pointers with a coherent narrative. You can ask specific questions like "Who is our most valuable customer?", or let AI explore your data with a question like "Here's all the data we have, give us some ideas for the next quarter."
38
-
39
- [![PyPI Downloads](https://static.pepy.tech/badge/zaturn)](https://pepy.tech/projects/zaturn)
40
-
41
- [Join The Discord](https://discord.gg/K8mECeVzpQ)
42
-
43
-
44
- <a href="https://glama.ai/mcp/servers/@kdqed/zaturn">
45
- <img width="380" height="200" src="https://glama.ai/mcp/servers/@kdqed/zaturn/badge" alt="Zaturn MCP server" />
46
- </a>
47
-
48
- ## But I can just upload my data to ChatGPT and ask it to analyze right?
49
-
50
- Yes, but ChatGPT has an upload size limit of approximately 50MB for CSV files/spreadsheets, and uploading also takes time. Plus, it can't read data straight from your MySQL or PostgreSQL server. Zaturn can overcome all of these limitations, without moving your data anywhere. It simply equips your AI with SQL and visualization capabilities so AI can query your data directly, get the results, process them, and give you instant insights. With Zaturn, AI does not need to process your full dataset and keep it in its memory to answer your questions about the data.
51
-
52
- ## Zaturn in Action
53
-
54
- https://github.com/user-attachments/assets/d42dc433-e5ec-4b3e-bef0-5cfc097396ab
55
-
56
- ## Features:
57
-
58
- ### Multiple Data Sources
59
- Zaturn can currently connect to the following data sources:
60
- - SQL Databases: PostgreSQL, SQLite, DuckDB, MySQL, ClickHouse
61
- - Files: CSV, Parquet
62
-
63
- Connectors for more data sources are being added.
64
-
65
- ### Visualizations
66
- In addition to providing tabular and textual summaries, Zaturn can also generate the following image visualizations
67
-
68
- - Scatter and Line Plots
69
- - Histograms
70
- - Strip and Box Plots
71
- - Bar Plots
72
-
73
- > NOTE: The visuals will be shown only if your MCP client supports image rendering (e.g. Claude Desktop)
74
- >
75
- > If you MCP client does not support images (e.g. Cursor) add the `--noimg` argument in the MCP config. Then the plots will be stored as files and the file location will be returned. You can view the plots with your file browser.
76
-
77
- More visualization capabilities are being added.
78
-
79
-
80
- ## Installation & Setup
81
- 1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/#installation-methods)
82
-
83
- 2. Install [Zaturn](https://pypi.org/project/zaturn/) with uv:
84
- ```bash
85
- uv tool install zaturn
86
- ```
87
-
88
- 3. Add to MCP config, with data sources:
89
- ```json
90
- "mcpServers": {
91
- "zaturn": {
92
- "command": "zaturn_mcp",
93
- "args": [
94
- "postgresql://username:password@host:port/dbname",
95
- "mysql+pymysql://username:password@host:3306/dbname",
96
- "sqlite:////full/path/to/sample_dbs/northwind.db",
97
- "/full/path/to/sample_dbs/titanic.parquet",
98
- "/full/path/to/sample_dbs/ny_aq.csv",
99
- "/full/path/to/sample_dbs/duckdb_sample.duckdb"
100
- ]
101
- },
102
- }
103
- ```
104
-
105
- OR add a `sources.txt` to the Zaturn config directory:
106
- ```
107
- postgresql://username:password@host:port/dbname
108
- mysql+pymysql://username:password@host:3306/dbname
109
- clickhouse://username:password@host:port/dbname
110
- sqlite:////full/path/to/sample_dbs/northwind.db
111
- /full/path/to/sample_dbs/titanic.parquet
112
- /full/path/to/sample_dbs/ny_aq.csv
113
- /full/path/to/sample_dbs/duckdb_sample.duckdb
114
- ```
115
-
116
- This file needs to be at `~/.config/zaturn/sources.txt` on Linux/MacOS and at `%APPDATA%\zaturn\sources.txt` on Windows.
117
-
118
- If your MCP client does not support image rendering, add the `--noimg` argument:
119
- ```json
120
- ...
121
- "args": [
122
- "--noimg",
123
- "mysql+pymysql://username:password@host:3306/dbname",
124
- ...
125
- ```
126
-
127
-
128
- 4. Set a system prompt if your LLM/IDE allows you to:
129
- ```
130
- You are a helpful data analysis assistant. Use only the tool provided data sources to process user inputs. Do not use external sources or your own knowledge base.
131
- ```
132
-
133
- 5. Ask a question and watch the magic:
134
- ```
135
- User: List the top 5 customers by revenue for Northwind
136
- AI:
137
- The top 5 customers by revenue for Northwind are:
138
-
139
- 1. B's Beverages with a revenue of $6,154,115.34
140
- 2. Hungry Coyote Import Store** with a revenue of $5,698,023.67
141
- 3. Rancho grande with a revenue of $5,559,110.08
142
- 4. Gourmet Lanchonetes with a revenue of $5,552,597.90
143
- 5. Ana Trujillo Emparedados y helados with a revenue of $5,534,356.6
144
- ```
145
-
146
- ## Roadmap
147
-
148
- - Support for more data source types
149
- - More data visualizations
150
- - Predictive analysis and forecasting, e.g.:
151
- ```
152
- Based on the revenue of the last 3 months, forecast next month's revenue.
153
- ```
154
- - Generate Presentations & PDFs
155
- ```
156
- Manager:
157
- I need a presentation to show the boss. Can you do it by EOD?
158
- Analyst:
159
- EOD?! Are you still in the 2010s?
160
- I can get it done right now. Actually, you can do it right now.
161
- You know what? The boss can do it right now.
162
- ```
163
- - A native notebook interface
164
-
165
- ## Help And Feedback
166
-
167
- [Raise an issue](https://github.com/kdqed/zaturn/issues) or [join the Discord](https://discord.gg/K8mECeVzpQ).
168
-
169
-
170
- ## Support The Project
171
-
172
- If you find Zaturn useful, please support this project by:
173
- - Starring the Project
174
- - Spreading the word
175
- - [Pledging $9/month on Patreon](https://www.patreon.com/kdqed?utm_medium=github&utm_source=join_link&utm_campaign=creatorshare_creator&utm_content=copyLink)
176
-
177
- Your support will enable me to dedicate more of my time to Zaturn.
178
-
179
- ## Example Dataset Credits
180
-
181
- The [pokemon dataset compiled by Sarah Taha and PokéAPI](https://www.kaggle.com/datasets/sarahtaha/1025-pokemon) has been included under the [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) license for demonstration purposes.
182
-
183
- ## Star History
184
-
185
- [![Star History Chart](https://api.star-history.com/svg?repos=kdqed/zaturn&type=Date)](https://www.star-history.com/#kdqed/zaturn&Date)
@@ -1,12 +0,0 @@
1
- zaturn/__init__.py,sha256=v4t5fkRuIJFE-SBxCa5pBjZv0EoC0eWK75nU9iaa7Rg,267
2
- zaturn/config.py,sha256=qdFy7GyGyXO-rEyqb8kO3wym3DEk2nQEiz-JscDKjaw,3446
3
- zaturn/core.py,sha256=MNB37smt4wkdHCTsZECesrksnx0FnCnHBw4kkWOTvTQ,4671
4
- zaturn/query_utils.py,sha256=4o37eGV8X1sbYvme_jKaPX8hdlynfzMK_0qCSf6XZlo,3031
5
- zaturn/visualizations.py,sha256=0ON70D_mK4o0oyfEKqAhr2jkKWz_5-kNKkD6_TGBR9k,5014
6
- zaturn/example_data/all_pokemon_data.csv,sha256=SUlGHHWbehuLg-ch1YUrQ6-xBtqHGw6rIkyn70fAgCk,130893
7
- zaturn-0.1.7.dist-info/licenses/LICENSE,sha256=mZSuFlbEBZGl0-8ULRMLdRDbhau5hrWRNQOjytYeaug,1070
8
- zaturn-0.1.7.dist-info/METADATA,sha256=b_pULTQiosZBRg6lZSAWVD23HxRmjercbL3bj06wOHE,7179
9
- zaturn-0.1.7.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
10
- zaturn-0.1.7.dist-info/entry_points.txt,sha256=N1UZC2zvod92_Brs4A2xZiAnt-iGLBNryglXfwhxfj4,43
11
- zaturn-0.1.7.dist-info/top_level.txt,sha256=KLUnwQwVZkfd5YCnnqR35MOOs8KLhanPGelvmRo2MVA,7
12
- zaturn-0.1.7.dist-info/RECORD,,
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- zaturn_mcp = zaturn:main