refactor: cad_mcp_aec 工具改按仓库既有格式描述,并合入 mcp_config.json
现象:上一版自己发明的描述文件 cad-mcp-aec.json 与仓库既有工具(add_line /
query_entities / get_entity_detail)的风格不一致——工具名前缀不同、
点用 {x,y,z} 对象而不是 [x,y] 数组、颜色叫 color_index 而不是 color。
另外 cad_mcp_frame 的运行期配置文件名是 mcp_config.json(找不到才回落
cad-mcp-frame.json),单个 cad-mcp-aec.json 还得手工合并。
改动:
1. 工具改名,与既有工具同一套动词_名词风格:
list_aec_entities -> query_aec_entities
get_aec_entity -> get_aec_entity_detail
create_aec_pipe|wall|slab|column|beam -> add_aec_*
2. 参数约定对齐既有工具:
- 点改用 [x,y] / [x,y,z] 数组(对象写法仍兼容,后端不变);
- 颜色用 color(ACI,256=ByLayer),并兼容旧写法 color_index;
- add_* 支持 space(Model 或布局名),缺省模型空间;
- get_aec_entity_detail 的输出也从 color_index 改成 color,和入参对称。
3. 删掉自定义的 cad-mcp-aec.json,把 12 个工具按标准 MCP 字段 + backend
(type/dll_name/factory_function)写进 cad_mcp_aec/mcp_config.json,
与既有 28 个工具同一份文件;inputSchema 写全,带每个参数的 description。
4. 插件里的 private_name()/private_input_schema() 同步成同一套名字与 schema,
保证配置里没写 schema 时回落也一致。
验证:
- R230 Debug / Z2026 Debug 均编译通过并部署。
- AutoCAD 2020 实测(部署目录放这份 mcp_config.json,cad_mcp_frame 优先读它):
tools/list = 30(既有 18 + 本插件 12),12 个 add_aec_*/update_aec_* 工厂全部加载成功;
query 列出 20 根管道;add_aec_pipe 用 [0,0,0]->[2000,0,0] + color=1 建成功,
detail 读回 dn_mm=100/od_mm=114/wall_thickness_mm=4/color=1;
只给 end 的 update 后端点变 2500、壁厚与颜色不变;
add_aec_wall/slab/column/beam 各建一次并读回参数一致。
已知(与本次改动无关):mcp_config.json 里有 10 个工具在仓库当前的
cad_mcp_plugins.dll 里没有对应工厂函数(AddText/AddMText/AddLine/AddPolyline/
AddLeaderAnnotation/DeleteEntities/SetEntityProperties/DrawRevisionCloud/
FindCollisions/SetDrawingArea),会被静默丢掉,补齐需要先把那些工具的实现
补进 cad_mcp_plugins。
This commit is contained in:
1 parent
c85b1b645e
commit
4f1ea72e4e
4 files changed
+1769
-139
No files matched your search
@@ -91,8 +91,9 @@ nlohmann::json paramsOf(AcDbEntity* pEnt, const std::string& sType)
|
||||
if (pX->GetAt(PIPE_SYS, s)) p["system"] = acharToUtf8(s);
|
||||
if (pX->GetAt(PIPE_MATERIAL, s)) p["material"] = acharToUtf8(s);
|
||||
|
||||
// 与入参统一用 color(ACI);老字段名 color_index 不再输出
|
||||
int nClr = 0;
|
||||
if (pX->GetAt(_T("COLOR"), nClr)) p["color_index"] = nClr;
|
||||
if (pX->GetAt(_T("COLOR"), nClr)) p["color"] = nClr;
|
||||
}
|
||||
}
|
||||
else if (sType == kTypeWall)
|
||||
@@ -188,7 +189,7 @@ nlohmann::json summaryOf(AcDbEntity* pEnt)
|
||||
class ToolListAecEntities : public mcp_Tool
|
||||
{
|
||||
public:
|
||||
std::string private_name() const override { return "list_aec_entities"; }
|
||||
std::string private_name() const override { return "query_aec_entities"; }
|
||||
|
||||
std::string private_description() const override
|
||||
{
|
||||
@@ -286,7 +287,7 @@ EXPORT_MCP_TOOL(ToolListAecEntities, ListAecEntitiesTool)
|
||||
class ToolGetAecEntity : public mcp_Tool
|
||||
{
|
||||
public:
|
||||
std::string private_name() const override { return "get_aec_entity"; }
|
||||
std::string private_name() const override { return "get_aec_entity_detail"; }
|
||||
|
||||
std::string private_description() const override
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user