sastol——基于SASPy的SAS集成MCP服务器
此存储库包含最小 模型上下文协议(MCP) 将以下SAS驱动的工具暴露给MCP兼容客户端的服务器(例如,Claude Desktop、GitHub CoPilot):
| 工具名称 | 描述 |
|---|---|
run_sas(code) | 运行SAS代码并返回LOG+HTML结果 |
list_libs() | 列出分配的SAS/CAS库 |
list_tables(libname) | 列出SAS库中的表 |
list_directory(path) | 列出SAS服务器上的文件 |
save_code(path, filename, content) | 远程保存SAS代码 |
______________________________________________________________________
特性
- ✅ 通过SAS日志和列表输出清理MCP
- ✅ 退货
LOG和LST来自SASPy - ✅ 与Claude Desktop轻松集成
SASPy配置
SASPy需要一个配置,指定它如何连接到SAS。要配置SASPy,请按照说明进行操作 这里.
与Claude Desktop一起使用
点击观看演示

编辑claude_desktop_config.json:
{
"mcpServers": {
"sastool": {
"command": ",/absolute/path/to/.venv/bin/python or uv>",
"args": ["run", "--with", "mcp[cli]","/absolute/path/to/server.py"],
"env": {
"SAS_CONFIG_NAMES": "default",
"PYTHONUNBUFFERED": "1"
},
"disabled": false
}
}
}Claude示例流程
sequenceDiagram
autonumber
participant U as User
participant C as Claude Desktop
(Sonnet 4.5)
participant M as MCP Server
(server.py / FastMCP)
participant P as SASPy
participant VC as SAS Viya Compute
participant CAS as CAS / CASLIBs
U->>C: Analysis request from user
C->>C: Generate SAS Code:code
C->>M: MCP tool call: runsascode(code)
M->>P: sas.submit(code, results='HTML')
P->>VC: Start compute session
VC->CAS: CAS Initiate
CAS-->>VC: Data access / processing
VC-->>P: Return LOG and ODS results
P-->>M: {"LOG": "...", "LST": "..."}
M-->>C: Return MCP JSON
C->>C: Evaluate and generate additional SAS code if needed
C-->>U: Display results (HTML tables/graphs)与GitHub桌面一起使用
编辑用户mcp.json配置
{
"servers": {
"sastoolmcp": {
"type": "stdio",
"command": "uv",
"args": [
"run",
"--with",
"mcp[cli]",
"mcp",
"run",
""
]
}
},
"inputs": []
}