pyNastran MCP服务器
  
pyNastran的模型上下文协议(MCP)服务器 FastMCP使AI代理能够与Nastran FEA模型进行交互。
特性
- 🔧 BDF工具:读取、写入和分析Nastran输入文件
- 📊 OP2工具:从Nastran输出文件中提取结果
- 🔍 几何图形工具:网格质量检查和几何分析
- 📝 分析工具:自动生成报告
- 🚀 FastMCP:采用现代FastMCP框架构建
- 🌐 多个传输:stdio、SSE和可流式传输的http
安装
pip install pynastran-mcp或者从源代码安装:
git clone https://github.com/Shaoqigit/pynastran-mcp.git
cd pynastran-mcp
pip install -e .快速开始
标准传输(默认)
对于Cherry Studio、Claude Desktop等MCP客户:
pynastran-mcp苏格兰和南方能源公司运输
# Default: host=127.0.0.1, port=8080
pynastran-mcp --transport sse
# Custom host and port
pynastran-mcp --transport sse --host 0.0.0.0 --port 8080流式HTTP传输(生产)
# Default: host=127.0.0.1, port=8080
pynastran-mcp --transport streamable-http
# Custom host and port
pynastran-mcp --transport streamable-http --host 0.0.0.0 --port 8080MCP客户端配置
樱桃工作室/光标/克劳德桌面
添加到MCP客户端配置中:
{
"mcpServers": {
"pynastran": {
"command": "pynastran-mcp"
}
}
}看 CHERRY_SDIO_TUTORIAL.md 有关详细的设置说明。
可用工具
BDF工具
| 工具 | 说明 |
|---|---|
read_bdf | 读取BDF文件并返回模型摘要 |
get_model_info | 获取详细的模型信息 |
write_bdf | 将模型写入新的BDF文件 |
get_nodes | 获取节点坐标 |
get_elements | 获取元素连接 |
get_materials | 获取材料属性 |
get_properties | 获取属性定义 |
OP2工具
| 工具 | 说明 |
|---|---|
read_op2 | 读取OP2结果文件 |
get_result_cases | 列出可用结果案例 |
get_stress | 提取压力结果 |
get_displacement | 提取位移结果 |
几何图形工具
| 工具 | 说明 |
|---|---|
check_mesh_quality | 检查网格质量指标 |
get_model_bounds | 获取模型边界框 |
分析工具
| 工具 | 说明 |
|---|---|
generate_report | 生成综合分析报告 |
用法示例
使用AI代理
配置后,您可以询问您的AI助手:
"Read the BDF file at /path/to/model.bdf and tell me about the mesh"
"Analyze the stress results from /path/to/results.op2"
"Check the mesh quality and suggest improvements"
"Generate a report for my Nastran model"程序化使用
from pynastran_mcp.tools.bdf_tools import BdfTools
from pynastran_mcp.tools.op2_tools import Op2Tools
async def analyze_model():
# BDF Analysis
bdf_tools = BdfTools()
summary = await bdf_tools.read_bdf("wing.bdf")
print(summary)
# OP2 Results
op2_tools = Op2Tools()
stresses = await op2_tools.get_stress("results.op2", element_type="CQUAD4")
print(stresses)项目结构
pynastran-mcp/
├── pynastran_mcp/
│ ├── __init__.py
│ ├── server.py # FastMCP server with all tools
│ └── tools/
│ ├── __init__.py
│ ├── bdf_tools.py # BDF file operations
│ ├── op2_tools.py # OP2 result operations
│ ├── geometry_tools.py # Mesh quality checks
│ └── analysis_tools.py # Report generation
├── pyproject.toml
├── README.md
└── examples/
└── example_usage.py需求
- Python 3.10+
- pyNastran>=1.4.0
- mcp>=1.0.0(使用FastMCP)
发展
# Setup
git clone https://github.com/Shaoqigit/pynastran-mcp.git
cd pynastran-mcp
pip install -e ".[dev]"
# Run tests
pytest
# Code formatting
black pynastran_mcp/许可证
MIT许可证-请参阅 许可证 文件
致谢
- pyNastran -底层Nastran接口库
- MCP Python SDK -FastMCP框架
贡献
欢迎投稿!请随时提交拉取请求。
- 分叉存储库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交您的更改(
git commit -m 'Add some amazing feature') - 推到分支(
git push origin feature/amazing-feature) - 打开拉取请求
请确保根据需要更新测试,并遵循现有的代码风格。
- pyNastran -底层Nastran接口库
- MCP Python SDK -FastMCP框架
