ANSA API MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ANSA API MCP Serverhow to delete all shell elements?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ANSA API MCP Server
基于 Model Context Protocol (MCP) 的 ANSA Python API 智能搜索服务。让 Claude Code 能够直接搜索和理解 ANSA API 文档,辅助用户编写 ANSA 脚本。
项目介绍
ANSA 是业界广泛使用的 CAE 前处理软件,其 Python API 包含 2379 个函数,分布在 20 个模块中。面对如此庞大的 API 体系,开发者往往难以快速找到所需的函数。
本项目将 ANSA API 文档构建为结构化索引,并通过 MCP 协议暴露给 Claude Code,使 AI 能够:
理解用户的自然语言意图(中英文均可)
精准定位对应的 ANSA API 函数
返回函数签名、参数说明和代码示例
覆盖的模块
模块 | 说明 |
| 基础操作(查询、创建、修改、删除实体) |
| 网格操作(划分、质量检查、编辑) |
| 形状变形(映射、变形控制) |
| 连接管理(焊点、螺栓等) |
| 数据管理 |
| 计算工具 |
| 运动学分析 |
| 批量网格处理 |
| 报告生成 |
| CAD 导入导出 |
以及 10 个其他模块... |
Related MCP server: UseKeen Documentation MCP Server
功能特性
三层搜索策略
用户查询 → Layer 1: 关键词匹配
↓ (结果不足)
Layer 2: 模糊子串搜索
↓ (结果不足)
Layer 3: TXT 文档全文兜底关键词匹配 — 基于预生成的中英文关键词索引,精确匹配最相关的函数
模糊搜索 — 在函数签名和描述中进行子串匹配,补充关键词未覆盖的结果
TXT 文档兜底 — 在完整的 API 文档全文中搜索,确保不遗漏
中英文双语支持
内置中英文关键词映射,支持用中文描述需求:
用户: "删除网格" → ansa.mesh.DeleteElements
用户: "delete mesh" → ansa.mesh.DeleteElements智能结果排序
关键词命中数越多,排名越靠前
返回函数签名、模块、分类、参数列表和代码示例
支持按
module和category过滤
安装教程
前置条件
Python 3.10+
Claude Code 已安装
第一步:安装 MCP Server
方式 A:有 Git 环境
pip install git+https://github.com/RufengLai/ansa-api-mcp.git方式 B:没有 Git 环境
# 下载 zip
Invoke-WebRequest -Uri "https://codeload.github.com/RufengLai/ansa-api-mcp/zip/refs/heads/master" -OutFile "$env:TEMP\ansa-api-mcp.zip"
Expand-Archive -Path "$env:TEMP\ansa-api-mcp.zip" -DestinationPath "$env:TEMP" -Force
# 安装
cd "$env:TEMP\ansa-api-mcp-master"
pip install -e .第二步:注册到 Claude Code
ansa-api-mcp install输出示例:
Successfully registered ansa-api MCP server in Claude Code!
Config: C:\Users\XXX\.claude.json
Command: C:\...\Scripts\ansa-api-mcp.EXE
Restart Claude Code to start using it.第三步:重启 Claude Code
重启后即可使用 search_ansa_api 工具搜索 ANSA API。
使用示例
在 Claude Code 中直接用自然语言描述需求,AI 会自动调用搜索工具:
你: 帮我写一个删除所有 shell 单元的脚本
AI: [调用 search_ansa_api("删除 shell")]
→ 找到 ansa.mesh.DeleteElements()
→ 生成完整脚本你: 如何获取某个 PID 下的所有单元?
AI: [调用 search_ansa_api("get elements by pid", module="ansa.base")]
→ 找到 ansa.base.CollectEntities()
→ 生成查询代码搜索工具参数
参数 | 类型 | 说明 |
| string | 搜索关键词,支持中英文 |
| string | 按模块过滤,如 |
| string | 按分类过滤,如 |
| int | 返回结果数量,默认 5 |
技术架构
ansa-api-mcp/
├── tools/
│ ├── mcp_server.py # MCP Server (FastMCP) + 三层搜索引擎
│ ├── parse_html.py # Sphinx HTML 文档解析器
│ ├── generate_keywords.py # AI 关键词生成 (Anthropic SDK)
│ ├── generate_index.py # 索引构建流水线
│ ├── ansa_api_index.json # 预构建索引 (2379 函数)
│ └── txt_docs/ # ANSA API 全量 TXT 文档 (26 文件)
├── tests/ # 测试套件 (26 个测试)
├── pyproject.toml # 包配置
└── demo/ # 示例 ANSA 脚本索引构建
索引通过以下流水线生成:
HTML 解析 — 从 ANSA Sphinx 文档中提取函数签名、参数、描述、示例
分类标注 — 根据函数名和模块自动分类(mesh_edit、base_query 等)
关键词生成 — 调用 AI 为每个函数生成中英文搜索关键词
输出索引 — 生成
ansa_api_index.json,供运行时搜索使用
MCP 协议
本项目使用 MCP Python SDK 的 FastMCP 框架,通过 stdio 协议与 Claude Code 通信。Claude Code 在需要查询 ANSA API 时自动调用 search_ansa_api 工具。
高级配置
自定义 TXT 文档路径
如果你有更新版本的 ANSA TXT 文档,可通过环境变量覆盖内置文档。编辑 ~/.claude.json:
{
"mcpServers": {
"ansa-api": {
"type": "stdio",
"command": "ansa-api-mcp",
"args": [],
"env": {
"ANSA_TXT_DOCS_PATH": "C:/path/to/your/txt_docs"
}
}
}
}重新生成索引
如果需要为不同版本的 ANSA 重新生成索引:
# 需要 Anthropic API Key 用于关键词生成
export ANTHROPIC_API_KEY="your-key"
python -m tools.generate_index故障排查
MCP 服务器在 Claude Code 中不可见
确认配置写入了正确的文件:
~/.claude.json(不是~/.claude/settings.json)确认配置格式包含必要字段:
{ "mcpServers": { "ansa-api": { "type": "stdio", "command": "C:\\path\\to\\ansa-api-mcp.EXE", "args": [], "env": {} } } }运行
claude mcp list查看已注册的 MCP 服务器重启 Claude Code
pip install 报错 "Cannot find command 'git'"
说明没有安装 Git,请使用方式 B(zip 下载)安装。
开发
# 克隆仓库
git clone https://github.com/RufengLai/ansa-api-mcp.git
cd ansa-api-mcp
# 安装开发依赖
pip install -e ".[dev]"
# 运行测试
pytest tests/ -vLicense
MIT
Available Tools
1 toolsearch_ansa_apiA
Search the ANSA Python API documentation.
Args: query: Search query (supports Chinese and English keywords) module: Filter by module name (e.g. "ansa.mesh", "ansa.base") category: Filter by category (e.g. "mesh_edit", "base_query") top_n: Maximum number of results to return (default 5)
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| module | No | ||
| category | No | ||
| top_n | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the burden. It mentions keyword language support but does not disclose non-obvious behaviors like rate limits, pagination (only top_n count), or result format. Moderate transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is structured with an Args section and is reasonably concise. However, it could be slightly shortened by removing the default value repetition for top_n (already in schema) without losing clarity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The parameter semantics are well-covered, but the description omits what the search returns (e.g., list of documentation sections, relevance scores). An output schema is present but not seen; assuming it covers return structure, the description still lacks context on search scope (e.g., full text vs title only).
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description fully compensates. Each parameter is explained with examples (e.g., module: 'ansa.mesh', category: 'mesh_edit'), and top_n includes a default value. This adds significant meaning beyond the schema's type/title-only definitions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'Search the ANSA Python API documentation' with a specific verb and resource, and includes details about keyword support. Although no sibling tools exist for differentiation, the purpose is unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when or when not to use this tool. With no sibling tools, the lack of alternatives context is less critical, but the description does not mention any prerequisites or ideal use cases, resulting in a neutral score.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
1 tool update
v0.1.0- First observed
search_ansa_api
TDQS
With only one tool, there is no possibility of confusion or overlap. The tool has a clear and singular purpose of searching the ANSA API documentation.
The single tool follows a consistent verb_noun pattern ('search_ansa_api'), which is clear and predictable.
One tool is appropriate for a focused documentation search server. While minimal, it aligns with the server's narrow scope.
The tool provides comprehensive search functionality with query, module, category filters, and result limiting. Minor gaps like listing available modules or categories exist but are not critical for the core search task.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Search and query nTop's knowledge base and engineering guides from AI applications.
Versioned documentation registry and semantic search for AI tools and coding assistants.
Search @imqueue docs and scaffold typed services & clients from your AI coding agent.
Search NVIDIA CUDA documentation and code samples from AI coding agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to search documentation of packages and services to find implementation details, examples, and specifications.MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to search for documentation of packages and services, providing implementation details, examples, and specifications through a specialized API.1182MIT
- AlicenseNot gradedqualityNot gradedmaintenanceEnables access to scientific simulation documentation and code snippets for simulators like PyBaMM and Cantera. Provides AI-powered search and retrieval of simulation examples and documentation through natural language queries.-
- AlicenseNot gradedqualityCmaintenanceEnables search and lookup of SolidWorks API documentation, including methods, interfaces, enums, and examples, via natural language queries.167MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/RufengLai/ansa-api-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server