mcp-instana 0.3.1__py3-none-any.whl → 0.7.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 (30) hide show
  1. {mcp_instana-0.3.1.dist-info → mcp_instana-0.7.0.dist-info}/METADATA +186 -311
  2. {mcp_instana-0.3.1.dist-info → mcp_instana-0.7.0.dist-info}/RECORD +30 -22
  3. {mcp_instana-0.3.1.dist-info → mcp_instana-0.7.0.dist-info}/WHEEL +1 -1
  4. src/application/application_alert_config.py +393 -136
  5. src/application/application_analyze.py +597 -594
  6. src/application/application_call_group.py +528 -0
  7. src/application/application_catalog.py +0 -8
  8. src/application/application_global_alert_config.py +275 -57
  9. src/application/application_metrics.py +377 -237
  10. src/application/application_resources.py +414 -325
  11. src/application/application_settings.py +608 -1530
  12. src/application/application_topology.py +62 -62
  13. src/core/custom_dashboard_smart_router_tool.py +135 -0
  14. src/core/server.py +95 -119
  15. src/core/smart_router_tool.py +574 -0
  16. src/core/utils.py +17 -8
  17. src/custom_dashboard/custom_dashboard_tools.py +422 -0
  18. src/event/events_tools.py +57 -9
  19. src/infrastructure/elicitation_handler.py +338 -0
  20. src/infrastructure/entity_registry.py +329 -0
  21. src/infrastructure/infrastructure_analyze_new.py +600 -0
  22. src/infrastructure/{infrastructure_analyze.py → infrastructure_analyze_old.py} +1 -16
  23. src/infrastructure/infrastructure_catalog.py +37 -32
  24. src/infrastructure/infrastructure_metrics.py +93 -16
  25. src/infrastructure/infrastructure_resources.py +6 -24
  26. src/infrastructure/infrastructure_topology.py +29 -23
  27. src/observability.py +29 -0
  28. src/prompts/application/application_settings.py +58 -0
  29. {mcp_instana-0.3.1.dist-info → mcp_instana-0.7.0.dist-info}/entry_points.txt +0 -0
  30. {mcp_instana-0.3.1.dist-info → mcp_instana-0.7.0.dist-info}/licenses/LICENSE.md +0 -0
@@ -33,15 +33,233 @@ class ApplicationGlobalAlertMCPTools(BaseInstanaClient):
33
33
  """Initialize the Application Alert MCP tools client."""
34
34
  super().__init__(read_token=read_token, base_url=base_url)
35
35
 
36
- @register_as_tool(
37
- title="Find Active Global Application Alert Configs",
38
- annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False)
39
- )
36
+ # CRUD Operations Dispatcher - called by smart_router_tool.py
37
+ async def execute_alert_config_operation(
38
+ self,
39
+ operation: str,
40
+ application_id: Optional[str] = None,
41
+ id: Optional[str] = None,
42
+ alert_ids: Optional[List[str]] = None,
43
+ valid_on: Optional[int] = None,
44
+ created: Optional[int] = None,
45
+ payload: Optional[Union[Dict[str, Any], str]] = None,
46
+ ctx=None
47
+ ) -> Dict[str, Any]:
48
+ """
49
+ Execute Global Application Alert Config CRUD operations.
50
+ Called by the smart router tool.
51
+
52
+ Args:
53
+ operation: Operation to perform (find_active, find_versions, find, create, update, delete, enable, disable, restore)
54
+ application_id: Application ID (for find_active)
55
+ id: Alert config ID
56
+ alert_ids: List of alert IDs to filter
57
+ valid_on: Unix timestamp for specific version
58
+ created: Unix timestamp for restore
59
+ payload: Configuration payload
60
+ ctx: MCP context
61
+
62
+ Returns:
63
+ Operation result dictionary
64
+ """
65
+ try:
66
+ if operation == "find_active":
67
+ return await self._find_active_configs(application_id, alert_ids, ctx)
68
+ elif operation == "find_versions":
69
+ return await self._find_config_versions(id, ctx)
70
+ elif operation == "find":
71
+ return await self._find_config(id, valid_on, ctx)
72
+ elif operation == "create":
73
+ return await self._create_config(payload, ctx)
74
+ elif operation == "update":
75
+ return await self._update_config(id, payload, ctx)
76
+ elif operation == "delete":
77
+ return await self._delete_config(id, ctx)
78
+ elif operation == "enable":
79
+ return await self._enable_config(id, ctx)
80
+ elif operation == "disable":
81
+ return await self._disable_config(id, ctx)
82
+ elif operation == "restore":
83
+ return await self._restore_config(id, created, ctx)
84
+ else:
85
+ return {"error": f"Operation '{operation}' not supported"}
86
+
87
+ except Exception as e:
88
+ logger.error(f"Error executing {operation}: {e}", exc_info=True)
89
+ return {"error": f"Error executing {operation}: {e!s}"}
90
+
91
+ # Individual operation functions
92
+
93
+ @with_header_auth(GlobalApplicationAlertConfigurationApi)
94
+ async def _find_active_configs(
95
+ self,
96
+ application_id: Optional[str],
97
+ alert_ids: Optional[List[str]],
98
+ ctx=None,
99
+ api_client=None
100
+ ) -> Dict[str, Any]:
101
+ """Find active global application alert configs."""
102
+ if not application_id:
103
+ return {"error": "application_id is required for find_active operation"}
104
+
105
+ return await self.find_active_global_application_alert_configs(
106
+ application_id=application_id,
107
+ alert_ids=alert_ids,
108
+ ctx=ctx,
109
+ api_client=api_client
110
+ )
111
+
112
+ @with_header_auth(GlobalApplicationAlertConfigurationApi)
113
+ async def _find_config_versions(
114
+ self,
115
+ id: Optional[str],
116
+ ctx=None,
117
+ api_client=None
118
+ ) -> Dict[str, Any]:
119
+ """Find all versions of a global application alert config."""
120
+ if not id:
121
+ return {"error": "id is required for find_versions operation"}
122
+
123
+ return await self.find_global_application_alert_config_versions(
124
+ id=id,
125
+ ctx=ctx,
126
+ api_client=api_client
127
+ )
128
+
129
+ @with_header_auth(GlobalApplicationAlertConfigurationApi)
130
+ async def _find_config(
131
+ self,
132
+ id: Optional[str],
133
+ valid_on: Optional[int],
134
+ ctx=None,
135
+ api_client=None
136
+ ) -> Dict[str, Any]:
137
+ """Find a specific global application alert config."""
138
+ return await self.find_global_application_alert_config(
139
+ id=id,
140
+ valid_on=valid_on,
141
+ ctx=ctx,
142
+ api_client=api_client
143
+ )
144
+
145
+ @with_header_auth(GlobalApplicationAlertConfigurationApi)
146
+ async def _create_config(
147
+ self,
148
+ payload: Optional[Union[Dict[str, Any], str]],
149
+ ctx=None,
150
+ api_client=None
151
+ ) -> Dict[str, Any]:
152
+ """Create a new global application alert config."""
153
+ if not payload:
154
+ return {"error": "payload is required for create operation"}
155
+
156
+ return await self.create_global_application_alert_config(
157
+ payload=payload,
158
+ ctx=ctx,
159
+ api_client=api_client
160
+ )
161
+
162
+ @with_header_auth(GlobalApplicationAlertConfigurationApi)
163
+ async def _update_config(
164
+ self,
165
+ id: Optional[str],
166
+ payload: Optional[Union[Dict[str, Any], str]],
167
+ ctx=None,
168
+ api_client=None
169
+ ) -> Dict[str, Any]:
170
+ """Update an existing global application alert config."""
171
+ if not id:
172
+ return {"error": "id is required for update operation"}
173
+ if not payload:
174
+ return {"error": "payload is required for update operation"}
175
+
176
+ return await self.update_global_application_alert_config(
177
+ id=id,
178
+ payload=payload,
179
+ ctx=ctx,
180
+ api_client=api_client
181
+ )
182
+
183
+ @with_header_auth(GlobalApplicationAlertConfigurationApi)
184
+ async def _delete_config(
185
+ self,
186
+ id: Optional[str],
187
+ ctx=None,
188
+ api_client=None
189
+ ) -> Dict[str, Any]:
190
+ """Delete a global application alert config."""
191
+ if not id:
192
+ return {"error": "id is required for delete operation"}
193
+
194
+ return await self.delete_global_application_alert_config(
195
+ id=id,
196
+ ctx=ctx,
197
+ api_client=api_client
198
+ )
199
+
200
+ @with_header_auth(GlobalApplicationAlertConfigurationApi)
201
+ async def _enable_config(
202
+ self,
203
+ id: Optional[str],
204
+ ctx=None,
205
+ api_client=None
206
+ ) -> Dict[str, Any]:
207
+ """Enable a global application alert config."""
208
+ if not id:
209
+ return {"error": "id is required for enable operation"}
210
+
211
+ return await self.enable_global_application_alert_config(
212
+ id=id,
213
+ ctx=ctx,
214
+ api_client=api_client
215
+ )
216
+
217
+ @with_header_auth(GlobalApplicationAlertConfigurationApi)
218
+ async def _disable_config(
219
+ self,
220
+ id: Optional[str],
221
+ ctx=None,
222
+ api_client=None
223
+ ) -> Dict[str, Any]:
224
+ """Disable a global application alert config."""
225
+ if not id:
226
+ return {"error": "id is required for disable operation"}
227
+
228
+ return await self.disable_global_application_alert_config(
229
+ id=id,
230
+ ctx=ctx,
231
+ api_client=api_client
232
+ )
233
+
234
+ @with_header_auth(GlobalApplicationAlertConfigurationApi)
235
+ async def _restore_config(
236
+ self,
237
+ id: Optional[str],
238
+ created: Optional[int],
239
+ ctx=None,
240
+ api_client=None
241
+ ) -> Dict[str, Any]:
242
+ """Restore a deleted global application alert config."""
243
+ if not id:
244
+ return {"error": "id is required for restore operation"}
245
+ if not created:
246
+ return {"error": "created timestamp is required for restore operation"}
247
+
248
+ return await self.restore_global_application_alert_config(
249
+ id=id,
250
+ created=created,
251
+ ctx=ctx,
252
+ api_client=api_client
253
+ )
254
+
255
+ # Original individual methods - no @register_as_tool decorator
256
+ # These are called internally by the operation functions above
257
+
40
258
  @with_header_auth(GlobalApplicationAlertConfigurationApi)
41
259
  async def find_active_global_application_alert_configs(self,
42
260
  application_id: str,
43
261
  alert_ids: Optional[List[str]] = None,
44
- ctx=None, api_client=None) -> List[Dict[str, Any]]:
262
+ ctx=None, api_client=None) -> Dict[str, Any]:
45
263
  """
46
264
  Get All Global Smart Alert Configuration.
47
265
 
@@ -63,42 +281,63 @@ class ApplicationGlobalAlertMCPTools(BaseInstanaClient):
63
281
 
64
282
  # Validate required parameters
65
283
  if not application_id:
66
- return [{"error": "application_id is required"}]
284
+ return {"error": "application_id is required"}
67
285
 
68
286
  # Call the find_active_global_application_alert_configs method from the SDK
69
287
  logger.debug(f"Calling find_active_global_application_alert_configs with application_id={application_id}, alert_ids={alert_ids}")
70
- result = api_client.find_active_global_application_alert_configs(
288
+ response = api_client.find_active_global_application_alert_configs_without_preload_content(
71
289
  application_id=application_id,
72
290
  alert_ids=alert_ids
73
291
  )
74
292
 
75
- # Convert the result to a list format
76
- if isinstance(result, list):
77
- # If it's already a list, convert each item to dict if needed
78
- result_list = []
79
- for item in result:
80
- if hasattr(item, 'to_dict'):
81
- result_list.append(item.to_dict())
82
- else:
83
- result_list.append(item)
84
- elif hasattr(result, 'to_dict'):
85
- # If it's a single object, wrap it in a list
86
- result_list = [result.to_dict()]
87
- else:
88
- # If it's already a dict or other format, wrap it in a list
89
- result_list = [result] if result else []
293
+ import json
294
+
295
+ raw_data = response.data.decode('utf-8')
296
+ logger.debug(f"Raw data: {raw_data}")
297
+
298
+ try:
299
+ result = json.loads(raw_data)
300
+ logger.debug(f"Parsed JSON result: {result}")
301
+
302
+ if isinstance(result, list):
303
+ configs = result
304
+ else:
305
+ configs = [result] if result else []
306
+
307
+ # Limit to first 10 results
308
+ total_count = len(configs)
309
+ limited_configs = configs[:10]
310
+
311
+ # Provide helpful feedback based on the result
312
+ if not configs:
313
+ return {
314
+ "configs": [],
315
+ "count": 0,
316
+ "total": 0,
317
+ "showing": 0,
318
+ "message": f"No active global alert configurations found for application ID: {application_id}",
319
+ "suggestion": "You can create a new global alert configuration using the 'create' operation."
320
+ }
321
+ else:
322
+ return {
323
+ "configs": limited_configs,
324
+ "count": len(limited_configs),
325
+ "total": total_count,
326
+ "showing": len(limited_configs),
327
+ "message": f"Found {total_count} active global alert configuration(s) for application ID: {application_id}. Showing first {len(limited_configs)}."
328
+ }
329
+
330
+ except json.JSONDecodeError as e:
331
+ error_msg = f"Failed to parse response JSON: {e}"
332
+ logger.error(error_msg)
333
+ return {"error": error_msg}
90
334
 
91
- logger.debug(f"Result from find_active_global_application_alert_configs: {result_list}")
92
- return result_list
93
335
  except Exception as e:
94
336
  logger.error(f"Error in find_active_global_application_alert_configs: {e}", exc_info=True)
95
- return [{"error": f"Failed to get active global application alert config: {e!s}"}]
337
+ return {"error": f"Failed to get active global application alert config: {e!s}"}
96
338
 
97
339
 
98
- @register_as_tool(
99
- title="Find Global Application Alert Config Versions",
100
- annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False)
101
- )
340
+ # @register_as_tool decorator removed - now called via router
102
341
  @with_header_auth(GlobalApplicationAlertConfigurationApi)
103
342
  async def find_global_application_alert_config_versions(self,
104
343
  id: str,
@@ -146,10 +385,7 @@ class ApplicationGlobalAlertMCPTools(BaseInstanaClient):
146
385
  logger.error(f"Error in find_global_application_alert_config_versions: {e}", exc_info=True)
147
386
  return {"error": f"Failed to get global application alert config versions: {e!s}"}
148
387
 
149
- @register_as_tool(
150
- title="Find Global Application Alert Config",
151
- annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False)
152
- )
388
+ # @register_as_tool decorator removed - now called via router
153
389
  @with_header_auth(GlobalApplicationAlertConfigurationApi)
154
390
  async def find_global_application_alert_config(self,
155
391
  id: Optional[str] = None,
@@ -195,10 +431,7 @@ class ApplicationGlobalAlertMCPTools(BaseInstanaClient):
195
431
  logger.error(f"Error in find_global_application_alert_config: {e}", exc_info=True)
196
432
  return {"error": f"Failed to get global application alert configs: {e!s}"}
197
433
 
198
- @register_as_tool(
199
- title="Delete Global Application Alert Config",
200
- annotations=ToolAnnotations(readOnlyHint=False, destructiveHint=True)
201
- )
434
+ # @register_as_tool decorator removed - now called via router
202
435
  @with_header_auth(GlobalApplicationAlertConfigurationApi)
203
436
  async def delete_global_application_alert_config(self,
204
437
  id: str,
@@ -239,10 +472,7 @@ class ApplicationGlobalAlertMCPTools(BaseInstanaClient):
239
472
  logger.error(f"Error in delete_global_application_alert_config: {e}", exc_info=True)
240
473
  return {"error": f"Failed to delete global application alert config: {e!s}"}
241
474
 
242
- @register_as_tool(
243
- title="Enable Global Application Alert Config",
244
- annotations=ToolAnnotations(readOnlyHint=False, destructiveHint=False)
245
- )
475
+ # @register_as_tool decorator removed - now called via router
246
476
  @with_header_auth(GlobalApplicationAlertConfigurationApi)
247
477
  async def enable_global_application_alert_config(self,
248
478
  id: str,
@@ -287,10 +517,7 @@ class ApplicationGlobalAlertMCPTools(BaseInstanaClient):
287
517
  logger.error(f"Error in enable_global_application_alert_config: {e}", exc_info=True)
288
518
  return {"error": f"Failed to enable global application alert config: {e!s}"}
289
519
 
290
- @register_as_tool(
291
- title="Disable Global Application Alert Config",
292
- annotations=ToolAnnotations(readOnlyHint=False, destructiveHint=False)
293
- )
520
+ # @register_as_tool decorator removed - now called via router
294
521
  @with_header_auth(GlobalApplicationAlertConfigurationApi)
295
522
  async def disable_global_application_alert_config(self,
296
523
  id: str,
@@ -335,10 +562,7 @@ class ApplicationGlobalAlertMCPTools(BaseInstanaClient):
335
562
  logger.error(f"Error in disable_global_application_alert_config: {e}", exc_info=True)
336
563
  return {"error": f"Failed to disable global application alert config: {e!s}"}
337
564
 
338
- @register_as_tool(
339
- title="Restore Global Application Alert Config",
340
- annotations=ToolAnnotations(readOnlyHint=False, destructiveHint=False)
341
- )
565
+ # @register_as_tool decorator removed - now called via router
342
566
  @with_header_auth(GlobalApplicationAlertConfigurationApi)
343
567
  async def restore_global_application_alert_config(self,
344
568
  id: str,
@@ -388,10 +612,7 @@ class ApplicationGlobalAlertMCPTools(BaseInstanaClient):
388
612
  logger.error(f"Error in restore_global_application_alert_config: {e}", exc_info=True)
389
613
  return {"error": f"Failed to restore global application alert config: {e!s}"}
390
614
 
391
- @register_as_tool(
392
- title="Create Global Application Alert Config",
393
- annotations=ToolAnnotations(readOnlyHint=False, destructiveHint=False)
394
- )
615
+ # @register_as_tool decorator removed - now called via router
395
616
  @with_header_auth(GlobalApplicationAlertConfigurationApi)
396
617
  async def create_global_application_alert_config(self,
397
618
  payload: Union[Dict[str, Any], str],
@@ -533,10 +754,7 @@ class ApplicationGlobalAlertMCPTools(BaseInstanaClient):
533
754
  logger.error(f"Error in create_global_application_alert_config: {e}", exc_info=True)
534
755
  return {"error": f"Failed to create global application alert config: {e!s}"}
535
756
 
536
- @register_as_tool(
537
- title="Update Global Application Alert Config",
538
- annotations=ToolAnnotations(readOnlyHint=False, destructiveHint=False)
539
- )
757
+ # @register_as_tool decorator removed - now called via router
540
758
  @with_header_auth(GlobalApplicationAlertConfigurationApi)
541
759
  async def update_global_application_alert_config(self,
542
760
  id: str,