@atlisp/mcp 1.6.6 → 1.6.7

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.
Files changed (2) hide show
  1. package/dist/atlisp-mcp.js +81 -27
  2. package/package.json +1 -1
@@ -23,7 +23,7 @@ var FILE_EXTENSIONS = {
23
23
  "BricsCAD": [".des"]
24
24
  };
25
25
  var SERVER_NAME = "atlisp-mcp-server";
26
- var SERVER_VERSION = "1.6.4";
26
+ var SERVER_VERSION = "1.6.7";
27
27
  var MOCK_PACKAGES = [
28
28
  { name: "base", description: "\u57FA\u7840\u51FD\u6570\u5E93", version: "1.0.0" },
29
29
  { name: "at-pm", description: "\u5DE5\u7A0B\u9879\u76EE\u7BA1\u7406", version: "2.1.0" },
@@ -610,6 +610,58 @@ var __dirname2 = path4.dirname(fileURLToPath2(import.meta.url));
610
610
  var STANDARDS_DIR = path4.join(__dirname2, "..", "standards");
611
611
  var CACHE_TTL = config_default.resourceCacheTtl;
612
612
  var resourceCache = /* @__PURE__ */ new Map();
613
+ var ENTITY_PROPERTIES_LISP = `
614
+ (defun entity:to-list (val)
615
+ (cond
616
+ ((= (type val) 'VARIANT) (entity:to-list (vlax-variant-value val)))
617
+ ((= (type val) 'SAFEARRAY) (vlax-safearray->list val))
618
+ (T val)))
619
+
620
+ (defun entity:try-get (obj names / result val)
621
+ (foreach name names
622
+ (if (not (vl-catch-all-error-p
623
+ (setq val (vl-catch-all-apply
624
+ (function vlax-get-property)
625
+ (list obj name)))))
626
+ (setq result (cons (cons name (entity:to-list val)) result))))
627
+ (reverse result))
628
+
629
+ (setq *common-props* '(ObjectName Handle Layer Color Linetype LinetypeScale Lineweight Visibility Material))
630
+
631
+ (setq *entity-props*
632
+ '((AcDbLine StartPoint EndPoint Angle Delta Length Thickness Normal)
633
+ (AcDbCircle Center Radius Diameter Circumference Area Thickness Normal)
634
+ (AcDbArc Center Radius StartAngle EndAngle TotalAngle ArcLength Area Normal)
635
+ (AcDbPoint Position Thickness Normal)
636
+ (AcDbText TextString Position Height Width ObliqueAngle Rotation StyleName HorizontalAlignment VerticalAlignment Normal Backward UpsideDown)
637
+ (AcDbMText TextString Location Height Width Rotation StyleName AttachmentPoint DrawingDirection LinespacingFactor LinespacingDistance LinespacingStyle FlowDirection)
638
+ (AcDbBlockReference Name InsertionPoint Rotation XScale YScale ZScale Normal)
639
+ (AcDbPolyline Coordinates Closed ConstantWidth Elevation Normal Thickness LinetypeGeneration Area Length)
640
+ (AcDb2dPolyline Coordinates Closed Elevation Normal Thickness LinetypeGeneration Area Length Type Width)
641
+ (AcDb3dPolyline Coordinates Closed Type Normal Length Area)
642
+ (AcDbAlignedDimension DimLinePoint1 DimLinePoint2 ExtLinePoint1 ExtLinePoint2 TextPosition TextRotation Measurement)
643
+ (AcDbRotatedDimension DimLinePoint1 DimLinePoint2 ExtLinePoint1 ExtLinePoint2 TextPosition TextRotation Measurement Rotation)
644
+ (AcDbRadialDimension Center Diameter LeaderLength TextPosition)
645
+ (AcDbDiametricDimension Center Diameter LeaderLength TextPosition)
646
+ (AcDbAngularDimension AngleVertex AngleEndPoint ArcPoint TextPosition Measurement)
647
+ (AcDbHatch PatternName PatternType Area Elevation Normal NumberOfLoops AssociativeHatch HatchObjectType PatternAngle PatternScale PatternSpace ISOPenWidth)
648
+ (AcDbSpline Degree NumberOfControlPoints NumberOfFitPoints ControlPoints FitPoints Knots Weights Area Length Closed Periodic StartTanVector EndTanVector Elevation Normal)
649
+ (AcDbEllipse Center MajorRadius MinorRadius RadiusRatio StartAngle EndAngle Area Circumference Normal)
650
+ (AcDbRegion Area Perimeter Centroid MomentsOfInertia PrincipalMoments PrincipalDirections Normal)
651
+ (AcDb3dSolid Volume Area Centroid MomentsOfInertia PrincipalMoments PrincipalDirections)
652
+ (AcDbRasterImage ImageFile ImageWidth ImageHeight Origin Rotation Width Height ShowImage ClippingEnabled)
653
+ (AcDbLeader Coordinates ArrowheadType ArrowheadSize Color ScaleFactor StyleName TextString TextPosition Type Normal)
654
+ (AcDbViewport Center Width Height ScaleFactor CustomScale StandardScale GridOn SnapOn On DisplayLocked)
655
+ (AcDbTable TableStyleName Position Rows Columns Direction FlowDirection)))
656
+
657
+ (defun entity:properties (ent / obj object-name result)
658
+ (setq obj (if (= (type ent) 'VLA-OBJECT) ent (vlax-ename->vla-object ent)))
659
+ (setq result (entity:try-get obj *common-props*))
660
+ (setq object-name (cdr (assoc 'ObjectName result)))
661
+ (if object-name
662
+ (setq result (append result (entity:try-get obj (cdr (assoc (read object-name) *entity-props*))))))
663
+ result)
664
+ `;
613
665
  function getCached(key) {
614
666
  const entry = resourceCache.get(key);
615
667
  if (entry && Date.now() - entry.timestamp < CACHE_TTL) {
@@ -839,7 +891,18 @@ function parseEntity(arr) {
839
891
  }
840
892
  return entity;
841
893
  }
842
- function buildEntityCode({ type, layer, bbox }) {
894
+ function propertyPairsToObject(pairs) {
895
+ if (!Array.isArray(pairs))
896
+ return null;
897
+ const obj = {};
898
+ for (const pair of pairs) {
899
+ if (Array.isArray(pair) && pair.length >= 2) {
900
+ obj[String(pair[0])] = pair[1] !== null && pair[1] !== void 0 ? pair[1] : null;
901
+ }
902
+ }
903
+ return obj;
904
+ }
905
+ function buildEntityPropertiesCode({ type, layer, bbox }) {
843
906
  const items = [];
844
907
  if (type)
845
908
  items.push(`(cons 0 "${type.replace(/"/g, '\\"')}")`);
@@ -861,27 +924,12 @@ function buildEntityCode({ type, layer, bbox }) {
861
924
  const ssgetExpr = items.length ? `(ssget "_X" ${filterExpr})` : '(ssget "_X")';
862
925
  return `(progn
863
926
  (vl-load-com)
864
- (defun @e:safe-fn (f ent / r)
865
- (setq r (vl-catch-all-apply f (list ent)))
866
- (if (vl-catch-all-error-p r) nil r))
867
- (defun @e:dp (ent / ed typ gcl is)
868
- (setq ed (entget ent) typ (cdr (assoc 0 ed)) gcl (assoc 62 ed) is (assoc 6 ed))
869
- (append
870
- (list typ (cdr (assoc 5 ed)) (cdr (assoc 8 ed))
871
- (if gcl (cdr gcl) 256)
872
- (if is (cdr is) "ByLayer"))
873
- (cond
874
- ((wcmatch typ "TEXT,MTEXT,ATTRIB,TCH_TEXT")
875
- (list (@e:safe-fn '(lambda (e) (text:remove-fmt (text:get-mtext e))) ent)))
876
- ((wcmatch typ "LINE,LWPOLYLINE,POLYLINE,ARC,CIRCLE,SPLINE,ELLIPSE,XLINE,RAY")
877
- (list (@e:safe-fn 'curve:get-points ent)))
878
- ((= typ "INSERT")
879
- (list (@e:safe-fn 'block:get-effectivename ent)))
880
- (t nil))))
927
+ ${ENTITY_PROPERTIES_LISP}
881
928
  (setq @e:total (if (setq @e:ss ${ssgetExpr}) (sslength @e:ss) 0)
882
929
  @e:ents nil @e:i 0)
883
- (while (and @e:ss (< @e:i @e:total)(< (length @e:ents) 3000))
884
- (setq @e:ents (cons (@e:dp (ssname @e:ss @e:i)) @e:ents) @e:i (1+ @e:i)))
930
+ (while (and @e:ss (< @e:i @e:total) (< (length @e:ents) 3000))
931
+ (setq @e:ents (cons (entity:properties (ssname @e:ss @e:i)) @e:ents)
932
+ @e:i (1+ @e:i)))
885
933
  (vl-prin1-to-string (list @e:total (reverse @e:ents))))`;
886
934
  }
887
935
  function buildTextCode({ layer, bbox, offset, limit }) {
@@ -926,7 +974,7 @@ function buildTextCode({ layer, bbox, offset, limit }) {
926
974
  var RESOURCES = [
927
975
  { uri: "atlisp://cad/info", name: "CAD Info", description: "CAD \u8FDE\u63A5\u4FE1\u606F", mimeType: "application/json", subscribable: true },
928
976
  { uri: "atlisp://dwg/layers", name: "Layers", description: "\u56FE\u5C42\u5217\u8868", mimeType: "application/json", subscribable: true },
929
- { uri: "atlisp://dwg/entities", name: "Entities", description: "\u56FE\u5143\u5217\u8868\uFF0C\u8FD4\u56DE\u603B\u6570\u548C\u524D3000\u4E2A\u56FE\u5143\uFF0C\u6587\u672C\u9644\u52A0 text \u5B57\u6BB5\uFF0C\u66F2\u7EBF\u9644\u52A0 points \u6570\u7EC4\uFF0CINSERT \u9644\u52A0 blockName\uFF0C\u652F\u6301 ?type=LINE&layer=0&bbox=0,0,100,100 \u8FC7\u6EE4", mimeType: "application/json", subscribable: true },
977
+ { uri: "atlisp://dwg/entities", name: "Entities", description: "\u56FE\u5143\u5217\u8868\u3002\u65E0\u53C2\u6570\u65F6\u8FD4\u56DE\u603B\u6570\u548C\u6309\u7C7B\u578B\u7EDF\u8BA1\uFF1B\u6709\u53C2\u6570\u65F6\u8FD4\u56DE filtered \u56FE\u6587\u7684 entity:properties \u5168\u5C5E\u6027 JSON\uFF08ObjectName, Handle, Layer, Color, Center, Radius \u7B49\uFF09\uFF0C\u652F\u6301 ?type=LINE&layer=0&bbox=0,0,100,100", mimeType: "application/json", subscribable: true },
930
978
  { uri: "atlisp://dwg/texts", name: "Texts", description: "\u6587\u672C\u5B9E\u4F53\u5185\u5BB9\u5217\u8868 (TEXT/MTEXT/ATTRIB/TCH_TEXT)\uFF0C\u652F\u6301 ?layer=0&bbox=0,0,100,100&limit=5000&offset=0", mimeType: "application/json", subscribable: true },
931
979
  { uri: "atlisp://dwg/name", name: "DWG Name", description: "\u5F53\u524D DWG \u6587\u4EF6\u540D", mimeType: "application/json", subscribable: true },
932
980
  { uri: "atlisp://dwg/path", name: "DWG Path", description: "\u6587\u4EF6\u5B8C\u6574\u8DEF\u5F84", mimeType: "application/json", subscribable: true },
@@ -1130,7 +1178,7 @@ async function getEntities(params = {}) {
1130
1178
  return await getEntitiesSummary(cacheKey);
1131
1179
  }
1132
1180
  try {
1133
- const code = buildEntityCode({
1181
+ const code = buildEntityPropertiesCode({
1134
1182
  type: params.type || null,
1135
1183
  layer: params.layer || null,
1136
1184
  bbox: params.bbox || null
@@ -1147,7 +1195,7 @@ async function getEntities(params = {}) {
1147
1195
  if (parsed && Array.isArray(parsed) && parsed.length >= 2) {
1148
1196
  total = typeof parsed[0] === "number" ? parsed[0] : 0;
1149
1197
  const rawEntities = Array.isArray(parsed[1]) ? parsed[1] : [];
1150
- entities = rawEntities.map(parseEntity).filter(Boolean);
1198
+ entities = rawEntities.map(propertyPairsToObject).filter(Boolean);
1151
1199
  }
1152
1200
  const result = { total, entities };
1153
1201
  log(`getEntities: total=${total}, returned=${entities.length}`);
@@ -2982,9 +3030,15 @@ var RESOURCE_TEMPLATES = [
2982
3030
  mimeType: "application/json"
2983
3031
  },
2984
3032
  {
2985
- uriTemplate: "atlisp://dwg/entities?type={type}",
2986
- name: "Entities by Type",
2987
- description: "\u6309\u7C7B\u578B\u67E5\u8BE2\u5B9E\u4F53\u5217\u8868",
3033
+ uriTemplate: "atlisp://dwg/entities",
3034
+ name: "Entities Summary",
3035
+ description: "\u8FD4\u56DE\u56FE\u5143\u603B\u6570\u548C\u6309\u7C7B\u578B\u7EDF\u8BA1\u5217\u8868",
3036
+ mimeType: "application/json"
3037
+ },
3038
+ {
3039
+ uriTemplate: "atlisp://dwg/entities?type={type}&layer={layer}&bbox={bbox}",
3040
+ name: "Filtered Entities",
3041
+ description: "\u6309 type/layer/bbox \u8FC7\u6EE4\u56FE\u5143\uFF0C\u8FD4\u56DE entity:properties \u5168\u5C5E\u6027 JSON\uFF08ObjectName, Handle, Layer, Color, Center, Radius \u7B49\uFF09",
2988
3042
  mimeType: "application/json"
2989
3043
  },
2990
3044
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlisp/mcp",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
4
4
  "description": "MCP Server for @lisp on CAD,support AutoCAD/GstarCAD/ZWCAD/BricsCAD or CAD platform compatible with AutoLISP",
5
5
  "type": "module",
6
6
  "bin": {