mcp-stata 1.2.2__py3-none-any.whl → 1.6.8__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.

Potentially problematic release.


This version of mcp-stata might be problematic. Click here for more details.

@@ -0,0 +1,388 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-stata
3
+ Version: 1.6.8
4
+ Summary: A lightweight Model Context Protocol (MCP) server for Stata. Execute commands, inspect data, retrieve stored results (`r()`/`e()`), and view graphs in your chat interface. Built for economists who want to integrate LLM assistance into their Stata workflow.
5
+ Project-URL: Homepage, https://github.com/tmonk/mcp-stata
6
+ Project-URL: Repository, https://github.com/tmonk/mcp-stata
7
+ Project-URL: Issues, https://github.com/tmonk/mcp-stata/issues
8
+ Author-email: Thomas Monk <t.d.monk@lse.ac.uk>
9
+ License-Expression: AGPL-3.0-or-later
10
+ License-File: LICENSE
11
+ Keywords: ai,econometrics,llm,mcp,stata,statistics
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
20
+ Requires-Python: >=3.12
21
+ Requires-Dist: httpx<0.28.0,>=0.27.0
22
+ Requires-Dist: mcp[cli]>=1.0.0
23
+ Requires-Dist: pandas>=2.0.0
24
+ Requires-Dist: pydantic>=2.0.0
25
+ Requires-Dist: pystata>=0.0.1
26
+ Requires-Dist: pytest-asyncio>=1.3.0
27
+ Requires-Dist: stata-setup>=0.1.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: build>=1.3.0; extra == 'dev'
30
+ Requires-Dist: hatch>=1.16.2; extra == 'dev'
31
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
32
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
33
+ Requires-Dist: ruff>=0.4.0; extra == 'dev'
34
+ Requires-Dist: twine>=6.2.0; extra == 'dev'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # Stata MCP Server
38
+
39
+ <a href="https://cursor.com/en-US/install-mcp?name=mcp-stata&config=eyJjb21tYW5kIjoidXZ4IC0tZnJvbSBtY3Atc3RhdGEgbWNwLXN0YXRhIn0%3D"><img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install MCP Server" height="20"></a>&nbsp;
40
+ <a href="https://pypi.org/project/mcp-stata/"><img src="https://img.shields.io/pypi/v/mcp-stata?style=flat&color=black" alt="PyPI - Version" height="20"></a>
41
+
42
+ A [Model Context Protocol](https://github.com/modelcontextprotocol) (MCP) server that connects AI agents to a local Stata installation.
43
+
44
+ > If you'd like a fully integrated VS Code extension to run Stata code without leaving your IDE, and also allow AI agent interaction, check out my other project: [<img src="https://raw.githubusercontent.com/tmonk/stata-workbench/refs/heads/main/img/icon.png" height="12px"> Stata Workbench](https://github.com/tmonk/stata-workbench/).
45
+
46
+ Built by <a href="https://tdmonk.com">Thomas Monk</a>, London School of Economics.
47
+ <!-- mcp-name: io.github.tmonk/mcp-stata -->
48
+
49
+ This server enables LLMs to:
50
+ - **Execute Stata code**: run any Stata command (e.g. `sysuse auto`, `regress price mpg`).
51
+ - **Inspect data**: retrieve dataset summaries and variable codebooks.
52
+ - **Export graphics**: generate and view Stata graphs (histograms, scatterplots).
53
+ - **Streaming graph caching**: automatically cache graphs during command execution for instant exports.
54
+ - **Verify results**: programmatically check stored results (`r()`, `e()`) for accurate validation.
55
+
56
+ ## Prerequisites
57
+
58
+ - **Stata 17+** (required for `pystata` integration)
59
+ - **Python 3.12+** (required)
60
+ - **uv** (recommended for install/run)
61
+
62
+ ## Installation
63
+
64
+ ### Run as a published tool with `uvx`
65
+
66
+ ```bash
67
+ uvx --refresh --from mcp-stata@latest mcp-stata
68
+ ```
69
+
70
+ `uvx` is an alias for `uv tool run` and runs the tool in an isolated, cached environment.
71
+
72
+ ## Configuration
73
+
74
+ This server attempts to automatically discover your Stata installation (supporting standard paths and StataNow).
75
+
76
+ If auto-discovery fails, set the `STATA_PATH` environment variable to your Stata executable:
77
+
78
+ ```bash
79
+ # macOS example
80
+ export STATA_PATH="/Applications/StataNow/StataMP.app/Contents/MacOS/stata-mp"
81
+
82
+ # Windows example (cmd.exe)
83
+ set STATA_PATH="C:\Program Files\Stata18\StataMP-64.exe"
84
+ ```
85
+
86
+ If you prefer, add `STATA_PATH` to your MCP config's `env` for any IDE shown below. It's optional and only needed when discovery cannot find Stata.
87
+
88
+ Optional `env` example (add inside your MCP server entry):
89
+
90
+ ```json
91
+ "env": {
92
+ "STATA_PATH": "/Applications/StataNow/StataMP.app/Contents/MacOS/stata-mp"
93
+ }
94
+ ```
95
+
96
+ ## IDE Setup (MCP)
97
+
98
+ This MCP server uses the **stdio** transport (the IDE launches the process and communicates over stdin/stdout).
99
+
100
+ ---
101
+
102
+ ### Claude Desktop
103
+
104
+ Open Claude Desktop → **Settings** → **Developer** → **Edit Config**.
105
+ Config file locations include:
106
+
107
+ * macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
108
+ * Windows: `%APPDATA%\Claude\claude_desktop_config.json`
109
+
110
+ #### Published tool (uvx)
111
+
112
+ ```json
113
+ {
114
+ "mcpServers": {
115
+ "mcp-stata": {
116
+ "command": "uvx",
117
+ "args": [
118
+ "--refresh",
119
+ "--from",
120
+ "mcp-stata@latest",
121
+ "mcp-stata"
122
+ ]
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ After editing, fully quit and restart Claude Desktop to reload MCP servers.
129
+
130
+ ---
131
+
132
+ ### Cursor
133
+
134
+ Cursor supports MCP config at:
135
+
136
+ * Global: `~/.cursor/mcp.json`
137
+ * Project: `.cursor/mcp.json`
138
+
139
+ #### Published tool (uvx)
140
+
141
+ ```json
142
+ {
143
+ "mcpServers": {
144
+ "mcp-stata": {
145
+ "command": "uvx",
146
+ "args": [
147
+ "--refresh",
148
+ "--from",
149
+ "mcp-stata@latest",
150
+ "mcp-stata"
151
+ ]
152
+ }
153
+ }
154
+ }
155
+ ```
156
+
157
+ ---
158
+
159
+ ### Windsurf
160
+
161
+ Windsurf supports MCP plugins and also allows manual editing of `mcp_config.json`. After adding/editing a server, use the UI’s refresh so it re-reads the config.
162
+
163
+ A common location is `~/.codeium/windsurf/mcp_config.json`.
164
+ #### Published tool (uvx)
165
+
166
+ ```json
167
+ {
168
+ "mcpServers": {
169
+ "mcp-stata": {
170
+ "command": "uvx",
171
+ "args": [
172
+ "--refresh",
173
+ "--from",
174
+ "mcp-stata@latest",
175
+ "mcp-stata"
176
+ ]
177
+ }
178
+ }
179
+ }
180
+ ```
181
+
182
+ ---
183
+
184
+ ### Google Antigravity
185
+
186
+ In Antigravity, MCP servers are managed from the MCP store/menu; you can open **Manage MCP Servers** and then **View raw config** to edit `mcp_config.json`.
187
+
188
+ #### Published tool (uvx)
189
+
190
+ ```json
191
+ {
192
+ "mcpServers": {
193
+ "mcp-stata": {
194
+ "command": "uvx",
195
+ "args": [
196
+ "--refresh",
197
+ "--from",
198
+ "mcp-stata@latest",
199
+ "mcp-stata"
200
+ ]
201
+ }
202
+ }
203
+ }
204
+ ```
205
+
206
+ ---
207
+
208
+ ### Visual Studio Code
209
+
210
+ VS Code supports MCP servers via a `.vscode/mcp.json` file. The top-level key is **`servers`** (not `mcpServers`).
211
+
212
+ Create `.vscode/mcp.json`:
213
+
214
+ #### Published tool (uvx)
215
+
216
+ ```json
217
+ {
218
+ "servers": {
219
+ "mcp-stata": {
220
+ "type": "stdio",
221
+ "command": "uvx",
222
+ "args": [
223
+ "--refresh",
224
+ "--from",
225
+ "mcp-stata@latest",
226
+ "mcp-stata"
227
+ ]
228
+ }
229
+ }
230
+ }
231
+ ```
232
+
233
+ VS Code documents `.vscode/mcp.json` and the `servers` schema, including `type` and `command`/`args`.
234
+
235
+ ---
236
+
237
+ ## Skills
238
+
239
+ - Skill file (for Claude/Codex): [skill/SKILL.md](skill/SKILL.md)
240
+
241
+ ## Tools Available (from server.py)
242
+
243
+ * `run_command(code, echo=True, as_json=True, trace=False, raw=False, max_output_lines=None)`: Execute Stata syntax.
244
+ - Always writes output to a temporary log file and emits a single `notifications/logMessage` containing `{"event":"log_path","path":"..."}` so the client can tail it locally.
245
+ - May emit `notifications/progress` when the client provides a progress token/callback.
246
+ * `read_log(path, offset=0, max_bytes=65536)`: Read a slice of a previously-provided log file (JSON: `path`, `offset`, `next_offset`, `data`).
247
+ * `load_data(source, clear=True, as_json=True, raw=False, max_output_lines=None)`: Heuristic loader (sysuse/webuse/use/path/URL) with JSON envelope unless `raw=True`. Supports output truncation.
248
+ * `get_data(start=0, count=50)`: View dataset rows (JSON response, capped to 500 rows).
249
+ * `get_ui_channel()`: Return a short-lived localhost HTTP endpoint + bearer token for the UI-only data browser.
250
+ * `describe()`: View dataset structure via Stata `describe`.
251
+ * `list_graphs()`: See available graphs in memory (JSON list with an `active` flag).
252
+ * `export_graph(graph_name=None, format="pdf")`: Export a graph to a file path (default PDF; use `format="png"` for PNG).
253
+ * `export_graphs_all()`: Export all in-memory graphs. Returns file paths by default.
254
+ * `get_help(topic, plain_text=False)`: Markdown-rendered Stata help by default; `plain_text=True` strips formatting.
255
+ * `codebook(variable, as_json=True, trace=False, raw=False, max_output_lines=None)`: Variable-level metadata (JSON envelope by default; supports `trace=True` and output truncation).
256
+ * `run_do_file(path, echo=True, as_json=True, trace=False, raw=False, max_output_lines=None)`: Execute a .do file.
257
+ - Always writes output to a temporary log file and emits a single `notifications/logMessage` containing `{"event":"log_path","path":"..."}` so the client can tail it locally.
258
+ - Emits incremental `notifications/progress` when the client provides a progress token/callback.
259
+ * `get_stored_results()`: Get `r()` and `e()` scalars/macros as JSON.
260
+ * `get_variable_list()`: JSON list of variables and labels.
261
+
262
+ ### Cancellation
263
+
264
+ - Clients may cancel an in-flight request by sending the MCP notification `notifications/cancelled` with `params.requestId` set to the original tool call ID.
265
+ - Client guidance:
266
+ 1. Pass a `_meta.progressToken` when invoking the tool if you want progress updates (optional).
267
+ 2. If you need to cancel, send `notifications/cancelled` with the same requestId. You may also stop tailing the log file path once you receive cancellation confirmation (the tool call will return an error indicating cancellation).
268
+ 3. Be prepared for partial output in the log file; cancellation is best-effort and depends on Stata surfacing `BreakError`.
269
+
270
+ Resources exposed for MCP clients:
271
+
272
+ * `stata://data/summary` → `summarize`
273
+ * `stata://data/metadata` → `describe`
274
+ * `stata://graphs/list` → graph list (resource handler delegates to `list_graphs` tool)
275
+ * `stata://variables/list` → variable list (resource wrapper)
276
+ * `stata://results/stored` → stored r()/e() results
277
+
278
+ ## UI-only Data Browser (Local HTTP API)
279
+
280
+ This server also hosts a **localhost-only HTTP API** intended for a VS Code extension UI to browse data at high volume (paging, filtering) without sending large payloads over MCP.
281
+
282
+ Important properties:
283
+
284
+ - **Loopback only**: binds to `127.0.0.1`.
285
+ - **Bearer auth**: every request requires an `Authorization: Bearer <token>` header.
286
+ - **Short-lived tokens**: clients should call `get_ui_channel()` to obtain a fresh token as needed.
287
+ - **No Stata dataset mutation** for browsing/filtering:
288
+ - No generated variables.
289
+ - Paging uses `sfi.Data.get`.
290
+ - Filtering is evaluated in Python over chunked reads.
291
+
292
+ ### Discovery via MCP (`get_ui_channel`)
293
+
294
+ Call the MCP tool `get_ui_channel()` and parse the JSON:
295
+
296
+ ```json
297
+ {
298
+ "baseUrl": "http://127.0.0.1:53741",
299
+ "token": "...",
300
+ "expiresAt": 1730000000,
301
+ "capabilities": {
302
+ "dataBrowser": true,
303
+ "filtering": true
304
+ }
305
+ }
306
+ ```
307
+
308
+ Server-enforced limits (current defaults):
309
+
310
+ - **maxLimit**: 500
311
+ - **maxVars**: 200
312
+ - **maxChars**: 500
313
+ - **maxRequestBytes**: 1,000,000
314
+
315
+ ### Endpoints
316
+
317
+ All endpoints are under `baseUrl` and require the bearer token.
318
+
319
+ - `GET /v1/dataset`
320
+ - Returns dataset identity and basic state (`id`, `frame`, `n`, `k`).
321
+ - `GET /v1/vars`
322
+ - Returns variable metadata (`name`, `type`, `label`, `format`).
323
+ - `POST /v1/page`
324
+ - Returns a page of data for selected variables.
325
+ - `POST /v1/views`
326
+ - Creates a server-side filtered view (handle-based filtering).
327
+ - `POST /v1/views/:viewId/page`
328
+ - Pages within a filtered view.
329
+ - `DELETE /v1/views/:viewId`
330
+ - Deletes a view handle.
331
+ - `POST /v1/filters/validate`
332
+ - Validates a filter expression.
333
+
334
+ ### Paging request example
335
+
336
+ ```bash
337
+ curl -sS \
338
+ -H "Authorization: Bearer $TOKEN" \
339
+ -H "Content-Type: application/json" \
340
+ -d '{"datasetId":"...","frame":"default","offset":0,"limit":50,"vars":["price","mpg"],"includeObsNo":true,"maxChars":200}' \
341
+ "$BASE_URL/v1/page"
342
+ ```
343
+
344
+ Notes:
345
+
346
+ - `datasetId` is used for cache invalidation. If the dataset changes due to running Stata commands, the server will report a new dataset id and view handles become invalid.
347
+ - Filter expressions are evaluated in Python using values read from Stata via `sfi.Data.get`. Use boolean operators like `==`, `!=`, `<`, `>`, and `and`/`or` (Stata-style `&`/`|` are also accepted).
348
+
349
+ ## License
350
+
351
+ This project is licensed under the GNU Affero General Public License v3.0 or later.
352
+ See the LICENSE file for the full text.
353
+
354
+ ## Error reporting
355
+
356
+ - All tools that execute Stata commands support JSON envelopes (`as_json=true`) carrying:
357
+ - `rc` (from r()/c(rc)), `stdout`, `stderr`, `message`, optional `line` (when Stata reports it), `command`, optional `log_path` (for log-file streaming), and a `snippet` excerpt of error output.
358
+ - Stata-specific cues are preserved:
359
+ - `r(XXX)` codes are parsed when present in output.
360
+ - “Red text” is captured via stderr where available.
361
+ - `trace=true` adds `set trace on` around the command/do-file to surface program-defined errors; the trace is turned off afterward.
362
+
363
+ ## Logging
364
+
365
+ Set `MCP_STATA_LOGLEVEL` (e.g., `DEBUG`, `INFO`) to control server logging. Logs include discovery details (edition/path) and command-init traces for easier troubleshooting.
366
+
367
+ ## Development & Contributing
368
+
369
+ For detailed information on building, testing, and contributing to this project, see [CONTRIBUTING.md](CONTRIBUTING.md).
370
+
371
+ Quick setup:
372
+
373
+ ```bash
374
+ # Install dependencies
375
+ uv sync --extra dev --no-install-project
376
+
377
+ # Run tests (requires Stata)
378
+ pytest
379
+
380
+ # Run tests without Stata
381
+ pytest -v -m "not requires_stata"
382
+
383
+ # Build the package
384
+ python -m build
385
+ ```
386
+
387
+ [![MCP Badge](https://lobehub.com/badge/mcp/tmonk-mcp-stata)](https://lobehub.com/mcp/tmonk-mcp-stata)
388
+ [![Tests](https://github.com/tmonk/mcp-stata/actions/workflows/build-test.yml/badge.svg)](https://github.com/tmonk/mcp-stata/actions/workflows/build-test.yml)
@@ -0,0 +1,14 @@
1
+ mcp_stata/__init__.py,sha256=kJKKRn7lGuVCuS2-GaN5VoVcvnxtNlfuswW_VOlYqwg,98
2
+ mcp_stata/discovery.py,sha256=J_XU1_AXRpqWg_ULV8xf4lT6RRN8MxOdpr1ioTi5TjQ,12951
3
+ mcp_stata/graph_detector.py,sha256=-dJIU1Dq_c1eQSk4eegUi0gU2N-tFqjFGM0tE1E32KM,16066
4
+ mcp_stata/models.py,sha256=QETpYKO3yILy_L6mhouVEanvUIvu4ww_CAAFuiP2YdM,1201
5
+ mcp_stata/server.py,sha256=PV8ragGMeHT72zgVx5DJp3vt8CPqT8iwdvJ8GXSctds,15989
6
+ mcp_stata/stata_client.py,sha256=TNJnlkZ0IoNoVXhKUw0_IYLiRNOwyL2wVmb1gWdiRUY,95981
7
+ mcp_stata/streaming_io.py,sha256=GVaXgTtxx8YLY6RWqdTcO2M3QSqxLsefqkmnlNO1nTI,6974
8
+ mcp_stata/ui_http.py,sha256=kkPYpqp-lQDXs_9qcs7hb16FtvNcag3rKSH7wvQX7Qo,22013
9
+ mcp_stata/smcl/smcl2html.py,sha256=wi91mOMeV9MCmHtNr0toihNbaiDCNZ_NP6a6xEAzWLM,2624
10
+ mcp_stata-1.6.8.dist-info/METADATA,sha256=V5mN_9vRL5f1aja0zrhMatBKb-_ZC6Ok3uOXfRBfYw4,13794
11
+ mcp_stata-1.6.8.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
12
+ mcp_stata-1.6.8.dist-info/entry_points.txt,sha256=TcOgrtiTL4LGFEDb1pCrQWA-fUZvIujDOvQ-bWFh5Z8,52
13
+ mcp_stata-1.6.8.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
14
+ mcp_stata-1.6.8.dist-info/RECORD,,
@@ -1,240 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: mcp-stata
3
- Version: 1.2.2
4
- Summary: A lightweight Model Context Protocol (MCP) server for Stata. Execute commands, inspect data, retrieve stored results (`r()`/`e()`), and view graphs in your chat interface. Built for economists who want to integrate LLM assistance into their Stata workflow.
5
- Project-URL: Homepage, https://github.com/tmonk/mcp-stata
6
- Project-URL: Repository, https://github.com/tmonk/mcp-stata
7
- Project-URL: Issues, https://github.com/tmonk/mcp-stata/issues
8
- Author-email: Thomas Monk <t.d.monk@lse.ac.uk>
9
- License-Expression: AGPL-3.0-or-later
10
- License-File: LICENSE
11
- Keywords: ai,econometrics,llm,mcp,stata,statistics
12
- Classifier: Development Status :: 4 - Beta
13
- Classifier: Intended Audience :: Developers
14
- Classifier: Intended Audience :: Science/Research
15
- Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Topic :: Scientific/Engineering :: Information Analysis
19
- Requires-Python: >=3.11
20
- Requires-Dist: mcp[cli]>=1.0.0
21
- Requires-Dist: pandas>=2.0.0
22
- Requires-Dist: pydantic>=2.0.0
23
- Requires-Dist: pystata>=0.0.1
24
- Requires-Dist: stata-setup>=0.1.0
25
- Provides-Extra: dev
26
- Requires-Dist: build>=1.3.0; extra == 'dev'
27
- Requires-Dist: hatch>=1.16.2; extra == 'dev'
28
- Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
29
- Requires-Dist: pytest>=7.0.0; extra == 'dev'
30
- Requires-Dist: ruff>=0.4.0; extra == 'dev'
31
- Requires-Dist: twine>=6.2.0; extra == 'dev'
32
- Description-Content-Type: text/markdown
33
-
34
- # Stata MCP Server
35
-
36
- [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=mcp-stata&config=eyJjb21tYW5kIjoidXZ4IC0tZnJvbSBtY3Atc3RhdGEgbWNwLXN0YXRhIn0%3D)
37
-
38
- A [Model Context Protocol](https://github.com/modelcontextprotocol) (MCP) server that connects AI assistants to a local Stata installation.
39
-
40
- Built by <a href="https://tdmonk.com">Thomas Monk</a>, London School of Economics.
41
- <!-- mcp-name: io.github.tmonk/mcp-stata -->
42
-
43
- This server enables LLMs to:
44
- - **Execute Stata code**: run any Stata command (e.g. `sysuse auto`, `regress price mpg`).
45
- - **Inspect data**: retrieve dataset summaries and variable codebooks.
46
- - **Export graphics**: generate and view Stata graphs (histograms, scatterplots).
47
- - **Verify results**: programmatically check stored results (`r()`, `e()`) for accurate validation.
48
-
49
- ## Prerequisites
50
-
51
- - **Stata 17+** (required for `pystata` integration)
52
- - **Python 3.11+** (recommended)
53
- - **uv** (recommended for install/run)
54
-
55
- ## Installation
56
-
57
- ### Run as a published tool with `uvx`
58
-
59
- ```bash
60
- uvx --from mcp-stata mcp-stata
61
- ```
62
-
63
- `uvx` is an alias for `uv tool run` and runs the tool in an isolated, cached environment.
64
-
65
- ## Configuration
66
-
67
- This server attempts to automatically discover your Stata installation (supporting standard paths and StataNow).
68
-
69
- If auto-discovery fails, set the `STATA_PATH` environment variable to your Stata executable:
70
-
71
- ```bash
72
- # macOS example
73
- export STATA_PATH="/Applications/StataNow/StataMP.app/Contents/MacOS/stata-mp"
74
-
75
- # Windows example (cmd.exe)
76
- set STATA_PATH="C:\Program Files\Stata18\StataMP-64.exe"
77
- ```
78
-
79
- If you prefer, add `STATA_PATH` to your MCP config's `env` for any IDE shown below. It's optional and only needed when discovery cannot find Stata.
80
-
81
- Optional `env` example (add inside your MCP server entry):
82
-
83
- ```json
84
- "env": {
85
- "STATA_PATH": "/Applications/StataNow/StataMP.app/Contents/MacOS/stata-mp"
86
- }
87
- ```
88
-
89
- ## IDE Setup (MCP)
90
-
91
- This MCP server uses the **stdio** transport (the IDE launches the process and communicates over stdin/stdout).
92
-
93
- ---
94
-
95
- ### Claude Desktop
96
-
97
- Open Claude Desktop → **Settings** → **Developer** → **Edit Config**.
98
- Config file locations include:
99
-
100
- * macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
101
- * Windows: `%APPDATA%\Claude\claude_desktop_config.json`
102
-
103
- #### Published tool (uvx)
104
-
105
- ```json
106
- {
107
- "mcpServers": {
108
- "mcp-stata": {
109
- "command": "uvx",
110
- "args": ["--from", "mcp-stata", "mcp-stata"]
111
- }
112
- }
113
- }
114
- ```
115
-
116
- After editing, fully quit and restart Claude Desktop to reload MCP servers.
117
-
118
- ---
119
-
120
- ### Cursor
121
-
122
- Cursor supports MCP config at:
123
-
124
- * Global: `~/.cursor/mcp.json`
125
- * Project: `.cursor/mcp.json`
126
-
127
- #### Published tool (uvx)
128
-
129
- ```json
130
- {
131
- "mcpServers": {
132
- "mcp-stata": {
133
- "command": "uvx",
134
- "args": ["--from", "mcp-stata", "mcp-stata"]
135
- }
136
- }
137
- }
138
- ```
139
-
140
- ---
141
-
142
- ### Windsurf
143
-
144
- Windsurf supports MCP plugins and also allows manual editing of `mcp_config.json`. After adding/editing a server, use the UI’s refresh so it re-reads the config.
145
-
146
- A common location is `~/.codeium/windsurf/mcp_config.json`.
147
- #### Published tool (uvx)
148
-
149
- ```json
150
- {
151
- "mcpServers": {
152
- "mcp-stata": {
153
- "command": "uvx",
154
- "args": ["--from", "mcp-stata", "mcp-stata"]
155
- }
156
- }
157
- }
158
- ```
159
-
160
- ---
161
-
162
- ### Google Antigravity
163
-
164
- In Antigravity, MCP servers are managed from the MCP store/menu; you can open **Manage MCP Servers** and then **View raw config** to edit `mcp_config.json`.
165
-
166
- #### Published tool (uvx)
167
-
168
- ```json
169
- {
170
- "mcpServers": {
171
- "mcp-stata": {
172
- "command": "uvx",
173
- "args": ["--from", "mcp-stata", "mcp-stata"]
174
- }
175
- }
176
- }
177
- ```
178
-
179
- ---
180
-
181
- ### Visual Studio Code
182
-
183
- VS Code supports MCP servers via a `.vscode/mcp.json` file. The top-level key is **`servers`** (not `mcpServers`).
184
-
185
- Create `.vscode/mcp.json`:
186
-
187
- #### Published tool (uvx)
188
-
189
- ```json
190
- {
191
- "servers": {
192
- "mcp-stata": {
193
- "type": "stdio",
194
- "command": "uvx",
195
- "args": ["--from", "mcp-stata", "mcp-stata"],
196
- }
197
- }
198
- }
199
- ```
200
-
201
- VS Code documents `.vscode/mcp.json` and the `servers` schema, including `type` and `command`/`args`.
202
-
203
- ---
204
-
205
- ## Skills
206
-
207
- - Skill file (for Claude/Codex): [skill/SKILL.md](skill/SKILL.md)
208
-
209
- ## Tools Available
210
-
211
- * `run_command(code, raw=false)`: Execute Stata syntax. Returns a structured JSON envelope by default; set `raw=true` for plain stdout/stderr. `trace=true` temporarily enables `set trace on`.
212
- * `load_data(source, clear=True, raw=false)`: Heuristic loader (sysuse/webuse/use/path/URL) with JSON envelope.
213
- * `get_data(start, count)`: View dataset rows (JSON response, capped to 500 rows).
214
- * `describe()`: View dataset structure.
215
- * `codebook(variable, raw=false)`: Variable-level metadata (JSON envelope by default).
216
- * `run_do_file(path, trace=false, raw=false)`: Execute a .do file with rich error capture (JSON by default).
217
- * `export_graph(name, format="pdf")`: Export a graph to a file path (default PDF; use `format="png"` for PNG).
218
- * `export_graphs_all()`: Export all in-memory graphs as base64-encoded PNGs (JSON response).
219
- * `list_graphs()`: See available graphs in memory (JSON list with an `active` flag).
220
- * `get_stored_results()`: Get `r()` and `e()` scalars/macros.
221
- * `get_help(topic, plain_text=false)`: Returns Markdown-rendered Stata help (default). Use `plain_text=true` for stripped text. Falls back to the Stata online help URL if missing.
222
- * `get_variable_list()`: JSON list of variables and labels.
223
-
224
- ## License
225
-
226
- This project is licensed under the GNU Affero General Public License v3.0 or later.
227
- See the LICENSE file for the full text.
228
-
229
- ## Error reporting
230
-
231
- - All tools that execute Stata commands support JSON envelopes (`as_json=true`) carrying:
232
- - `rc` (from r()/c(rc)), `stdout`, `stderr`, `message`, optional `line` (when Stata reports it), `command`, and a `snippet` excerpt of error output.
233
- - Stata-specific cues are preserved:
234
- - `r(XXX)` codes are parsed when present in output.
235
- - “Red text” is captured via stderr where available.
236
- - `trace=true` adds `set trace on` around the command/do-file to surface program-defined errors; the trace is turned off afterward.
237
-
238
- ## Logging
239
-
240
- Set `STATA_MCP_LOGLEVEL` (e.g., `DEBUG`, `INFO`) to control server logging. Logs include discovery details (edition/path) and command-init traces for easier troubleshooting.
@@ -1,11 +0,0 @@
1
- mcp_stata/__init__.py,sha256=kJKKRn7lGuVCuS2-GaN5VoVcvnxtNlfuswW_VOlYqwg,98
2
- mcp_stata/discovery.py,sha256=KVNgLzmsZfkQ41k0UDZjNfwfz8yRwJs7iZR9NMu0qCE,5791
3
- mcp_stata/models.py,sha256=mVRvZYZMeXf1o5MLcD0bSwd0xO16ldEWaY6qXsJehRc,1078
4
- mcp_stata/server.py,sha256=KxxuFeVfYbIH5aRmCgYFA_wQwVw-Q1JMD5vC3e7vzAU,7804
5
- mcp_stata/stata_client.py,sha256=GQi5t3L9jX6xSocaOqIWo0Lp3ORaqRMDYQHfITjNXYM,20474
6
- mcp_stata/smcl/smcl2html.py,sha256=wi91mOMeV9MCmHtNr0toihNbaiDCNZ_NP6a6xEAzWLM,2624
7
- mcp_stata-1.2.2.dist-info/METADATA,sha256=DH7y6cqEDJr-blD62LE0p4rudhmzaBkiSuHwtO2uagA,7840
8
- mcp_stata-1.2.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
9
- mcp_stata-1.2.2.dist-info/entry_points.txt,sha256=TcOgrtiTL4LGFEDb1pCrQWA-fUZvIujDOvQ-bWFh5Z8,52
10
- mcp_stata-1.2.2.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
11
- mcp_stata-1.2.2.dist-info/RECORD,,