polars-mcp 0.1.1__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.
- polars_mcp-0.1.1/.gitignore +2 -0
- polars_mcp-0.1.1/PKG-INFO +222 -0
- polars_mcp-0.1.1/README.md +212 -0
- polars_mcp-0.1.1/guides/contexts.md +382 -0
- polars_mcp-0.1.1/guides/expressions.md +1154 -0
- polars_mcp-0.1.1/guides/lazy-api.md +87 -0
- polars_mcp-0.1.1/guides/pandas-to-polars.md +597 -0
- polars_mcp-0.1.1/polars_mcp.py +597 -0
- polars_mcp-0.1.1/pyproject.toml +31 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: polars-mcp
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: MCP server providing Polars API reference via introspection
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Requires-Dist: mcp>=1.0.0
|
|
7
|
+
Requires-Dist: polars>=1.0.0
|
|
8
|
+
Requires-Dist: pydantic>=2.0.0
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# Polars MCP Server
|
|
12
|
+
|
|
13
|
+
MCP server providing Polars API reference documentation via introspection of the installed Polars package and additional information via conceptual guides.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- Polars API searchable by keyword
|
|
18
|
+
- Full documentation for any Polars function, method, or class
|
|
19
|
+
- Conceptual guides for Polars usage patterns
|
|
20
|
+
- pandas to Polars translation guide
|
|
21
|
+
- Always up-to-date with your installed Polars version
|
|
22
|
+
- No external dependencies or pre-built docs needed
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Requires Python 3.10+ and Polars.
|
|
27
|
+
|
|
28
|
+
**Important:** This server introspects the installed Polars package. Install the same Polars version you use in your project to ensure accurate documentation.
|
|
29
|
+
|
|
30
|
+
### From PyPI
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Install with your project's Polars version
|
|
34
|
+
uv pip install polars-mcp polars==1.35.0
|
|
35
|
+
|
|
36
|
+
# Or install with latest Polars
|
|
37
|
+
uv pip install polars-mcp polars
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### From source
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Clone repository
|
|
44
|
+
git clone https://github.com/r-brink/polars-mcp
|
|
45
|
+
cd polars-mcp
|
|
46
|
+
|
|
47
|
+
# Install with uv
|
|
48
|
+
uv pip install .
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
Add to your MCP settings configuration file.
|
|
54
|
+
|
|
55
|
+
### With `uvx`
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"mcpServers": {
|
|
60
|
+
"polars-mcp": {
|
|
61
|
+
"command": "uvx",
|
|
62
|
+
"args": [
|
|
63
|
+
"--with",
|
|
64
|
+
"polars", # set your Polars version here
|
|
65
|
+
"polars-mcp"
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### When installing from source
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"mcpServers": {
|
|
77
|
+
"polars-mcp": {
|
|
78
|
+
"command": "uv",
|
|
79
|
+
"args": [
|
|
80
|
+
"--directory",
|
|
81
|
+
"/path/to/polars-mcp",
|
|
82
|
+
"run",
|
|
83
|
+
"polars_mcp.py"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Refer to the documentation on the Model Context Protocol website on how to [connect to local MCP servers](https://modelcontextprotocol.io/docs/develop/connect-local-servers) for an extensive guide.
|
|
91
|
+
|
|
92
|
+
### Standalone Testing
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Test the server
|
|
96
|
+
python polars_mcp.py --help
|
|
97
|
+
|
|
98
|
+
# Run with MCP inspector
|
|
99
|
+
npx @modelcontextprotocol/inspector uv run polars_mcp.py
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Available Tools
|
|
103
|
+
|
|
104
|
+
### polars_get_guide
|
|
105
|
+
|
|
106
|
+
Get conceptual guides about Polars usage patterns.
|
|
107
|
+
|
|
108
|
+
**Parameters:**
|
|
109
|
+
|
|
110
|
+
- `guide` (str): Which guide to retrieve
|
|
111
|
+
- `'contexts'` - Expression contexts (select, filter, group_by, with_columns, over)
|
|
112
|
+
- `'expressions'` - Expression system and composition patterns
|
|
113
|
+
- `'lazy-api'` - Lazy evaluation and query optimization
|
|
114
|
+
- `'pandas-to-polars'` - Complete pandas to Polars translation guide
|
|
115
|
+
|
|
116
|
+
**Example:**
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
Guide: "pandas-to-polars"
|
|
120
|
+
Returns: Complete guide with side-by-side pandas/Polars comparisons
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### polars_search_api
|
|
124
|
+
|
|
125
|
+
Search for Polars API elements by keyword.
|
|
126
|
+
|
|
127
|
+
**Parameters:**
|
|
128
|
+
|
|
129
|
+
- `query` (str): Search term (e.g., "groupby", "filter", "lazy")
|
|
130
|
+
- `limit` (int, optional): Max results (default: 20)
|
|
131
|
+
- `response_format` (str, optional): "markdown" or "json" (default: "markdown")
|
|
132
|
+
|
|
133
|
+
**Example:**
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
Query: "group by"
|
|
137
|
+
Returns: List of all group by-related functions and methods
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### polars_get_docstring
|
|
141
|
+
|
|
142
|
+
Get complete documentation for a specific API element.
|
|
143
|
+
|
|
144
|
+
**Parameters:**
|
|
145
|
+
|
|
146
|
+
- `name` (str): Full name (e.g., "DataFrame.filter", "col", "LazyFrame")
|
|
147
|
+
- `response_format` (str, optional): "markdown" or "json" (default: "markdown")
|
|
148
|
+
|
|
149
|
+
**Example:**
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
Name: "DataFrame.filter"
|
|
153
|
+
Returns: Full documentation with signature and examples
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Available Guides
|
|
157
|
+
|
|
158
|
+
### polars://guides/contexts
|
|
159
|
+
|
|
160
|
+
Guide to Polars expression contexts:
|
|
161
|
+
|
|
162
|
+
- What contexts are (select, filter, group_by, with_columns)
|
|
163
|
+
- When to use each context
|
|
164
|
+
- How contexts affect expression evaluation
|
|
165
|
+
- Common patterns for each context
|
|
166
|
+
|
|
167
|
+
### polars://guides/expressions
|
|
168
|
+
|
|
169
|
+
Complete guide to the Polars expression system:
|
|
170
|
+
|
|
171
|
+
- What expressions are and how they work
|
|
172
|
+
- Composition patterns (chaining, operators, nesting)
|
|
173
|
+
- Expression expansion
|
|
174
|
+
- Common patterns (aggregations, window functions, conditionals)
|
|
175
|
+
|
|
176
|
+
### polars://guides/lazy-api
|
|
177
|
+
|
|
178
|
+
Guide to lazy evaluation:
|
|
179
|
+
|
|
180
|
+
- Eager (DataFrame) vs Lazy (LazyFrame)
|
|
181
|
+
- Query optimization (predicate pushdown, projection pushdown)
|
|
182
|
+
- When to use each approach
|
|
183
|
+
- Best practices for large datasets
|
|
184
|
+
|
|
185
|
+
### polars://guides/pandas-to-polars
|
|
186
|
+
|
|
187
|
+
- Side-by-side syntax comparisons for all common operations
|
|
188
|
+
- Reading data, column selection, filtering, sorting
|
|
189
|
+
- Group by aggregations and window functions
|
|
190
|
+
- Joins (including semi/anti joins)
|
|
191
|
+
- String, datetime, and missing value operations
|
|
192
|
+
- Complete worked examples
|
|
193
|
+
- Anti-patterns to avoid
|
|
194
|
+
- Performance optimization checklist
|
|
195
|
+
|
|
196
|
+
This guide is specifically optimized for LLMs to quickly translate pandas code to efficient Polars queries.
|
|
197
|
+
|
|
198
|
+
## Why This Server?
|
|
199
|
+
|
|
200
|
+
- **Always current**: Documentation reflects your installed Polars version
|
|
201
|
+
- **Lightweight**: No large pre-built documentation databases
|
|
202
|
+
- **Comprehensive**: Combines API reference with conceptual guides
|
|
203
|
+
- **Migration-friendly**: Includes complete pandas translation guide
|
|
204
|
+
- **Fast**: Uses introspection for instant access to documentation
|
|
205
|
+
|
|
206
|
+
## Project Structure
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
polars-mcp/
|
|
210
|
+
├── polars_mcp.py # Main server
|
|
211
|
+
├── pyproject.toml # Dependencies
|
|
212
|
+
├── guides/ # Conceptual
|
|
213
|
+
│ ├── lazy-api.md # Lazy API guide
|
|
214
|
+
│ ├── expressions.md # Expression patterns
|
|
215
|
+
│ ├── contexts.md # Context behaviors
|
|
216
|
+
│ └── pandas-to-polars.md # pandas to Polars
|
|
217
|
+
└── README.md
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Contributing
|
|
221
|
+
|
|
222
|
+
Contributions welcome! Please submit issues or pull requests.
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# Polars MCP Server
|
|
2
|
+
|
|
3
|
+
MCP server providing Polars API reference documentation via introspection of the installed Polars package and additional information via conceptual guides.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Polars API searchable by keyword
|
|
8
|
+
- Full documentation for any Polars function, method, or class
|
|
9
|
+
- Conceptual guides for Polars usage patterns
|
|
10
|
+
- pandas to Polars translation guide
|
|
11
|
+
- Always up-to-date with your installed Polars version
|
|
12
|
+
- No external dependencies or pre-built docs needed
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Requires Python 3.10+ and Polars.
|
|
17
|
+
|
|
18
|
+
**Important:** This server introspects the installed Polars package. Install the same Polars version you use in your project to ensure accurate documentation.
|
|
19
|
+
|
|
20
|
+
### From PyPI
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Install with your project's Polars version
|
|
24
|
+
uv pip install polars-mcp polars==1.35.0
|
|
25
|
+
|
|
26
|
+
# Or install with latest Polars
|
|
27
|
+
uv pip install polars-mcp polars
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### From source
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Clone repository
|
|
34
|
+
git clone https://github.com/r-brink/polars-mcp
|
|
35
|
+
cd polars-mcp
|
|
36
|
+
|
|
37
|
+
# Install with uv
|
|
38
|
+
uv pip install .
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
Add to your MCP settings configuration file.
|
|
44
|
+
|
|
45
|
+
### With `uvx`
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"polars-mcp": {
|
|
51
|
+
"command": "uvx",
|
|
52
|
+
"args": [
|
|
53
|
+
"--with",
|
|
54
|
+
"polars", # set your Polars version here
|
|
55
|
+
"polars-mcp"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### When installing from source
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"mcpServers": {
|
|
67
|
+
"polars-mcp": {
|
|
68
|
+
"command": "uv",
|
|
69
|
+
"args": [
|
|
70
|
+
"--directory",
|
|
71
|
+
"/path/to/polars-mcp",
|
|
72
|
+
"run",
|
|
73
|
+
"polars_mcp.py"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Refer to the documentation on the Model Context Protocol website on how to [connect to local MCP servers](https://modelcontextprotocol.io/docs/develop/connect-local-servers) for an extensive guide.
|
|
81
|
+
|
|
82
|
+
### Standalone Testing
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Test the server
|
|
86
|
+
python polars_mcp.py --help
|
|
87
|
+
|
|
88
|
+
# Run with MCP inspector
|
|
89
|
+
npx @modelcontextprotocol/inspector uv run polars_mcp.py
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Available Tools
|
|
93
|
+
|
|
94
|
+
### polars_get_guide
|
|
95
|
+
|
|
96
|
+
Get conceptual guides about Polars usage patterns.
|
|
97
|
+
|
|
98
|
+
**Parameters:**
|
|
99
|
+
|
|
100
|
+
- `guide` (str): Which guide to retrieve
|
|
101
|
+
- `'contexts'` - Expression contexts (select, filter, group_by, with_columns, over)
|
|
102
|
+
- `'expressions'` - Expression system and composition patterns
|
|
103
|
+
- `'lazy-api'` - Lazy evaluation and query optimization
|
|
104
|
+
- `'pandas-to-polars'` - Complete pandas to Polars translation guide
|
|
105
|
+
|
|
106
|
+
**Example:**
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
Guide: "pandas-to-polars"
|
|
110
|
+
Returns: Complete guide with side-by-side pandas/Polars comparisons
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### polars_search_api
|
|
114
|
+
|
|
115
|
+
Search for Polars API elements by keyword.
|
|
116
|
+
|
|
117
|
+
**Parameters:**
|
|
118
|
+
|
|
119
|
+
- `query` (str): Search term (e.g., "groupby", "filter", "lazy")
|
|
120
|
+
- `limit` (int, optional): Max results (default: 20)
|
|
121
|
+
- `response_format` (str, optional): "markdown" or "json" (default: "markdown")
|
|
122
|
+
|
|
123
|
+
**Example:**
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
Query: "group by"
|
|
127
|
+
Returns: List of all group by-related functions and methods
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### polars_get_docstring
|
|
131
|
+
|
|
132
|
+
Get complete documentation for a specific API element.
|
|
133
|
+
|
|
134
|
+
**Parameters:**
|
|
135
|
+
|
|
136
|
+
- `name` (str): Full name (e.g., "DataFrame.filter", "col", "LazyFrame")
|
|
137
|
+
- `response_format` (str, optional): "markdown" or "json" (default: "markdown")
|
|
138
|
+
|
|
139
|
+
**Example:**
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
Name: "DataFrame.filter"
|
|
143
|
+
Returns: Full documentation with signature and examples
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Available Guides
|
|
147
|
+
|
|
148
|
+
### polars://guides/contexts
|
|
149
|
+
|
|
150
|
+
Guide to Polars expression contexts:
|
|
151
|
+
|
|
152
|
+
- What contexts are (select, filter, group_by, with_columns)
|
|
153
|
+
- When to use each context
|
|
154
|
+
- How contexts affect expression evaluation
|
|
155
|
+
- Common patterns for each context
|
|
156
|
+
|
|
157
|
+
### polars://guides/expressions
|
|
158
|
+
|
|
159
|
+
Complete guide to the Polars expression system:
|
|
160
|
+
|
|
161
|
+
- What expressions are and how they work
|
|
162
|
+
- Composition patterns (chaining, operators, nesting)
|
|
163
|
+
- Expression expansion
|
|
164
|
+
- Common patterns (aggregations, window functions, conditionals)
|
|
165
|
+
|
|
166
|
+
### polars://guides/lazy-api
|
|
167
|
+
|
|
168
|
+
Guide to lazy evaluation:
|
|
169
|
+
|
|
170
|
+
- Eager (DataFrame) vs Lazy (LazyFrame)
|
|
171
|
+
- Query optimization (predicate pushdown, projection pushdown)
|
|
172
|
+
- When to use each approach
|
|
173
|
+
- Best practices for large datasets
|
|
174
|
+
|
|
175
|
+
### polars://guides/pandas-to-polars
|
|
176
|
+
|
|
177
|
+
- Side-by-side syntax comparisons for all common operations
|
|
178
|
+
- Reading data, column selection, filtering, sorting
|
|
179
|
+
- Group by aggregations and window functions
|
|
180
|
+
- Joins (including semi/anti joins)
|
|
181
|
+
- String, datetime, and missing value operations
|
|
182
|
+
- Complete worked examples
|
|
183
|
+
- Anti-patterns to avoid
|
|
184
|
+
- Performance optimization checklist
|
|
185
|
+
|
|
186
|
+
This guide is specifically optimized for LLMs to quickly translate pandas code to efficient Polars queries.
|
|
187
|
+
|
|
188
|
+
## Why This Server?
|
|
189
|
+
|
|
190
|
+
- **Always current**: Documentation reflects your installed Polars version
|
|
191
|
+
- **Lightweight**: No large pre-built documentation databases
|
|
192
|
+
- **Comprehensive**: Combines API reference with conceptual guides
|
|
193
|
+
- **Migration-friendly**: Includes complete pandas translation guide
|
|
194
|
+
- **Fast**: Uses introspection for instant access to documentation
|
|
195
|
+
|
|
196
|
+
## Project Structure
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
polars-mcp/
|
|
200
|
+
├── polars_mcp.py # Main server
|
|
201
|
+
├── pyproject.toml # Dependencies
|
|
202
|
+
├── guides/ # Conceptual
|
|
203
|
+
│ ├── lazy-api.md # Lazy API guide
|
|
204
|
+
│ ├── expressions.md # Expression patterns
|
|
205
|
+
│ ├── contexts.md # Context behaviors
|
|
206
|
+
│ └── pandas-to-polars.md # pandas to Polars
|
|
207
|
+
└── README.md
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Contributing
|
|
211
|
+
|
|
212
|
+
Contributions welcome! Please submit issues or pull requests.
|