tree-sitter-analyzer 0.2.0__py3-none-any.whl → 0.4.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.

Potentially problematic release.


This version of tree-sitter-analyzer might be problematic. Click here for more details.

Files changed (78) hide show
  1. tree_sitter_analyzer/__init__.py +134 -121
  2. tree_sitter_analyzer/__main__.py +11 -12
  3. tree_sitter_analyzer/api.py +533 -539
  4. tree_sitter_analyzer/cli/__init__.py +39 -39
  5. tree_sitter_analyzer/cli/__main__.py +12 -13
  6. tree_sitter_analyzer/cli/commands/__init__.py +26 -27
  7. tree_sitter_analyzer/cli/commands/advanced_command.py +88 -88
  8. tree_sitter_analyzer/cli/commands/base_command.py +160 -155
  9. tree_sitter_analyzer/cli/commands/default_command.py +18 -19
  10. tree_sitter_analyzer/cli/commands/partial_read_command.py +141 -133
  11. tree_sitter_analyzer/cli/commands/query_command.py +81 -82
  12. tree_sitter_analyzer/cli/commands/structure_command.py +138 -121
  13. tree_sitter_analyzer/cli/commands/summary_command.py +101 -93
  14. tree_sitter_analyzer/cli/commands/table_command.py +235 -233
  15. tree_sitter_analyzer/cli/info_commands.py +120 -121
  16. tree_sitter_analyzer/cli_main.py +278 -276
  17. tree_sitter_analyzer/core/__init__.py +15 -20
  18. tree_sitter_analyzer/core/analysis_engine.py +555 -574
  19. tree_sitter_analyzer/core/cache_service.py +320 -330
  20. tree_sitter_analyzer/core/engine.py +559 -560
  21. tree_sitter_analyzer/core/parser.py +293 -288
  22. tree_sitter_analyzer/core/query.py +502 -502
  23. tree_sitter_analyzer/encoding_utils.py +456 -460
  24. tree_sitter_analyzer/exceptions.py +337 -340
  25. tree_sitter_analyzer/file_handler.py +210 -222
  26. tree_sitter_analyzer/formatters/__init__.py +1 -1
  27. tree_sitter_analyzer/formatters/base_formatter.py +167 -168
  28. tree_sitter_analyzer/formatters/formatter_factory.py +78 -74
  29. tree_sitter_analyzer/formatters/java_formatter.py +291 -270
  30. tree_sitter_analyzer/formatters/python_formatter.py +259 -235
  31. tree_sitter_analyzer/interfaces/__init__.py +9 -10
  32. tree_sitter_analyzer/interfaces/cli.py +528 -557
  33. tree_sitter_analyzer/interfaces/cli_adapter.py +343 -319
  34. tree_sitter_analyzer/interfaces/mcp_adapter.py +206 -170
  35. tree_sitter_analyzer/interfaces/mcp_server.py +405 -416
  36. tree_sitter_analyzer/java_analyzer.py +187 -219
  37. tree_sitter_analyzer/language_detector.py +398 -400
  38. tree_sitter_analyzer/language_loader.py +224 -228
  39. tree_sitter_analyzer/languages/__init__.py +10 -11
  40. tree_sitter_analyzer/languages/java_plugin.py +1174 -1113
  41. tree_sitter_analyzer/{plugins → languages}/javascript_plugin.py +446 -439
  42. tree_sitter_analyzer/languages/python_plugin.py +747 -712
  43. tree_sitter_analyzer/mcp/__init__.py +31 -32
  44. tree_sitter_analyzer/mcp/resources/__init__.py +44 -47
  45. tree_sitter_analyzer/mcp/resources/code_file_resource.py +209 -213
  46. tree_sitter_analyzer/mcp/resources/project_stats_resource.py +555 -550
  47. tree_sitter_analyzer/mcp/server.py +333 -345
  48. tree_sitter_analyzer/mcp/tools/__init__.py +30 -31
  49. tree_sitter_analyzer/mcp/tools/analyze_scale_tool.py +654 -557
  50. tree_sitter_analyzer/mcp/tools/analyze_scale_tool_cli_compatible.py +247 -245
  51. tree_sitter_analyzer/mcp/tools/base_tool.py +54 -55
  52. tree_sitter_analyzer/mcp/tools/read_partial_tool.py +300 -302
  53. tree_sitter_analyzer/mcp/tools/table_format_tool.py +362 -359
  54. tree_sitter_analyzer/mcp/tools/universal_analyze_tool.py +543 -476
  55. tree_sitter_analyzer/mcp/utils/__init__.py +107 -106
  56. tree_sitter_analyzer/mcp/utils/error_handler.py +549 -549
  57. tree_sitter_analyzer/models.py +470 -481
  58. tree_sitter_analyzer/output_manager.py +255 -264
  59. tree_sitter_analyzer/plugins/__init__.py +280 -334
  60. tree_sitter_analyzer/plugins/base.py +496 -446
  61. tree_sitter_analyzer/plugins/manager.py +379 -355
  62. tree_sitter_analyzer/queries/__init__.py +26 -27
  63. tree_sitter_analyzer/queries/java.py +391 -394
  64. tree_sitter_analyzer/queries/javascript.py +148 -149
  65. tree_sitter_analyzer/queries/python.py +285 -286
  66. tree_sitter_analyzer/queries/typescript.py +229 -230
  67. tree_sitter_analyzer/query_loader.py +257 -260
  68. tree_sitter_analyzer/table_formatter.py +471 -448
  69. tree_sitter_analyzer/utils.py +277 -277
  70. {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.4.0.dist-info}/METADATA +23 -8
  71. tree_sitter_analyzer-0.4.0.dist-info/RECORD +73 -0
  72. {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.4.0.dist-info}/entry_points.txt +2 -1
  73. tree_sitter_analyzer/plugins/java_plugin.py +0 -625
  74. tree_sitter_analyzer/plugins/plugin_loader.py +0 -83
  75. tree_sitter_analyzer/plugins/python_plugin.py +0 -598
  76. tree_sitter_analyzer/plugins/registry.py +0 -366
  77. tree_sitter_analyzer-0.2.0.dist-info/RECORD +0 -77
  78. {tree_sitter_analyzer-0.2.0.dist-info → tree_sitter_analyzer-0.4.0.dist-info}/WHEEL +0 -0
@@ -1,245 +1,247 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """
4
- CLI-Compatible Analyze Code Scale MCP Tool
5
-
6
- This tool provides code scale analysis with output format
7
- that matches the CLI --advanced --statistics output exactly.
8
- """
9
-
10
- import json
11
- import logging
12
- import time
13
- from pathlib import Path
14
- from typing import Any, Dict
15
-
16
- from ...core.analysis_engine import get_analysis_engine, AnalysisRequest
17
- from ...language_detector import detect_language_from_file
18
- from ...utils import setup_logger
19
-
20
- # Set up logging
21
- logger = setup_logger(__name__)
22
-
23
-
24
- class AnalyzeScaleToolCLICompatible:
25
- """
26
- MCP Tool for analyzing code scale with CLI-compatible output format.
27
-
28
- This tool matches the exact output format of CLI --advanced --statistics.
29
- """
30
-
31
- def __init__(self) -> None:
32
- """Initialize the CLI-compatible analyze scale tool."""
33
- self.analysis_engine = get_analysis_engine()
34
- logger.info("AnalyzeScaleToolCLICompatible initialized")
35
-
36
- def get_tool_schema(self) -> Dict[str, Any]:
37
- """
38
- Get the MCP tool schema for analyze_code_scale.
39
-
40
- Returns:
41
- Dictionary containing the tool schema
42
- """
43
- return {
44
- "type": "object",
45
- "properties": {
46
- "file_path": {
47
- "type": "string",
48
- "description": "Path to the code file to analyze",
49
- },
50
- "language": {
51
- "type": "string",
52
- "description": "Programming language (optional, auto-detected if not specified)",
53
- },
54
- "include_complexity": {
55
- "type": "boolean",
56
- "description": "Include complexity metrics in the analysis",
57
- "default": True,
58
- },
59
- "include_details": {
60
- "type": "boolean",
61
- "description": "Include detailed element information",
62
- "default": False,
63
- },
64
- },
65
- "required": ["file_path"],
66
- "additionalProperties": False,
67
- }
68
-
69
- async def execute(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
70
- """
71
- Execute the analyze_code_scale tool with CLI-compatible output.
72
-
73
- Args:
74
- arguments: Tool arguments containing file_path and optional parameters
75
-
76
- Returns:
77
- Dictionary containing analysis results in CLI-compatible format
78
-
79
- Raises:
80
- ValueError: If required arguments are missing or invalid
81
- FileNotFoundError: If the specified file doesn't exist
82
- """
83
- # Validate required arguments
84
- if "file_path" not in arguments:
85
- raise ValueError("file_path is required")
86
-
87
- file_path = arguments["file_path"]
88
- language = arguments.get("language")
89
- include_complexity = arguments.get("include_complexity", True)
90
- include_details = arguments.get("include_details", False)
91
-
92
- # Validate file exists
93
- if not Path(file_path).exists():
94
- raise FileNotFoundError(f"File not found: {file_path}")
95
-
96
- # Detect language if not specified
97
- if not language:
98
- language = detect_language_from_file(file_path)
99
- if language == "unknown":
100
- raise ValueError(f"Could not detect language for file: {file_path}")
101
-
102
- logger.info(f"Analyzing code scale for {file_path} (language: {language})")
103
-
104
- try:
105
- start_time = time.time()
106
-
107
- # Use AdvancedAnalyzer for comprehensive analysis
108
- analysis_result = await self.analysis_engine.analyze_file(file_path)
109
-
110
- if analysis_result is None:
111
- # Return CLI-compatible error format
112
- return {
113
- "file_path": file_path,
114
- "success": False,
115
- "package_name": None,
116
- "element_counts": {
117
- "imports": 0,
118
- "classes": 0,
119
- "methods": 0,
120
- "fields": 0,
121
- "annotations": 0,
122
- },
123
- "analysis_time_ms": round((time.time() - start_time) * 1000, 2),
124
- "error_message": f"Failed to analyze file: {file_path}",
125
- }
126
-
127
- # Calculate analysis time
128
- analysis_time_ms = round((time.time() - start_time) * 1000, 2)
129
-
130
- # Build CLI-compatible result structure (exact match with CLI --advanced --statistics)
131
- result = {
132
- "file_path": file_path,
133
- "success": True,
134
- "package_name": (
135
- analysis_result.package.name if analysis_result.package else None
136
- ),
137
- "element_counts": {
138
- "imports": len(analysis_result.imports),
139
- "classes": len(analysis_result.classes),
140
- "methods": len(analysis_result.methods),
141
- "fields": len(analysis_result.fields),
142
- "annotations": len(getattr(analysis_result, "annotations", [])),
143
- },
144
- "analysis_time_ms": analysis_time_ms,
145
- "error_message": None,
146
- }
147
-
148
- logger.info(
149
- f"Successfully analyzed {file_path}: {len(analysis_result.classes)} classes, "
150
- f"{len(analysis_result.methods)} methods, {analysis_time_ms}ms"
151
- )
152
-
153
- return result
154
-
155
- except Exception as e:
156
- logger.error(f"Error analyzing {file_path}: {e}")
157
- # Return CLI-compatible error format
158
- return {
159
- "file_path": file_path,
160
- "success": False,
161
- "package_name": None,
162
- "element_counts": {
163
- "imports": 0,
164
- "classes": 0,
165
- "methods": 0,
166
- "fields": 0,
167
- "annotations": 0,
168
- },
169
- "analysis_time_ms": 0.0,
170
- "error_message": str(e),
171
- }
172
-
173
- def validate_arguments(self, arguments: Dict[str, Any]) -> bool:
174
- """
175
- Validate tool arguments against the schema.
176
-
177
- Args:
178
- arguments: Arguments to validate
179
-
180
- Returns:
181
- True if arguments are valid
182
-
183
- Raises:
184
- ValueError: If arguments are invalid
185
- """
186
- schema = self.get_tool_schema()
187
- required_fields = schema.get("required", [])
188
-
189
- # Check required fields
190
- for field in required_fields:
191
- if field not in arguments:
192
- raise ValueError(f"Required field '{field}' is missing")
193
-
194
- # Validate file_path
195
- if "file_path" in arguments:
196
- file_path = arguments["file_path"]
197
- if not isinstance(file_path, str):
198
- raise ValueError("file_path must be a string")
199
- if not file_path.strip():
200
- raise ValueError("file_path cannot be empty")
201
-
202
- # Validate optional fields
203
- if "language" in arguments:
204
- language = arguments["language"]
205
- if not isinstance(language, str):
206
- raise ValueError("language must be a string")
207
-
208
- if "include_complexity" in arguments:
209
- include_complexity = arguments["include_complexity"]
210
- if not isinstance(include_complexity, bool):
211
- raise ValueError("include_complexity must be a boolean")
212
-
213
- if "include_details" in arguments:
214
- include_details = arguments["include_details"]
215
- if not isinstance(include_details, bool):
216
- raise ValueError("include_details must be a boolean")
217
-
218
- return True
219
-
220
- def get_tool_definition(self) -> Any:
221
- """
222
- Get the MCP tool definition for analyze_code_scale.
223
-
224
- Returns:
225
- Tool definition object compatible with MCP server
226
- """
227
- try:
228
- from mcp.types import Tool
229
-
230
- return Tool(
231
- name="analyze_code_scale",
232
- description="Analyze code scale, complexity, and structure metrics with CLI-compatible output format",
233
- inputSchema=self.get_tool_schema(),
234
- )
235
- except ImportError:
236
- # Fallback for when MCP is not available
237
- return {
238
- "name": "analyze_code_scale",
239
- "description": "Analyze code scale, complexity, and structure metrics with CLI-compatible output format",
240
- "inputSchema": self.get_tool_schema(),
241
- }
242
-
243
-
244
- # Tool instance for easy access
245
- analyze_scale_tool_cli_compatible = AnalyzeScaleToolCLICompatible()
1
+ #!/usr/bin/env python3
2
+ """
3
+ CLI-Compatible Analyze Code Scale MCP Tool
4
+
5
+ This tool provides code scale analysis with output format
6
+ that matches the CLI --advanced --statistics output exactly.
7
+ """
8
+
9
+ import time
10
+ from pathlib import Path
11
+ from typing import Any, cast
12
+
13
+ from ...core.analysis_engine import get_analysis_engine
14
+ from ...language_detector import detect_language_from_file
15
+ from ...utils import setup_logger
16
+
17
+ # Set up logging
18
+ logger = setup_logger(__name__)
19
+
20
+
21
+ class AnalyzeScaleToolCLICompatible:
22
+ """
23
+ MCP Tool for analyzing code scale with CLI-compatible output format.
24
+
25
+ This tool matches the exact output format of CLI --advanced --statistics.
26
+ """
27
+
28
+ def __init__(self) -> None:
29
+ """Initialize the CLI-compatible analyze scale tool."""
30
+ self.analysis_engine = get_analysis_engine()
31
+ logger.info("AnalyzeScaleToolCLICompatible initialized")
32
+
33
+ def get_tool_schema(self) -> dict[str, Any]:
34
+ """
35
+ Get the MCP tool schema for analyze_code_scale.
36
+
37
+ Returns:
38
+ Dictionary containing the tool schema
39
+ """
40
+ return {
41
+ "type": "object",
42
+ "properties": {
43
+ "file_path": {
44
+ "type": "string",
45
+ "description": "Path to the code file to analyze",
46
+ },
47
+ "language": {
48
+ "type": "string",
49
+ "description": "Programming language (optional, auto-detected if not specified)",
50
+ },
51
+ "include_complexity": {
52
+ "type": "boolean",
53
+ "description": "Include complexity metrics in the analysis",
54
+ "default": True,
55
+ },
56
+ "include_details": {
57
+ "type": "boolean",
58
+ "description": "Include detailed element information",
59
+ "default": False,
60
+ },
61
+ },
62
+ "required": ["file_path"],
63
+ "additionalProperties": False,
64
+ }
65
+
66
+ async def execute(self, arguments: dict[str, Any]) -> dict[str, Any]:
67
+ """
68
+ Execute the analyze_code_scale tool with CLI-compatible output.
69
+
70
+ Args:
71
+ arguments: Tool arguments containing file_path and optional parameters
72
+
73
+ Returns:
74
+ Dictionary containing analysis results in CLI-compatible format
75
+
76
+ Raises:
77
+ ValueError: If required arguments are missing or invalid
78
+ FileNotFoundError: If the specified file doesn't exist
79
+ """
80
+ # Validate required arguments
81
+ if "file_path" not in arguments:
82
+ raise ValueError("file_path is required")
83
+
84
+ file_path = arguments["file_path"]
85
+ language = arguments.get("language")
86
+ # include_complexity = arguments.get("include_complexity", True) # Not used currently
87
+ # include_details = arguments.get("include_details", False) # Not used currently
88
+
89
+ # Validate file exists
90
+ if not Path(file_path).exists():
91
+ raise FileNotFoundError(f"File not found: {file_path}")
92
+
93
+ # Detect language if not specified
94
+ if not language:
95
+ language = detect_language_from_file(file_path)
96
+ if language == "unknown":
97
+ raise ValueError(f"Could not detect language for file: {file_path}")
98
+
99
+ logger.info(f"Analyzing code scale for {file_path} (language: {language})")
100
+
101
+ try:
102
+ start_time = time.time()
103
+
104
+ # Use AdvancedAnalyzer for comprehensive analysis
105
+ analysis_result = await self.analysis_engine.analyze_file(file_path)
106
+
107
+ # Handle potential None result (for testing purposes with mocked engine)
108
+ # This can only happen in tests where the engine is mocked to return None
109
+ # Use cast to tell MyPy this is possible in testing scenarios
110
+ if cast(Any, analysis_result) is None:
111
+ return {
112
+ "file_path": file_path,
113
+ "success": False,
114
+ "package_name": None,
115
+ "element_counts": {
116
+ "imports": 0,
117
+ "classes": 0,
118
+ "methods": 0,
119
+ "fields": 0,
120
+ "annotations": 0,
121
+ },
122
+ "analysis_time_ms": round((time.time() - start_time) * 1000, 2),
123
+ "error_message": f"Failed to analyze file: {file_path}",
124
+ }
125
+
126
+ # Calculate analysis time
127
+ analysis_time_ms = round((time.time() - start_time) * 1000, 2)
128
+
129
+ # Build CLI-compatible result structure (exact match with CLI --advanced --statistics)
130
+ result = {
131
+ "file_path": file_path,
132
+ "success": True,
133
+ "package_name": (
134
+ analysis_result.package.name
135
+ if analysis_result.package
136
+ and hasattr(analysis_result.package, "name")
137
+ else None
138
+ ),
139
+ "element_counts": {
140
+ "imports": len(analysis_result.imports),
141
+ "classes": len(analysis_result.classes),
142
+ "methods": len(analysis_result.methods),
143
+ "fields": len(analysis_result.fields),
144
+ "annotations": len(getattr(analysis_result, "annotations", [])),
145
+ },
146
+ "analysis_time_ms": analysis_time_ms,
147
+ "error_message": None,
148
+ }
149
+
150
+ logger.info(
151
+ f"Successfully analyzed {file_path}: {len(analysis_result.classes)} classes, "
152
+ f"{len(analysis_result.methods)} methods, {analysis_time_ms}ms"
153
+ )
154
+
155
+ return result
156
+
157
+ except Exception as e:
158
+ logger.error(f"Error analyzing {file_path}: {e}")
159
+ # Return CLI-compatible error format
160
+ return {
161
+ "file_path": file_path,
162
+ "success": False,
163
+ "package_name": None,
164
+ "element_counts": {
165
+ "imports": 0,
166
+ "classes": 0,
167
+ "methods": 0,
168
+ "fields": 0,
169
+ "annotations": 0,
170
+ },
171
+ "analysis_time_ms": 0.0,
172
+ "error_message": str(e),
173
+ }
174
+
175
+ def validate_arguments(self, arguments: dict[str, Any]) -> bool:
176
+ """
177
+ Validate tool arguments against the schema.
178
+
179
+ Args:
180
+ arguments: Arguments to validate
181
+
182
+ Returns:
183
+ True if arguments are valid
184
+
185
+ Raises:
186
+ ValueError: If arguments are invalid
187
+ """
188
+ schema = self.get_tool_schema()
189
+ required_fields = schema.get("required", [])
190
+
191
+ # Check required fields
192
+ for field in required_fields:
193
+ if field not in arguments:
194
+ raise ValueError(f"Required field '{field}' is missing")
195
+
196
+ # Validate file_path
197
+ if "file_path" in arguments:
198
+ file_path = arguments["file_path"]
199
+ if not isinstance(file_path, str):
200
+ raise ValueError("file_path must be a string")
201
+ if not file_path.strip():
202
+ raise ValueError("file_path cannot be empty")
203
+
204
+ # Validate optional fields
205
+ if "language" in arguments:
206
+ language = arguments["language"]
207
+ if not isinstance(language, str):
208
+ raise ValueError("language must be a string")
209
+
210
+ if "include_complexity" in arguments:
211
+ include_complexity = arguments["include_complexity"]
212
+ if not isinstance(include_complexity, bool):
213
+ raise ValueError("include_complexity must be a boolean")
214
+
215
+ if "include_details" in arguments:
216
+ include_details = arguments["include_details"]
217
+ if not isinstance(include_details, bool):
218
+ raise ValueError("include_details must be a boolean")
219
+
220
+ return True
221
+
222
+ def get_tool_definition(self) -> Any:
223
+ """
224
+ Get the MCP tool definition for analyze_code_scale.
225
+
226
+ Returns:
227
+ Tool definition object compatible with MCP server
228
+ """
229
+ try:
230
+ from mcp.types import Tool
231
+
232
+ return Tool(
233
+ name="analyze_code_scale",
234
+ description="Analyze code scale, complexity, and structure metrics with CLI-compatible output format",
235
+ inputSchema=self.get_tool_schema(),
236
+ )
237
+ except ImportError:
238
+ # Fallback for when MCP is not available
239
+ return {
240
+ "name": "analyze_code_scale",
241
+ "description": "Analyze code scale, complexity, and structure metrics with CLI-compatible output format",
242
+ "inputSchema": self.get_tool_schema(),
243
+ }
244
+
245
+
246
+ # Tool instance for easy access
247
+ analyze_scale_tool_cli_compatible = AnalyzeScaleToolCLICompatible()
@@ -1,55 +1,54 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """
4
- Base Tool Protocol for MCP Tools
5
-
6
- This module defines the protocol that all MCP tools must implement
7
- to ensure type safety and consistency.
8
- """
9
-
10
- from typing import Any, Dict, Protocol
11
-
12
-
13
- class MCPTool(Protocol):
14
- """
15
- Protocol for MCP tools.
16
-
17
- All MCP tools must implement this protocol to ensure they have
18
- the required methods for integration with the MCP server.
19
- """
20
-
21
- def get_tool_definition(self) -> Any:
22
- """
23
- Get the MCP tool definition.
24
-
25
- Returns:
26
- Tool definition object compatible with MCP server
27
- """
28
- ...
29
-
30
- async def execute(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
31
- """
32
- Execute the tool with the given arguments.
33
-
34
- Args:
35
- arguments: Tool arguments
36
-
37
- Returns:
38
- Dictionary containing execution results
39
- """
40
- ...
41
-
42
- def validate_arguments(self, arguments: Dict[str, Any]) -> bool:
43
- """
44
- Validate tool arguments.
45
-
46
- Args:
47
- arguments: Arguments to validate
48
-
49
- Returns:
50
- True if arguments are valid
51
-
52
- Raises:
53
- ValueError: If arguments are invalid
54
- """
55
- ...
1
+ #!/usr/bin/env python3
2
+ """
3
+ Base Tool Protocol for MCP Tools
4
+
5
+ This module defines the protocol that all MCP tools must implement
6
+ to ensure type safety and consistency.
7
+ """
8
+
9
+ from typing import Any, Protocol
10
+
11
+
12
+ class MCPTool(Protocol):
13
+ """
14
+ Protocol for MCP tools.
15
+
16
+ All MCP tools must implement this protocol to ensure they have
17
+ the required methods for integration with the MCP server.
18
+ """
19
+
20
+ def get_tool_definition(self) -> Any:
21
+ """
22
+ Get the MCP tool definition.
23
+
24
+ Returns:
25
+ Tool definition object compatible with MCP server
26
+ """
27
+ ...
28
+
29
+ async def execute(self, arguments: dict[str, Any]) -> dict[str, Any]:
30
+ """
31
+ Execute the tool with the given arguments.
32
+
33
+ Args:
34
+ arguments: Tool arguments
35
+
36
+ Returns:
37
+ Dictionary containing execution results
38
+ """
39
+ ...
40
+
41
+ def validate_arguments(self, arguments: dict[str, Any]) -> bool:
42
+ """
43
+ Validate tool arguments.
44
+
45
+ Args:
46
+ arguments: Arguments to validate
47
+
48
+ Returns:
49
+ True if arguments are valid
50
+
51
+ Raises:
52
+ ValueError: If arguments are invalid
53
+ """
54
+ ...