mcp-instana 0.1.0__py3-none-any.whl → 0.2.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 (67) hide show
  1. mcp_instana-0.2.0.dist-info/METADATA +1229 -0
  2. mcp_instana-0.2.0.dist-info/RECORD +59 -0
  3. {mcp_instana-0.1.0.dist-info → mcp_instana-0.2.0.dist-info}/WHEEL +1 -1
  4. mcp_instana-0.2.0.dist-info/entry_points.txt +4 -0
  5. mcp_instana-0.1.0.dist-info/LICENSE → mcp_instana-0.2.0.dist-info/licenses/LICENSE.md +3 -3
  6. src/application/__init__.py +1 -0
  7. src/{client/application_alert_config_mcp_tools.py → application/application_alert_config.py} +251 -273
  8. src/application/application_analyze.py +628 -0
  9. src/application/application_catalog.py +155 -0
  10. src/application/application_global_alert_config.py +653 -0
  11. src/{client/application_metrics_mcp_tools.py → application/application_metrics.py} +113 -131
  12. src/{client/application_resources_mcp_tools.py → application/application_resources.py} +131 -151
  13. src/application/application_settings.py +1731 -0
  14. src/application/application_topology.py +111 -0
  15. src/automation/action_catalog.py +416 -0
  16. src/automation/action_history.py +338 -0
  17. src/core/__init__.py +1 -0
  18. src/core/server.py +586 -0
  19. src/core/utils.py +213 -0
  20. src/event/__init__.py +1 -0
  21. src/event/events_tools.py +850 -0
  22. src/infrastructure/__init__.py +1 -0
  23. src/{client/infrastructure_analyze_mcp_tools.py → infrastructure/infrastructure_analyze.py} +207 -206
  24. src/{client/infrastructure_catalog_mcp_tools.py → infrastructure/infrastructure_catalog.py} +197 -265
  25. src/infrastructure/infrastructure_metrics.py +171 -0
  26. src/{client/infrastructure_resources_mcp_tools.py → infrastructure/infrastructure_resources.py} +198 -227
  27. src/{client/infrastructure_topology_mcp_tools.py → infrastructure/infrastructure_topology.py} +110 -109
  28. src/log/__init__.py +1 -0
  29. src/log/log_alert_configuration.py +331 -0
  30. src/prompts/__init__.py +16 -0
  31. src/prompts/application/__init__.py +1 -0
  32. src/prompts/application/application_alerts.py +54 -0
  33. src/prompts/application/application_catalog.py +26 -0
  34. src/prompts/application/application_metrics.py +57 -0
  35. src/prompts/application/application_resources.py +26 -0
  36. src/prompts/application/application_settings.py +75 -0
  37. src/prompts/application/application_topology.py +30 -0
  38. src/prompts/events/__init__.py +1 -0
  39. src/prompts/events/events_tools.py +161 -0
  40. src/prompts/infrastructure/infrastructure_analyze.py +72 -0
  41. src/prompts/infrastructure/infrastructure_catalog.py +53 -0
  42. src/prompts/infrastructure/infrastructure_metrics.py +45 -0
  43. src/prompts/infrastructure/infrastructure_resources.py +74 -0
  44. src/prompts/infrastructure/infrastructure_topology.py +38 -0
  45. src/prompts/settings/__init__.py +0 -0
  46. src/prompts/settings/custom_dashboard.py +157 -0
  47. src/prompts/website/__init__.py +1 -0
  48. src/prompts/website/website_analyze.py +35 -0
  49. src/prompts/website/website_catalog.py +40 -0
  50. src/prompts/website/website_configuration.py +105 -0
  51. src/prompts/website/website_metrics.py +34 -0
  52. src/settings/__init__.py +1 -0
  53. src/settings/custom_dashboard_tools.py +417 -0
  54. src/website/__init__.py +0 -0
  55. src/website/website_analyze.py +433 -0
  56. src/website/website_catalog.py +171 -0
  57. src/website/website_configuration.py +770 -0
  58. src/website/website_metrics.py +241 -0
  59. mcp_instana-0.1.0.dist-info/METADATA +0 -649
  60. mcp_instana-0.1.0.dist-info/RECORD +0 -19
  61. mcp_instana-0.1.0.dist-info/entry_points.txt +0 -3
  62. src/client/What is the sum of queue depth for all q +0 -55
  63. src/client/events_mcp_tools.py +0 -531
  64. src/client/instana_client_base.py +0 -93
  65. src/client/log_alert_configuration_mcp_tools.py +0 -316
  66. src/client/show the top 5 services with the highest +0 -28
  67. src/mcp_server.py +0 -343
@@ -0,0 +1,155 @@
1
+ """
2
+ Application Catalog MCP Tools Module
3
+
4
+ This module provides application catalog-specific MCP tools for Instana monitoring.
5
+ """
6
+
7
+ import json
8
+ import logging
9
+ import sys
10
+ import traceback
11
+ from datetime import datetime, timedelta
12
+ from typing import Any, Dict, Optional
13
+
14
+ from src.core.utils import (
15
+ BaseInstanaClient,
16
+ register_as_tool,
17
+ with_header_auth,
18
+ )
19
+
20
+ try:
21
+ from instana_client.api.application_catalog_api import (
22
+ ApplicationCatalogApi,
23
+ )
24
+
25
+ except ImportError as e:
26
+ import logging
27
+ logger = logging.getLogger(__name__)
28
+ logger.error(f"Error importing Instana SDK: {e}", exc_info=True)
29
+ raise
30
+
31
+ # Configure logger for this module
32
+ logger = logging.getLogger(__name__)
33
+
34
+ class ApplicationCatalogMCPTools(BaseInstanaClient):
35
+ """Tools for application catalog in Instana MCP."""
36
+
37
+ def __init__(self, read_token: str, base_url: str):
38
+ """Initialize the Application Catalog MCP tools client."""
39
+ super().__init__(read_token=read_token, base_url=base_url)
40
+
41
+ @register_as_tool
42
+ @with_header_auth(ApplicationCatalogApi)
43
+ async def get_application_tag_catalog(self,
44
+ use_case: Optional[str] = None,
45
+ data_source: Optional[str] = None,
46
+ var_from: Optional[int] = None,
47
+ ctx = None, api_client=None) -> Dict[str, Any]:
48
+ """
49
+ Get application tag catalog data from Instana Server.
50
+ This tool retrieves application tag catalog data for a specific use case and data source.
51
+ It allows you to specify the use case (e.g., 'GROUPING'), data source (e.g., 'CALLS'),
52
+ and a timestamp from which to get data.
53
+
54
+ Args:
55
+ use_case: The use case for the tag catalog (e.g., 'GROUPING')
56
+ data_source: The data source for the tag catalog (e.g., 'CALLS')
57
+ var_from: The timestamp from which to get data
58
+ ctx: Context information
59
+
60
+ Returns:
61
+ A dictionary containing the application tag catalog data
62
+ """
63
+ try:
64
+ logger.debug(f"get_application_tag_catalog called with use_case={use_case}, data_source={data_source}, var_from={var_from}")
65
+
66
+ if not var_from:
67
+ var_from = int((datetime.now() - timedelta(hours=1)).timestamp() * 1000)
68
+
69
+ raw_response = api_client.get_application_tag_catalog_without_preload_content(
70
+ use_case=use_case,
71
+ data_source=data_source,
72
+ var_from=var_from,
73
+ )
74
+
75
+ raw_data = raw_response.data
76
+ parsed = json.loads(raw_data)
77
+
78
+ def trim_tag_tree(obj):
79
+ if "tagTree" in obj and isinstance(obj["tagTree"], list):
80
+ obj["tagTree"] = obj["tagTree"][:3] # Limit to top 3 levels
81
+ for level in obj["tagTree"]:
82
+ if "children" in level and isinstance(level["children"], list):
83
+ level["children"] = level["children"][:3] # Limit to 3 tags per level
84
+ return obj
85
+
86
+ # Normalize the parsed structure and apply trim
87
+ if isinstance(parsed, str):
88
+ parsed = json.loads(parsed)
89
+
90
+ if isinstance(parsed, list):
91
+ # Return the list as-is for list responses
92
+ parsed = [trim_tag_tree(item) for item in parsed if isinstance(item, dict)]
93
+ # Wrap list in a dictionary to match return type
94
+ result_dict = {"tags": parsed}
95
+ elif isinstance(parsed, dict):
96
+ result_dict = trim_tag_tree(parsed)
97
+ else:
98
+ logger.debug(f"Unexpected response format: {type(parsed)}")
99
+ return {"error": "Unexpected response format from API"}
100
+
101
+ logger.debug(f"Result from get_application_tag_catalog: {result_dict}")
102
+ return result_dict
103
+
104
+ except Exception as e:
105
+ logger.error(f"Error in get_application_tag_catalog: {e}", exc_info=True)
106
+ return {"error": f"Failed to get application catalog: {e!s}"}
107
+
108
+
109
+ @register_as_tool
110
+ @with_header_auth(ApplicationCatalogApi)
111
+ async def get_application_metric_catalog(self, ctx=None, api_client=None) -> Dict[str, Any]:
112
+ """
113
+ This API endpoint retrieves all available metric definitions for application monitoring.
114
+ This tool allows you to discover what metrics are available for monitoring different components in your application environment.
115
+
116
+ Args:
117
+ ctx: Context information
118
+
119
+ Returns:
120
+ A dictionary containing the application metric catalog data
121
+ """
122
+ try:
123
+ logger.debug("get_application_metric_catalog called")
124
+
125
+ # Call the API to get application metric catalog data
126
+ result = api_client.get_application_catalog_metrics()
127
+
128
+ # Handle different result types
129
+ if hasattr(result, "to_dict"):
130
+ result_data = result.to_dict()
131
+ else:
132
+ result_data = result
133
+
134
+ # Ensure we always return a dict
135
+ if isinstance(result_data, list):
136
+ result_dict = {"metrics": result_data}
137
+ elif isinstance(result_data, dict):
138
+ result_dict = result_data
139
+ else:
140
+ # Handle case where result_data is a MetricDescription object or other type
141
+ try:
142
+ # Try to convert to dict if it has attributes
143
+ if hasattr(result_data, "__dict__"):
144
+ result_dict = {"metrics": [result_data.__dict__]}
145
+ else:
146
+ result_dict = {"metrics": [str(result_data)]}
147
+ except Exception:
148
+ result_dict = {"metrics": [str(result_data)]}
149
+
150
+ logger.debug(f"Result from get_application_metric_catalog: {result_dict}")
151
+ return result_dict
152
+
153
+ except Exception as e:
154
+ logger.error(f"Error in get_application_metric_catalog: {e}", exc_info=True)
155
+ return {"error": f"Failed to get application metric catalog: {e!s}"}