solidworks-mcp-python 1.5.0__py3-none-any.whl

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 (115) hide show
  1. solidworks_mcp/__init__.py +57 -0
  2. solidworks_mcp/adapters/__init__.py +40 -0
  3. solidworks_mcp/adapters/base.py +1882 -0
  4. solidworks_mcp/adapters/circuit_breaker.py +2052 -0
  5. solidworks_mcp/adapters/com_executor.py +252 -0
  6. solidworks_mcp/adapters/complexity_analyzer.py +272 -0
  7. solidworks_mcp/adapters/connection_pool.py +1884 -0
  8. solidworks_mcp/adapters/factory.py +366 -0
  9. solidworks_mcp/adapters/intelligent_router.py +218 -0
  10. solidworks_mcp/adapters/mock_adapter.py +4016 -0
  11. solidworks_mcp/adapters/pywin32_adapter.py +2842 -0
  12. solidworks_mcp/adapters/solidworks/__init__.py +17 -0
  13. solidworks_mcp/adapters/solidworks/bitmap.py +180 -0
  14. solidworks_mcp/adapters/solidworks/com_utils.py +56 -0
  15. solidworks_mcp/adapters/solidworks/dimension_layout.py +753 -0
  16. solidworks_mcp/adapters/solidworks/documentation.py +1476 -0
  17. solidworks_mcp/adapters/solidworks/drawing_standard.py +1993 -0
  18. solidworks_mcp/adapters/solidworks/face_selection.py +392 -0
  19. solidworks_mcp/adapters/solidworks/features.py +3362 -0
  20. solidworks_mcp/adapters/solidworks/io.py +3649 -0
  21. solidworks_mcp/adapters/solidworks/rebuild_diagnostics.py +269 -0
  22. solidworks_mcp/adapters/solidworks/rebuild_inspector.py +146 -0
  23. solidworks_mcp/adapters/solidworks/selection.py +308 -0
  24. solidworks_mcp/adapters/solidworks/sketch.py +2545 -0
  25. solidworks_mcp/adapters/sw_feature_errors.py +66 -0
  26. solidworks_mcp/adapters/sw_type_info.py +317 -0
  27. solidworks_mcp/adapters/vba_adapter.py +318 -0
  28. solidworks_mcp/adapters/vba_macro_executor.py +215 -0
  29. solidworks_mcp/agents/__init__.py +68 -0
  30. solidworks_mcp/agents/design_knowledge/assembly_patterns.md +127 -0
  31. solidworks_mcp/agents/design_knowledge/hinges.md +118 -0
  32. solidworks_mcp/agents/design_knowledge/snap_fits.md +93 -0
  33. solidworks_mcp/agents/design_knowledge/solidworks_basics.md +3 -0
  34. solidworks_mcp/agents/design_knowledge/tolerancing.md +128 -0
  35. solidworks_mcp/agents/harness.py +216 -0
  36. solidworks_mcp/agents/history_db.py +1508 -0
  37. solidworks_mcp/agents/retrieval_index.py +164 -0
  38. solidworks_mcp/agents/schemas.py +165 -0
  39. solidworks_mcp/agents/smoke_test.py +285 -0
  40. solidworks_mcp/agents/soc_exporter.py +650 -0
  41. solidworks_mcp/agents/soc_pickup.py +332 -0
  42. solidworks_mcp/agents/soc_rewind.py +221 -0
  43. solidworks_mcp/agents/vector_rag.py +665 -0
  44. solidworks_mcp/cache/__init__.py +5 -0
  45. solidworks_mcp/cache/response_cache.py +164 -0
  46. solidworks_mcp/config.py +729 -0
  47. solidworks_mcp/exceptions.py +37 -0
  48. solidworks_mcp/security/__init__.py +68 -0
  49. solidworks_mcp/security/auth.py +128 -0
  50. solidworks_mcp/security/cors.py +27 -0
  51. solidworks_mcp/security/rate_limiting.py +90 -0
  52. solidworks_mcp/security/runtime.py +155 -0
  53. solidworks_mcp/server.py +777 -0
  54. solidworks_mcp/server_cli_fixed.py +120 -0
  55. solidworks_mcp/setup/__init__.py +1 -0
  56. solidworks_mcp/setup/cli.py +399 -0
  57. solidworks_mcp/setup/clients.py +157 -0
  58. solidworks_mcp/setup/config_file.py +230 -0
  59. solidworks_mcp/setup/handshake.py +202 -0
  60. solidworks_mcp/setup/launcher.py +102 -0
  61. solidworks_mcp/setup/legacy.py +100 -0
  62. solidworks_mcp/setup/registration.py +193 -0
  63. solidworks_mcp/setup/solidworks.py +49 -0
  64. solidworks_mcp/tools/__init__.py +64 -0
  65. solidworks_mcp/tools/analysis.py +723 -0
  66. solidworks_mcp/tools/automation.py +578 -0
  67. solidworks_mcp/tools/docs_discovery.py +1476 -0
  68. solidworks_mcp/tools/drawing.py +1015 -0
  69. solidworks_mcp/tools/drawing_analysis.py +456 -0
  70. solidworks_mcp/tools/drawing_automation.py +627 -0
  71. solidworks_mcp/tools/engineering_data.py +466 -0
  72. solidworks_mcp/tools/error_classifier.py +232 -0
  73. solidworks_mcp/tools/export.py +833 -0
  74. solidworks_mcp/tools/file_facts.py +40 -0
  75. solidworks_mcp/tools/file_management.py +1473 -0
  76. solidworks_mcp/tools/input_compat.py +17 -0
  77. solidworks_mcp/tools/macro_recording.py +464 -0
  78. solidworks_mcp/tools/modeling.py +2360 -0
  79. solidworks_mcp/tools/sketching.py +1422 -0
  80. solidworks_mcp/tools/template_management.py +367 -0
  81. solidworks_mcp/tools/tool_boundary.py +280 -0
  82. solidworks_mcp/tools/vba_generation.py +1145 -0
  83. solidworks_mcp/ui/__init__.py +9 -0
  84. solidworks_mcp/ui/local_llm.py +725 -0
  85. solidworks_mcp/ui/routers/__init__.py +10 -0
  86. solidworks_mcp/ui/routers/checkpoint.py +24 -0
  87. solidworks_mcp/ui/routers/docs.py +47 -0
  88. solidworks_mcp/ui/routers/llm.py +83 -0
  89. solidworks_mcp/ui/routers/local_model.py +69 -0
  90. solidworks_mcp/ui/routers/model.py +75 -0
  91. solidworks_mcp/ui/routers/preview.py +38 -0
  92. solidworks_mcp/ui/routers/session.py +161 -0
  93. solidworks_mcp/ui/routers/viewer.py +154 -0
  94. solidworks_mcp/ui/schemas.py +502 -0
  95. solidworks_mcp/ui/server.py +298 -0
  96. solidworks_mcp/ui/service.py +481 -0
  97. solidworks_mcp/ui/services/__init__.py +136 -0
  98. solidworks_mcp/ui/services/_utils.py +958 -0
  99. solidworks_mcp/ui/services/checkpoint_service.py +1110 -0
  100. solidworks_mcp/ui/services/docs_service.py +282 -0
  101. solidworks_mcp/ui/services/llm_service.py +956 -0
  102. solidworks_mcp/ui/services/model_service.py +459 -0
  103. solidworks_mcp/ui/services/parameter_repair_service.py +314 -0
  104. solidworks_mcp/ui/services/preview_service.py +489 -0
  105. solidworks_mcp/ui/services/session_service.py +1389 -0
  106. solidworks_mcp/utils/__init__.py +9 -0
  107. solidworks_mcp/utils/feature_tree_classifier.py +342 -0
  108. solidworks_mcp/utils/logging.py +76 -0
  109. solidworks_mcp/utils/validation.py +77 -0
  110. solidworks_mcp/version.py +8 -0
  111. solidworks_mcp_python-1.5.0.dist-info/METADATA +410 -0
  112. solidworks_mcp_python-1.5.0.dist-info/RECORD +115 -0
  113. solidworks_mcp_python-1.5.0.dist-info/WHEEL +4 -0
  114. solidworks_mcp_python-1.5.0.dist-info/entry_points.txt +3 -0
  115. solidworks_mcp_python-1.5.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,17 @@
1
+ """Shared input model compatibility helpers for tool schemas.
2
+
3
+ This module centralizes test/backward-compat parsing behavior so individual tool modules
4
+ stay focused on domain fields.
5
+ """
6
+
7
+ from pydantic import BaseModel, ConfigDict
8
+
9
+
10
+ class CompatInput(BaseModel):
11
+ """Base schema allowing legacy/extra fields used by existing tests.
12
+
13
+ Attributes:
14
+ model_config (Any): The model config value.
15
+ """
16
+
17
+ model_config = ConfigDict(extra="allow", populate_by_name=True)
@@ -0,0 +1,464 @@
1
+ """Macro Recording and Playback tools for SolidWorks MCP Server.
2
+
3
+ Provides tools for recording, managing, and executing SolidWorks macros for automation
4
+ and workflow optimization.
5
+ """
6
+
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+ from fastmcp import FastMCP
11
+ from pydantic import Field
12
+
13
+ from ..adapters.base import SolidWorksAdapter
14
+ from .input_compat import CompatInput
15
+ from .tool_boundary import (
16
+ UnsupportedOperationError,
17
+ normalize_input,
18
+ require_capability,
19
+ require_success,
20
+ with_tool_boundary,
21
+ )
22
+
23
+ # Input schemas for macro operations
24
+
25
+ # ISldWorks::RunMacro2 runs only binary macros.
26
+ _RUNNABLE_MACRO_SUFFIXES = frozenset({".swp", ".swb"})
27
+
28
+
29
+ class MacroRecordingInput(CompatInput):
30
+ """Input schema for macro recording operations.
31
+
32
+ Attributes:
33
+ auto_cleanup (bool): The auto cleanup value.
34
+ auto_stop (bool): The auto stop value.
35
+ capture_keyboard (bool): The capture keyboard value.
36
+ capture_mouse (bool): The capture mouse value.
37
+ description (str): The description value.
38
+ macro_name (str | None): The macro name value.
39
+ output_file (str): The output file value.
40
+ recording_mode (str): The recording mode value.
41
+ recording_name (str | None): The recording name value.
42
+ recording_quality (str): The recording quality value.
43
+ timeout_seconds (int): The timeout seconds value.
44
+ """
45
+
46
+ macro_name: str | None = Field(
47
+ default=None, description="Name for the recorded macro"
48
+ )
49
+ recording_name: str | None = Field(
50
+ default=None, description="Alternative recording name"
51
+ )
52
+ description: str = Field(
53
+ default="", description="Description of macro functionality"
54
+ )
55
+ output_file: str = Field(description="Output file for the recorded macro")
56
+ recording_mode: str = Field(default="User actions", description="Recording mode")
57
+ capture_mouse: bool = Field(default=True, description="Capture mouse actions")
58
+ capture_keyboard: bool = Field(default=True, description="Capture keyboard actions")
59
+ recording_quality: str = Field(
60
+ default="High", description="Recording quality level"
61
+ )
62
+ auto_cleanup: bool = Field(default=False, description="Cleanup temporary files")
63
+ auto_stop: bool = Field(
64
+ default=False, description="Auto-stop recording after timeout"
65
+ )
66
+ timeout_seconds: int = Field(
67
+ default=300, description="Timeout for auto-stop in seconds"
68
+ )
69
+
70
+ def model_post_init(self, __context: Any) -> None:
71
+ """Provide model post init support for the macro recording input.
72
+
73
+ Args:
74
+ __context (Any): The context value.
75
+
76
+ Returns:
77
+ None: None.
78
+ """
79
+ if self.macro_name is None:
80
+ self.macro_name = self.recording_name or "Recorded Macro"
81
+
82
+
83
+ class MacroPlaybackInput(CompatInput):
84
+ """Input schema for macro playback.
85
+
86
+ Attributes:
87
+ execution_mode (str | None): The execution mode value.
88
+ execution_parameters (dict[str, Any] | None): The execution parameters value.
89
+ log_execution (bool): The log execution value.
90
+ macro_file (str | None): The macro file value.
91
+ macro_path (str | None): The macro path value.
92
+ parameters (dict[str, Any]): The parameters value.
93
+ pause_between_runs (float): The pause between runs value.
94
+ pause_on_error (bool): The pause on error value.
95
+ repeat_count (int): The repeat count value.
96
+ target_file (str | None): The target file value.
97
+ """
98
+
99
+ macro_path: str | None = Field(
100
+ default=None,
101
+ description=(
102
+ "Path to a binary SolidWorks macro (.swp, or legacy .swb). "
103
+ "VBA source (.vb, .bas, text) cannot be run directly."
104
+ ),
105
+ )
106
+ macro_file: str | None = Field(
107
+ default=None, description="Alternative to macro_path (.swp or .swb)"
108
+ )
109
+ parameters: dict[str, Any] = Field(
110
+ default_factory=dict, description="Macro parameters"
111
+ )
112
+ target_file: str | None = Field(default=None, description="Target file")
113
+ execution_mode: str | None = Field(default=None, description="Execution mode")
114
+ pause_on_error: bool = Field(default=False, description="Pause on error")
115
+ log_execution: bool = Field(default=False, description="Log execution")
116
+ execution_parameters: dict[str, Any] | None = Field(
117
+ default=None, description="Execution parameters"
118
+ )
119
+ repeat_count: int = Field(default=1, description="Number of times to execute")
120
+ pause_between_runs: float = Field(
121
+ default=0.0, description="Pause between executions in seconds"
122
+ )
123
+
124
+ def model_post_init(self, __context: Any) -> None:
125
+ """Reject macro files ``ISldWorks::RunMacro2`` cannot run.
126
+
127
+ ``RunMacro2`` only runs binary ``.swp`` (or legacy ``.swb``) macros;
128
+ anything else fails deep inside COM with an opaque error.
129
+
130
+ Args:
131
+ __context (Any): The context value.
132
+
133
+ Raises:
134
+ ValueError: A macro path is not a ``.swp`` or ``.swb`` file.
135
+ """
136
+ for path in (self.macro_path, self.macro_file):
137
+ if path and Path(path).suffix.lower() not in _RUNNABLE_MACRO_SUFFIXES:
138
+ raise ValueError(
139
+ f"execute_macro runs only binary SolidWorks macros "
140
+ f"(.swp or .swb), got {path!r}. VBA source (.vb, .bas or "
141
+ "text) must be saved as a .swp in the SolidWorks VBA "
142
+ "editor first."
143
+ )
144
+
145
+
146
+ class MacroAnalysisInput(CompatInput):
147
+ """Input schema for macro analysis.
148
+
149
+ Attributes:
150
+ analysis_depth (str): The analysis depth value.
151
+ analysis_type (str): The analysis type value.
152
+ macro_file (str | None): The macro file value.
153
+ macro_path (str | None): The macro path value.
154
+ suggest_optimizations (bool): The suggest optimizations value.
155
+ """
156
+
157
+ macro_path: str | None = Field(
158
+ default=None, description="Path to macro file to analyze"
159
+ )
160
+ macro_file: str | None = Field(
161
+ default=None, description="Alternative macro file path"
162
+ )
163
+ analysis_type: str = Field(
164
+ default="full", description="Analysis type (full, dependencies, performance)"
165
+ )
166
+ analysis_depth: str = Field(default="Basic", description="Analysis depth alias")
167
+ suggest_optimizations: bool = Field(
168
+ default=False, description="Suggest optimizations"
169
+ )
170
+
171
+
172
+ class MacroBatchInput(CompatInput):
173
+ """Input schema for batch macro operations.
174
+
175
+ Attributes:
176
+ execution_order (str): The execution order value.
177
+ file_pattern (str | None): The file pattern value.
178
+ macro_list (list[str]): The macro list value.
179
+ source_directory (str | None): The source directory value.
180
+ stop_on_error (bool): The stop on error value.
181
+ target_directory (str | None): The target directory value.
182
+ """
183
+
184
+ macro_list: list[str] = Field(description="List of macro file paths")
185
+ target_directory: str | None = Field(
186
+ default=None, description="Target directory alias"
187
+ )
188
+ source_directory: str | None = Field(
189
+ default=None, description="Source directory alias"
190
+ )
191
+ file_pattern: str | None = Field(default=None, description="File pattern alias")
192
+ execution_order: str = Field(
193
+ default="sequential", description="Execution order (sequential, parallel)"
194
+ )
195
+ stop_on_error: bool = Field(default=True, description="Stop batch if error occurs")
196
+
197
+
198
+ async def register_macro_recording_tools(
199
+ mcp: FastMCP, adapter: SolidWorksAdapter, config: Any
200
+ ) -> int:
201
+ """Register macro recording and playback tools with FastMCP.
202
+
203
+ Args:
204
+ mcp (FastMCP): The mcp value.
205
+ adapter (SolidWorksAdapter): Adapter instance used for the operation.
206
+ config (Any): Configuration values for the operation.
207
+
208
+ Returns:
209
+ int: The computed numeric result.
210
+
211
+ Example:
212
+ >>> tool_count = await register_macro_recording_tools(mcp, adapter, config)
213
+ """
214
+ mcp = with_tool_boundary(mcp)
215
+ tool_count = 0
216
+
217
+ @mcp.tool()
218
+ async def start_macro_recording(input_data: MacroRecordingInput) -> dict[str, Any]:
219
+ """Start recording a SolidWorks macro.
220
+
221
+ This tool initiates macro recording to capture user actions for later playback and
222
+ automation.
223
+
224
+ Args:
225
+ input_data (MacroRecordingInput): The input data value.
226
+
227
+ Returns:
228
+ dict[str, Any]: A dictionary containing the resulting values.
229
+
230
+ Example:
231
+ >>> result = await start_macro_recording(recording_input)
232
+ """
233
+ require_capability(
234
+ adapter,
235
+ "start_macro_recording",
236
+ "Active adapter does not support start_macro_recording; "
237
+ f"no recording of {input_data.macro_name} was started.",
238
+ )
239
+ result = await adapter.start_macro_recording(input_data.model_dump())
240
+ require_success(result, "Failed to start recording")
241
+ return {
242
+ "status": "success",
243
+ "message": f"Macro recording started: {input_data.macro_name}",
244
+ "data": result.data,
245
+ "execution_time": result.execution_time,
246
+ }
247
+
248
+ @mcp.tool()
249
+ async def stop_macro_recording(input_data: dict[str, Any]) -> dict[str, Any]:
250
+ """Stop macro recording and save the recorded macro.
251
+
252
+ This tool stops the active recording session and saves the generated macro code to a
253
+ file.
254
+
255
+ Args:
256
+ input_data (dict[str, Any]): The input data value.
257
+
258
+ Returns:
259
+ dict[str, Any]: A dictionary containing the resulting values.
260
+
261
+ Example:
262
+ >>> result = await stop_macro_recording(stop_input)
263
+ """
264
+ require_capability(
265
+ adapter,
266
+ "stop_macro_recording",
267
+ "No adapter capability exists for stopping a macro "
268
+ "recording; this tool never started a real recording "
269
+ "session, so there is no macro code to save.",
270
+ )
271
+ result = await adapter.stop_macro_recording(input_data)
272
+ require_success(result, "Failed to stop recording")
273
+ return {
274
+ "status": "success",
275
+ "message": "Macro recording completed and saved",
276
+ "data": result.data,
277
+ "execution_time": result.execution_time,
278
+ }
279
+
280
+ @mcp.tool()
281
+ async def execute_macro(input_data: MacroPlaybackInput) -> dict[str, Any]:
282
+ """Run a binary SolidWorks macro (.swp, or legacy .swb).
283
+
284
+ Calls ``ISldWorks::RunMacro2`` on ``macro_path`` (or ``macro_file``).
285
+ Only binary macros run: VBA source (.vb, .bas, plain text) is
286
+ rejected as ``invalid_input`` before anything reaches SolidWorks.
287
+ The macro must not be interactive (no MsgBox or user forms).
288
+
289
+ Args:
290
+ input_data (MacroPlaybackInput): The input data value.
291
+
292
+ Returns:
293
+ dict[str, Any]: A dictionary containing the resulting values.
294
+
295
+ Example:
296
+ >>> result = await execute_macro(playback_input)
297
+ """
298
+
299
+ input_data = normalize_input(input_data, MacroPlaybackInput)
300
+ require_capability(
301
+ adapter,
302
+ "execute_macro",
303
+ "Active adapter does not support execute_macro; "
304
+ f"{input_data.macro_path} was not run, and no features "
305
+ "were created.",
306
+ )
307
+ result = await adapter.execute_macro(input_data.model_dump())
308
+ require_success(result, "Failed to execute macro")
309
+ return {
310
+ "status": "success",
311
+ "message": f"Macro executed {input_data.repeat_count} times successfully",
312
+ "data": result.data,
313
+ "execution_time": result.execution_time,
314
+ }
315
+
316
+ @mcp.tool()
317
+ async def analyze_macro(input_data: MacroAnalysisInput) -> dict[str, Any]:
318
+ """Analyze a macro for complexity, dependencies, and optimization opportunities.
319
+
320
+ This tool provides insights into macro structure and performance to help with
321
+ optimization and maintenance.
322
+
323
+ Args:
324
+ input_data (MacroAnalysisInput): The input data value.
325
+
326
+ Returns:
327
+ dict[str, Any]: A dictionary containing the resulting values.
328
+
329
+ Example:
330
+ >>> result = await analyze_macro(analysis_input)
331
+ """
332
+ require_capability(
333
+ adapter,
334
+ "analyze_macro",
335
+ "Active adapter does not support analyze_macro; "
336
+ f"{input_data.macro_path} was not analyzed.",
337
+ )
338
+ result = await adapter.analyze_macro(input_data.model_dump())
339
+ require_success(result, "Failed to analyze macro")
340
+ return {
341
+ "status": "success",
342
+ "message": f"Macro analysis completed for {input_data.macro_path}",
343
+ "data": result.data,
344
+ "execution_time": result.execution_time,
345
+ }
346
+
347
+ @mcp.tool()
348
+ async def batch_execute_macros(input_data: MacroBatchInput) -> dict[str, Any]:
349
+ """Handle batch execute macros.
350
+
351
+ This tool allows running multiple macros in sequence or parallel for complex automated
352
+ workflows.
353
+
354
+ Args:
355
+ input_data (MacroBatchInput): The input data value.
356
+
357
+ Returns:
358
+ dict[str, Any]: A dictionary containing the resulting values.
359
+
360
+ Example:
361
+ >>> result = await batch_execute_macros(batch_input)
362
+ """
363
+ payload = (
364
+ input_data.model_dump()
365
+ if hasattr(input_data, "model_dump")
366
+ else dict(input_data)
367
+ )
368
+
369
+ if hasattr(adapter, "batch_execute_macros"):
370
+ result = await adapter.batch_execute_macros(payload)
371
+ require_success(result, "Failed batch execution")
372
+ return {
373
+ "status": "success",
374
+ "message": "Batch macro execution completed successfully",
375
+ "data": result.data,
376
+ "execution_time": result.execution_time,
377
+ }
378
+
379
+ macro_list = payload.get("macro_list", [])
380
+
381
+ raise UnsupportedOperationError(
382
+ "Active adapter does not support batch_execute_macros; "
383
+ f"none of the {len(macro_list)} macro(s) were run."
384
+ )
385
+
386
+ @mcp.tool()
387
+ async def optimize_macro(input_data: dict[str, Any]) -> dict[str, Any]:
388
+ """Optimize an existing macro for better performance and reliability.
389
+
390
+ This tool analyzes and suggests improvements to existing macro code.
391
+
392
+ Args:
393
+ input_data (dict[str, Any]): The input data value.
394
+
395
+ Returns:
396
+ dict[str, Any]: A dictionary containing the resulting values.
397
+
398
+ Example:
399
+ >>> result = await optimize_macro(optimization_input)
400
+ """
401
+ payload = (
402
+ input_data.model_dump()
403
+ if hasattr(input_data, "model_dump")
404
+ else dict(input_data)
405
+ )
406
+
407
+ if hasattr(adapter, "optimize_macro"):
408
+ result = await adapter.optimize_macro(payload)
409
+ require_success(result, "Failed to optimize macro")
410
+ return {
411
+ "status": "success",
412
+ "message": "Macro optimization completed successfully",
413
+ "data": result.data,
414
+ "execution_time": result.execution_time,
415
+ }
416
+
417
+ macro_path = payload.get("macro_path") or payload.get("macro_file", "")
418
+
419
+ raise UnsupportedOperationError(
420
+ "Active adapter does not support optimize_macro; "
421
+ f"{macro_path} was not analyzed or changed."
422
+ )
423
+
424
+ @mcp.tool()
425
+ async def create_macro_library(input_data: dict[str, Any]) -> dict[str, Any]:
426
+ """Create a library of organized macros for team sharing and reuse.
427
+
428
+ This tool sets up a structured macro library with categorization, documentation, and
429
+ version control.
430
+
431
+ Args:
432
+ input_data (dict[str, Any]): The input data value.
433
+
434
+ Returns:
435
+ dict[str, Any]: A dictionary containing the resulting values.
436
+
437
+ Example:
438
+ >>> result = await create_macro_library(library_input)
439
+ """
440
+ payload = (
441
+ input_data.model_dump()
442
+ if hasattr(input_data, "model_dump")
443
+ else dict(input_data)
444
+ )
445
+
446
+ if hasattr(adapter, "create_macro_library"):
447
+ result = await adapter.create_macro_library(payload)
448
+ require_success(result, "Failed to create library")
449
+ return {
450
+ "status": "success",
451
+ "message": "Macro library created successfully",
452
+ "data": result.data,
453
+ "execution_time": result.execution_time,
454
+ }
455
+
456
+ library_path = payload.get("library_path", "")
457
+
458
+ raise UnsupportedOperationError(
459
+ "Active adapter does not support create_macro_library; "
460
+ f"no library was created at {library_path or '(unspecified path)'}."
461
+ )
462
+
463
+ tool_count = 8 # Macro recording and management tools
464
+ return tool_count