aigroup-stata-mcp 1.0.3__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.
- aigroup_stata_mcp-1.0.3.dist-info/METADATA +345 -0
- aigroup_stata_mcp-1.0.3.dist-info/RECORD +38 -0
- aigroup_stata_mcp-1.0.3.dist-info/WHEEL +4 -0
- aigroup_stata_mcp-1.0.3.dist-info/entry_points.txt +5 -0
- aigroup_stata_mcp-1.0.3.dist-info/licenses/LICENSE +21 -0
- stata_mcp/__init__.py +18 -0
- stata_mcp/cli/__init__.py +8 -0
- stata_mcp/cli/_cli.py +95 -0
- stata_mcp/core/__init__.py +14 -0
- stata_mcp/core/data_info/__init__.py +11 -0
- stata_mcp/core/data_info/_base.py +288 -0
- stata_mcp/core/data_info/csv.py +123 -0
- stata_mcp/core/data_info/dta.py +70 -0
- stata_mcp/core/stata/__init__.py +13 -0
- stata_mcp/core/stata/stata_controller/__init__.py +9 -0
- stata_mcp/core/stata/stata_controller/controller.py +208 -0
- stata_mcp/core/stata/stata_do/__init__.py +9 -0
- stata_mcp/core/stata/stata_do/do.py +177 -0
- stata_mcp/core/stata/stata_finder/__init__.py +9 -0
- stata_mcp/core/stata/stata_finder/base.py +294 -0
- stata_mcp/core/stata/stata_finder/finder.py +193 -0
- stata_mcp/core/stata/stata_finder/linux.py +43 -0
- stata_mcp/core/stata/stata_finder/macos.py +88 -0
- stata_mcp/core/stata/stata_finder/windows.py +191 -0
- stata_mcp/server/__init__.py +8 -0
- stata_mcp/server/main.py +153 -0
- stata_mcp/server/prompts/__init__.py +8 -0
- stata_mcp/server/prompts/core_prompts.py +122 -0
- stata_mcp/server/tools/__init__.py +10 -0
- stata_mcp/server/tools/core_tools.py +59 -0
- stata_mcp/server/tools/file_tools.py +163 -0
- stata_mcp/server/tools/stata_tools.py +221 -0
- stata_mcp/utils/Installer/__init__.py +7 -0
- stata_mcp/utils/Installer/installer.py +85 -0
- stata_mcp/utils/Prompt/__init__.py +74 -0
- stata_mcp/utils/Prompt/string.py +91 -0
- stata_mcp/utils/__init__.py +23 -0
- stata_mcp/utils/usable.py +244 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aigroup-stata-mcp
|
|
3
|
+
Version: 1.0.3
|
|
4
|
+
Summary: A Stata integration server based on Model Context Protocol (MCP) that allows AI assistants to execute Stata scripts, fetch data information, and run statistical analysis.
|
|
5
|
+
Author-email: jackdark425 <jackdark425@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: ai,data-analysis,mcp,model-context-protocol,stata,statistics
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: mcp[cli]>=1.21.0
|
|
21
|
+
Requires-Dist: openpyxl>=3.1.5
|
|
22
|
+
Requires-Dist: pandas>=2.3.0
|
|
23
|
+
Requires-Dist: pathvalidate>=3.3.1
|
|
24
|
+
Requires-Dist: pexpect>=4.9.0
|
|
25
|
+
Requires-Dist: pydantic>=2.0.0
|
|
26
|
+
Requires-Dist: python-dotenv>=1.1.1
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# aigroup-stata-mcp
|
|
30
|
+
|
|
31
|
+
[](https://www.python.org/downloads/)
|
|
32
|
+
[](https://opensource.org/licenses/MIT)
|
|
33
|
+
[](https://spec.modelcontextprotocol.io/)
|
|
34
|
+
[](https://pypi.org/project/aigroup-stata-mcp/)
|
|
35
|
+
|
|
36
|
+
一个基于 Model Context Protocol (MCP) 的 Stata 集成服务器,允许 AI 助手执行 Stata 脚本、获取数据信息和运行统计分析。
|
|
37
|
+
|
|
38
|
+
## 功能特性
|
|
39
|
+
|
|
40
|
+
### 🚀 核心功能
|
|
41
|
+
- **Stata 脚本执行**: 执行 `.do` 文件并捕获日志输出
|
|
42
|
+
- **数据信息获取**: 支持 `.dta` 和 `.csv` 文件的描述性统计
|
|
43
|
+
- **Stata 命令帮助**: 获取 Stata 内置命令的帮助文档
|
|
44
|
+
- **SSC 包管理**: 从 SSC 仓库安装和管理 Stata 包
|
|
45
|
+
- **文件操作**: 创建、读取和写入 Stata 脚本文件
|
|
46
|
+
|
|
47
|
+
### 🔧 技术特性
|
|
48
|
+
- **跨平台支持**: Windows、macOS 和 Linux
|
|
49
|
+
- **自动 Stata 检测**: 自动查找系统上的 Stata 安装路径
|
|
50
|
+
- **多传输协议**: 支持 stdio、SSE、HTTP 和 streamable-http
|
|
51
|
+
- **结构化输出**: 使用 Pydantic 模型提供类型安全的响应
|
|
52
|
+
- **多语言支持**: 中英文界面和提示
|
|
53
|
+
|
|
54
|
+
### 📊 数据处理
|
|
55
|
+
- **数据格式支持**: Stata (.dta)、CSV (.csv) 文件
|
|
56
|
+
- **统计分析**: 描述性统计、变量分析
|
|
57
|
+
- **URL 数据源**: 支持从 URL 直接读取数据文件
|
|
58
|
+
- **智能编码检测**: 自动检测文件编码和分隔符
|
|
59
|
+
|
|
60
|
+
## 快速开始
|
|
61
|
+
|
|
62
|
+
### 系统要求
|
|
63
|
+
|
|
64
|
+
- **Python**: 3.11 或更高版本
|
|
65
|
+
- **Stata**: 已安装并配置好环境变量
|
|
66
|
+
- **MCP 客户端**: Claude Desktop、Cherry Studio 或其他兼容 MCP 的客户端
|
|
67
|
+
|
|
68
|
+
### 安装
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# 使用 pip 安装
|
|
72
|
+
pip install aigroup-stata-mcp
|
|
73
|
+
|
|
74
|
+
# 或使用 uv 安装
|
|
75
|
+
uv add aigroup-stata-mcp
|
|
76
|
+
|
|
77
|
+
# 或使用 uvx 直接运行(无需安装)
|
|
78
|
+
uvx aigroup-stata-mcp
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 配置
|
|
82
|
+
|
|
83
|
+
#### Claude Desktop 配置
|
|
84
|
+
|
|
85
|
+
在 Claude Desktop 配置文件中添加以下内容:
|
|
86
|
+
|
|
87
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
88
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"mcpServers": {
|
|
93
|
+
"stata-mcp": {
|
|
94
|
+
"command": "uvx",
|
|
95
|
+
"args": ["aigroup-stata-mcp"],
|
|
96
|
+
"env": {
|
|
97
|
+
"STATA_CLI": "/path/to/your/stata/executable"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### 使用安装器
|
|
105
|
+
|
|
106
|
+
项目提供了自动安装工具:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# 检查系统兼容性
|
|
110
|
+
stata-mcp --usable
|
|
111
|
+
|
|
112
|
+
# 自动安装到 Claude Desktop
|
|
113
|
+
stata-mcp --install
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 可用工具
|
|
117
|
+
|
|
118
|
+
### Stata 工具
|
|
119
|
+
|
|
120
|
+
#### `stata_do`
|
|
121
|
+
执行 Stata do 文件并返回执行结果。
|
|
122
|
+
|
|
123
|
+
**参数:**
|
|
124
|
+
- `dofile_path`: do 文件路径
|
|
125
|
+
- `log_file_name`: 日志文件名(可选)
|
|
126
|
+
- `is_read_log`: 是否读取日志内容(默认: true)
|
|
127
|
+
|
|
128
|
+
**示例:**
|
|
129
|
+
```stata
|
|
130
|
+
regress price mpg weight
|
|
131
|
+
outreg2 using "results", replace
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### `get_data_info`
|
|
135
|
+
获取数据文件的描述性统计信息。
|
|
136
|
+
|
|
137
|
+
**参数:**
|
|
138
|
+
- `data_path`: 数据文件路径
|
|
139
|
+
- `vars_list`: 变量列表(可选)
|
|
140
|
+
- `encoding`: 文件编码(默认: utf-8)
|
|
141
|
+
- `file_extension`: 文件扩展名(可选)
|
|
142
|
+
- `is_save`: 是否保存结果到文件(默认: true)
|
|
143
|
+
|
|
144
|
+
**支持格式:**
|
|
145
|
+
- Stata 文件 (.dta)
|
|
146
|
+
- CSV 文件 (.csv, .txt, .tsv)
|
|
147
|
+
|
|
148
|
+
#### `help`
|
|
149
|
+
获取 Stata 命令的帮助文档。
|
|
150
|
+
|
|
151
|
+
**参数:**
|
|
152
|
+
- `cmd`: Stata 命令名称
|
|
153
|
+
|
|
154
|
+
**示例:**
|
|
155
|
+
```stata
|
|
156
|
+
help regress
|
|
157
|
+
help summarize
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### `ssc_install`
|
|
161
|
+
从 SSC 仓库安装 Stata 包。
|
|
162
|
+
|
|
163
|
+
**参数:**
|
|
164
|
+
- `command`: 包名称
|
|
165
|
+
- `is_replace`: 是否替换已安装版本(默认: true)
|
|
166
|
+
|
|
167
|
+
### 文件工具
|
|
168
|
+
|
|
169
|
+
#### `write_dofile`
|
|
170
|
+
创建新的 Stata do 文件。
|
|
171
|
+
|
|
172
|
+
**参数:**
|
|
173
|
+
- `content`: Stata 代码内容
|
|
174
|
+
- `encoding`: 文件编码(默认: utf-8)
|
|
175
|
+
|
|
176
|
+
#### `append_dofile`
|
|
177
|
+
向现有 do 文件追加内容或创建新文件。
|
|
178
|
+
|
|
179
|
+
**参数:**
|
|
180
|
+
- `original_dofile_path`: 原始 do 文件路径
|
|
181
|
+
- `content`: 要追加的 Stata 代码
|
|
182
|
+
- `encoding`: 文件编码(默认: utf-8)
|
|
183
|
+
|
|
184
|
+
#### `read_file`
|
|
185
|
+
读取文件内容。
|
|
186
|
+
|
|
187
|
+
**参数:**
|
|
188
|
+
- `file_path`: 文件路径
|
|
189
|
+
- `encoding`: 文件编码(默认: utf-8)
|
|
190
|
+
|
|
191
|
+
#### `load_figure`
|
|
192
|
+
加载图片文件。
|
|
193
|
+
|
|
194
|
+
**参数:**
|
|
195
|
+
- `figure_path`: 图片文件路径(支持 png、jpg 格式)
|
|
196
|
+
|
|
197
|
+
### 核心工具
|
|
198
|
+
|
|
199
|
+
#### `mk_dir`
|
|
200
|
+
安全创建目录。
|
|
201
|
+
|
|
202
|
+
**参数:**
|
|
203
|
+
- `path`: 目录路径
|
|
204
|
+
|
|
205
|
+
## 可用提示
|
|
206
|
+
|
|
207
|
+
### `stata_assistant_role`
|
|
208
|
+
获取 Stata 助手角色定义提示。
|
|
209
|
+
|
|
210
|
+
**参数:**
|
|
211
|
+
- `lang`: 语言代码(en/cn,可选)
|
|
212
|
+
|
|
213
|
+
### `stata_analysis_strategy`
|
|
214
|
+
获取 Stata 分析策略指南。
|
|
215
|
+
|
|
216
|
+
**参数:**
|
|
217
|
+
- `lang`: 语言代码(en/cn,可选)
|
|
218
|
+
|
|
219
|
+
### `results_doc_path`
|
|
220
|
+
生成结果文档存储路径。
|
|
221
|
+
|
|
222
|
+
## 项目结构
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
stata_mcp/
|
|
226
|
+
├── core/ # 核心功能模块
|
|
227
|
+
│ ├── data_info/ # 数据信息处理
|
|
228
|
+
│ │ ├── _base.py # 数据信息基类
|
|
229
|
+
│ │ ├── dta.py # Stata 文件处理
|
|
230
|
+
│ │ └── csv.py # CSV 文件处理
|
|
231
|
+
│ └── stata/ # Stata 集成
|
|
232
|
+
│ ├── stata_controller/ # Stata 会话控制
|
|
233
|
+
│ ├── stata_do/ # do 文件执行器
|
|
234
|
+
│ └── stata_finder/ # Stata 路径查找器
|
|
235
|
+
├── server/ # MCP 服务器实现
|
|
236
|
+
│ ├── tools/ # MCP 工具定义
|
|
237
|
+
│ │ ├── core_tools.py # 核心工具
|
|
238
|
+
│ │ ├── file_tools.py # 文件工具
|
|
239
|
+
│ │ └── stata_tools.py # Stata 工具
|
|
240
|
+
│ ├── prompts/ # MCP 提示定义
|
|
241
|
+
│ └── main.py # 服务器主程序
|
|
242
|
+
├── utils/ # 工具类
|
|
243
|
+
│ ├── Installer/ # 安装器
|
|
244
|
+
│ ├── Prompt/ # 提示管理
|
|
245
|
+
│ └── usable.py # 系统兼容性检查
|
|
246
|
+
└── cli/ # 命令行接口
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## 开发指南
|
|
250
|
+
|
|
251
|
+
### 环境设置
|
|
252
|
+
|
|
253
|
+
1. 克隆仓库:
|
|
254
|
+
```bash
|
|
255
|
+
git clone https://github.com/jackdark425/aigroup-stata-mcp.git
|
|
256
|
+
cd aigroup-stata-mcp
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
2. 安装开发依赖:
|
|
260
|
+
```bash
|
|
261
|
+
pip install -e ".[dev]"
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
3. 运行测试:
|
|
265
|
+
```bash
|
|
266
|
+
python -m pytest
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### 添加新工具
|
|
270
|
+
|
|
271
|
+
在 `src/stata_mcp/server/tools/` 目录下创建新的工具文件:
|
|
272
|
+
|
|
273
|
+
```python
|
|
274
|
+
from mcp.server.fastmcp import Context, FastMCP
|
|
275
|
+
from pydantic import BaseModel, Field
|
|
276
|
+
|
|
277
|
+
class MyToolResult(BaseModel):
|
|
278
|
+
result: str = Field(description="Tool execution result")
|
|
279
|
+
|
|
280
|
+
def register_my_tools(server: FastMCP) -> None:
|
|
281
|
+
@server.tool()
|
|
282
|
+
def my_tool(ctx: Context, param: str) -> MyToolResult:
|
|
283
|
+
"""Tool description."""
|
|
284
|
+
# Tool implementation
|
|
285
|
+
return MyToolResult(result="Success")
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
然后在 `src/stata_mcp/server/main.py` 中注册新工具。
|
|
289
|
+
|
|
290
|
+
## 故障排除
|
|
291
|
+
|
|
292
|
+
### 常见问题
|
|
293
|
+
|
|
294
|
+
1. **Stata 未找到**
|
|
295
|
+
- 确保 Stata 已正确安装
|
|
296
|
+
- 手动设置 `STATA_CLI` 环境变量
|
|
297
|
+
- 使用 `stata-mcp --usable` 检查配置
|
|
298
|
+
|
|
299
|
+
2. **权限错误**
|
|
300
|
+
- 确保对工作目录有读写权限
|
|
301
|
+
- 检查防火墙设置
|
|
302
|
+
|
|
303
|
+
3. **编码问题**
|
|
304
|
+
- 指定正确的文件编码
|
|
305
|
+
- 使用 UTF-8 编码处理中文数据
|
|
306
|
+
|
|
307
|
+
### 调试模式
|
|
308
|
+
|
|
309
|
+
启用详细日志输出:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
stata-mcp --verbose
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## 贡献指南
|
|
316
|
+
|
|
317
|
+
我们欢迎贡献!请参阅 [CONTRIBUTING.md](CONTRIBUTING.md) 了解详细信息。
|
|
318
|
+
|
|
319
|
+
1. Fork 项目
|
|
320
|
+
2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
|
|
321
|
+
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
|
322
|
+
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
323
|
+
5. 打开 Pull Request
|
|
324
|
+
|
|
325
|
+
## 许可证
|
|
326
|
+
|
|
327
|
+
本项目基于 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详细信息。
|
|
328
|
+
|
|
329
|
+
## 致谢
|
|
330
|
+
|
|
331
|
+
- [Model Context Protocol](https://spec.modelcontextprotocol.io/) - 提供协议规范
|
|
332
|
+
- [Stata](https://www.stata.com/) - 统计分析软件
|
|
333
|
+
- [FastMCP](https://github.com/modelcontextprotocol/python-sdk) - Python MCP SDK
|
|
334
|
+
|
|
335
|
+
## 支持
|
|
336
|
+
|
|
337
|
+
如果您遇到问题或有建议,请:
|
|
338
|
+
|
|
339
|
+
1. 查看 [问题页面](https://github.com/jackdark425/aigroup-stata-mcp/issues)
|
|
340
|
+
2. 创建新的 issue
|
|
341
|
+
3. 联系维护者: jackdark425@gmail.com
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
**注意**: 本项目与 StataCorp LLC 无关,Stata 是 StataCorp LLC 的注册商标。
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
stata_mcp/__init__.py,sha256=UlHcx94B_pFLtMKtnvWlqI6JMRJ_ETJG_AE4-0dUDAM,457
|
|
2
|
+
stata_mcp/cli/__init__.py,sha256=U4LOJljU47SzkjOSxKUiaDNMGCW3HOgh6ZhxX1CKTnA,123
|
|
3
|
+
stata_mcp/cli/_cli.py,sha256=W5h2eUt-Vt09GSnyvhl7tkvuGhYO6nI9ZZHHeDbsZCQ,2744
|
|
4
|
+
stata_mcp/core/__init__.py,sha256=fTtW3jXgKbh2A9bsZIuzsOvCnKmhms8C9yRG11K6gQg,112
|
|
5
|
+
stata_mcp/core/data_info/__init__.py,sha256=-tmDrCPzlpQYB_3SE4kMpdQJCj92wYCvIqIgEH7aAEc,167
|
|
6
|
+
stata_mcp/core/data_info/_base.py,sha256=728AEtqnzKdb2cmc39i3B4ydvQIqg2lPihk1xNhTSC8,9271
|
|
7
|
+
stata_mcp/core/data_info/csv.py,sha256=ReSiYzw6M52mrjk8TYqsTQGqc3CR64fErOSDuYSUVgo,4680
|
|
8
|
+
stata_mcp/core/data_info/dta.py,sha256=xMw_bW1cZGpL84GBh0fPmtgDLbuLI7PcHVOYpfgS1dQ,2381
|
|
9
|
+
stata_mcp/core/stata/__init__.py,sha256=QCPzqyFc6yxJDZ6b5SEhWyC3ULpBZkjJ3opOlJMfoHE,243
|
|
10
|
+
stata_mcp/core/stata/stata_controller/__init__.py,sha256=t3EQvpziZUkmZAINKU6Zqkd1kfkvWz5qtvpDq-I6lnY,132
|
|
11
|
+
stata_mcp/core/stata/stata_controller/controller.py,sha256=wZZVDerCiWqE16FniFn63XnxanEyH76eW1vW94Xb1pE,6881
|
|
12
|
+
stata_mcp/core/stata/stata_do/__init__.py,sha256=v4ufdO-4nYpAS0qfElq8-Dq9bTUKHM6ZmsdCXKla-8I,107
|
|
13
|
+
stata_mcp/core/stata/stata_do/do.py,sha256=S7XYYXQQhzGweEq1IfK38qZJrpjNy3al9pVoFQE2xDA,6315
|
|
14
|
+
stata_mcp/core/stata/stata_finder/__init__.py,sha256=AUWPgZjiVDoFFmYaS7nVyeyN0lTTGQWBzd3MFD7j5bs,120
|
|
15
|
+
stata_mcp/core/stata/stata_finder/base.py,sha256=ro5KZHrhVi14UqcF1OZ0EJTmgnQb-VhNR8Xi7L1CNKU,9889
|
|
16
|
+
stata_mcp/core/stata/stata_finder/finder.py,sha256=EoPwgO553NCosUTekC6c75ASHsMgabqBMKUEi9S1Uy8,6311
|
|
17
|
+
stata_mcp/core/stata/stata_finder/linux.py,sha256=4-OLymLoxfk1uOuopZstKNNJhxI0IZXqjZ1rFv334F8,1260
|
|
18
|
+
stata_mcp/core/stata/stata_finder/macos.py,sha256=HQJ0EyjOxpUvLFEb6u9V8qh4sCfu_vKNEpn4dTI2h9A,3397
|
|
19
|
+
stata_mcp/core/stata/stata_finder/windows.py,sha256=GZuWS5ZGQuRuzy-lE00ho_vMeZUIOx69P56GQ2PPQKE,6823
|
|
20
|
+
stata_mcp/server/__init__.py,sha256=0eBdEYx1VwIxKWb1vMyXOwPRM24Vdtk7u4-g4RL4YDU,156
|
|
21
|
+
stata_mcp/server/main.py,sha256=RgpZRh6MVkvBNBzKhPyDXLUGpXRi_y4H9HrwumEGeAY,4976
|
|
22
|
+
stata_mcp/server/prompts/__init__.py,sha256=LZ-_iNpYQlAHTWtFJsQjRibiKOEK1_j3SgCn8aoazQA,169
|
|
23
|
+
stata_mcp/server/prompts/core_prompts.py,sha256=9w6-mzFUh-jFGWxqzuRglGnjxlBPpoU7HxBv06Ww_ow,4978
|
|
24
|
+
stata_mcp/server/tools/__init__.py,sha256=pUifpy73eDW3f90JcKjhrrTPTwAQc5AsKw0-bOW0f1Y,300
|
|
25
|
+
stata_mcp/server/tools/core_tools.py,sha256=Q3nRH8jI6TUdQsa1tq9NZR_1NOkx8xuVHnq1e3zMXLc,2071
|
|
26
|
+
stata_mcp/server/tools/file_tools.py,sha256=3xZQ7NkSSrDowRqIHhe3gWK6MYHDM0Bu6G-o-tgE3Bo,6427
|
|
27
|
+
stata_mcp/server/tools/stata_tools.py,sha256=o3yjyMQ7mEWlTQvLAWaPd7xsNBKAhrMZ2bjFV56YEow,8283
|
|
28
|
+
stata_mcp/utils/__init__.py,sha256=bJ6wXXLvVWGILsguhrKWLUq2PxYhcsHG5KQ0EI41gbs,486
|
|
29
|
+
stata_mcp/utils/usable.py,sha256=p90bQ1_sdO4Bq6BY9Ah6Ka2NwRV89FG42UJos-5cKJQ,8025
|
|
30
|
+
stata_mcp/utils/Installer/__init__.py,sha256=yBza9nOoSTR2-Lk9eSCzmiok1DS-duacRcjv0Fgfl_k,110
|
|
31
|
+
stata_mcp/utils/Installer/installer.py,sha256=jRqxEATp9E09BMz1SxFwpNuDH7gNF5HKf3wREkE_Fys,3041
|
|
32
|
+
stata_mcp/utils/Prompt/__init__.py,sha256=7bgikghCBr-rLOjie48We766nRBH4Yuzl9ARZpbd8HY,2047
|
|
33
|
+
stata_mcp/utils/Prompt/string.py,sha256=wSyDZbZkK28TLz7qUunFzOr0OzjCoEPcCTOWYybysLM,4768
|
|
34
|
+
aigroup_stata_mcp-1.0.3.dist-info/METADATA,sha256=jYkCDW1tbxi5G1yRQAXrcpyqLzOU8z2AC-fn-H8BOKA,9287
|
|
35
|
+
aigroup_stata_mcp-1.0.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
36
|
+
aigroup_stata_mcp-1.0.3.dist-info/entry_points.txt,sha256=9Tts_0fSVdmoWZlH_EBPw3vKrvvPKt6Ngjccoo6BxTE,139
|
|
37
|
+
aigroup_stata_mcp-1.0.3.dist-info/licenses/LICENSE,sha256=JFoUmc-vAC0k4-jjI6qyO8x7a7w1ddlitHdaOHVp9Lo,1092
|
|
38
|
+
aigroup_stata_mcp-1.0.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Sepine Tam, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
stata_mcp/__init__.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
__version__ = version("aigroup-stata-mcp")
|
|
9
|
+
except PackageNotFoundError:
|
|
10
|
+
# Fallback for development mode when package is not installed
|
|
11
|
+
__version__ = "1.0.3"
|
|
12
|
+
|
|
13
|
+
__author__ = "jackdark425 <jackdark425@gmail.com>"
|
|
14
|
+
__team__ = "aigroup"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
if __name__ == "__main__":
|
|
18
|
+
print(f"Hello aigroup-stata-mcp@version{__version__}")
|
stata_mcp/cli/_cli.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
9
|
+
from typing import Optional
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_version() -> str:
|
|
13
|
+
"""Get the package version, handling cases where package is not installed."""
|
|
14
|
+
try:
|
|
15
|
+
return version("aigroup-stata-mcp")
|
|
16
|
+
except PackageNotFoundError:
|
|
17
|
+
# Fallback for development mode
|
|
18
|
+
try:
|
|
19
|
+
# Try to read from pyproject.toml
|
|
20
|
+
import tomllib
|
|
21
|
+
with open("pyproject.toml", "rb") as f:
|
|
22
|
+
data = tomllib.load(f)
|
|
23
|
+
return data.get("project", {}).get("version", "1.0.0-dev")
|
|
24
|
+
except (FileNotFoundError, ImportError):
|
|
25
|
+
return "1.0.0-dev"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def main() -> None:
|
|
29
|
+
"""Entry point for the command line interface."""
|
|
30
|
+
parser = argparse.ArgumentParser(
|
|
31
|
+
prog="aigroup-stata-mcp",
|
|
32
|
+
description="Stata-MCP command line interface",
|
|
33
|
+
add_help=True)
|
|
34
|
+
parser.add_argument(
|
|
35
|
+
"-v",
|
|
36
|
+
"--version",
|
|
37
|
+
action="version",
|
|
38
|
+
version=f"Stata-MCP version is {get_version()}",
|
|
39
|
+
help="show version information",
|
|
40
|
+
)
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
"-c", "--client",
|
|
43
|
+
nargs="?",
|
|
44
|
+
const="cc",
|
|
45
|
+
help="set the client mode (default for Claude Code)"
|
|
46
|
+
)
|
|
47
|
+
parser.add_argument(
|
|
48
|
+
"--usable",
|
|
49
|
+
action="store_true",
|
|
50
|
+
help="check whether Stata-MCP could be used on this computer",
|
|
51
|
+
)
|
|
52
|
+
parser.add_argument(
|
|
53
|
+
"--install",
|
|
54
|
+
action="store_true",
|
|
55
|
+
help="install Stata-MCP to Claude Desktop")
|
|
56
|
+
|
|
57
|
+
# mcp.run
|
|
58
|
+
parser.add_argument(
|
|
59
|
+
"-t",
|
|
60
|
+
"--transport",
|
|
61
|
+
choices=["stdio", "sse", "http", "streamable-http"],
|
|
62
|
+
default=None,
|
|
63
|
+
help="mcp server transport method (default: stdio)",
|
|
64
|
+
)
|
|
65
|
+
args = parser.parse_args()
|
|
66
|
+
|
|
67
|
+
if args.usable:
|
|
68
|
+
from stata_mcp.utils.usable import usable
|
|
69
|
+
sys.exit(usable())
|
|
70
|
+
|
|
71
|
+
elif args.install:
|
|
72
|
+
from stata_mcp.utils.Installer import Installer
|
|
73
|
+
Installer(sys_os=sys.platform).install()
|
|
74
|
+
|
|
75
|
+
elif args.client:
|
|
76
|
+
os.environ["STATA-MCP-CLIENT"] = "cc"
|
|
77
|
+
from stata_mcp.server import run_server
|
|
78
|
+
run_server()
|
|
79
|
+
|
|
80
|
+
else:
|
|
81
|
+
from stata_mcp.server import run_server
|
|
82
|
+
|
|
83
|
+
print("Starting Stata-MCP...")
|
|
84
|
+
|
|
85
|
+
# Use stdio if there is no transport argument
|
|
86
|
+
transport = args.transport or "stdio"
|
|
87
|
+
if transport == "http":
|
|
88
|
+
transport = (
|
|
89
|
+
"streamable-http" # Default to streamable-http for HTTP transport
|
|
90
|
+
)
|
|
91
|
+
run_server(transport=transport)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
if __name__ == "__main__":
|
|
95
|
+
main()
|