awslabs.prometheus-mcp-server 0.1.1__tar.gz → 0.2.1__tar.gz

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 (45) hide show
  1. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/.gitignore +7 -0
  2. awslabs_prometheus_mcp_server-0.2.1/CHANGELOG.md +22 -0
  3. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/Dockerfile +4 -4
  4. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/PKG-INFO +55 -15
  5. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/README.md +54 -14
  6. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/awslabs/prometheus_mcp_server/__init__.py +1 -1
  7. awslabs_prometheus_mcp_server-0.2.1/awslabs/prometheus_mcp_server/models.py +50 -0
  8. awslabs_prometheus_mcp_server-0.2.1/awslabs/prometheus_mcp_server/server.py +1106 -0
  9. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/pyproject.toml +1 -1
  10. awslabs_prometheus_mcp_server-0.2.1/tests/conftest.py +29 -0
  11. awslabs_prometheus_mcp_server-0.2.1/tests/test_aws_credentials.py +116 -0
  12. awslabs_prometheus_mcp_server-0.2.1/tests/test_config_manager.py +112 -0
  13. awslabs_prometheus_mcp_server-0.2.1/tests/test_consts.py +78 -0
  14. awslabs_prometheus_mcp_server-0.2.1/tests/test_coverage_gaps.py +128 -0
  15. awslabs_prometheus_mcp_server-0.2.1/tests/test_coverage_improvement.py +240 -0
  16. awslabs_prometheus_mcp_server-0.2.1/tests/test_final_coverage.py +35 -0
  17. awslabs_prometheus_mcp_server-0.2.1/tests/test_main.py +242 -0
  18. awslabs_prometheus_mcp_server-0.2.1/tests/test_models.py +76 -0
  19. awslabs_prometheus_mcp_server-0.2.1/tests/test_prometheus_client.py +117 -0
  20. awslabs_prometheus_mcp_server-0.2.1/tests/test_prometheus_connection.py +143 -0
  21. awslabs_prometheus_mcp_server-0.2.1/tests/test_security_validator.py +91 -0
  22. awslabs_prometheus_mcp_server-0.2.1/tests/test_server_coverage.py +222 -0
  23. awslabs_prometheus_mcp_server-0.2.1/tests/test_tools.py +635 -0
  24. awslabs_prometheus_mcp_server-0.2.1/tests/test_workspace_config.py +399 -0
  25. awslabs_prometheus_mcp_server-0.2.1/uv-requirements.txt +26 -0
  26. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/uv.lock +1 -1
  27. awslabs_prometheus_mcp_server-0.1.1/CHANGELOG.md +0 -12
  28. awslabs_prometheus_mcp_server-0.1.1/awslabs/prometheus_mcp_server/models.py +0 -108
  29. awslabs_prometheus_mcp_server-0.1.1/awslabs/prometheus_mcp_server/server.py +0 -668
  30. awslabs_prometheus_mcp_server-0.1.1/tests/test_config.py +0 -366
  31. awslabs_prometheus_mcp_server-0.1.1/tests/test_edge_cases.py +0 -125
  32. awslabs_prometheus_mcp_server-0.1.1/tests/test_error_handling.py +0 -139
  33. awslabs_prometheus_mcp_server-0.1.1/tests/test_main.py +0 -137
  34. awslabs_prometheus_mcp_server-0.1.1/tests/test_make_prometheus_request.py +0 -263
  35. awslabs_prometheus_mcp_server-0.1.1/tests/test_models.py +0 -179
  36. awslabs_prometheus_mcp_server-0.1.1/tests/test_prometheus_connection.py +0 -150
  37. awslabs_prometheus_mcp_server-0.1.1/tests/test_remaining_coverage.py +0 -127
  38. awslabs_prometheus_mcp_server-0.1.1/tests/test_server.py +0 -128
  39. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/.python-version +0 -0
  40. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/LICENSE +0 -0
  41. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/NOTICE +0 -0
  42. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/awslabs/__init__.py +0 -0
  43. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/awslabs/prometheus_mcp_server/consts.py +0 -0
  44. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/docker-healthcheck.sh +0 -0
  45. {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.1}/tests/test_init.py +0 -0
@@ -563,3 +563,10 @@ samples/mcp-integration-with-nova-canvas/output/*
563
563
 
564
564
  memory-bank/*
565
565
  .clinerules
566
+
567
+ # OpenAPI MCP Server specific ignores
568
+ src/openapi-mcp-server/generated-diagrams/*
569
+ src/openapi-mcp-server/*.txt
570
+ src/openapi-mcp-server/*-coverage.xml
571
+ src/openapi-mcp-server/junit.xml
572
+ executive-summary.md
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.2.0] - 2024-06-01
9
+
10
+ ### Changed
11
+
12
+ - Refactored to use workspace-based configuration model
13
+ - Added GetAvailableWorkspaces tool to list available Prometheus workspaces
14
+ - Modified all tools to require workspace_id parameter
15
+ - Removed requirement for Prometheus URL at startup
16
+ - Added per-request workspace configuration
17
+
18
+ ## [0.1.1] - 2024-05-15
19
+
20
+ ### Added
21
+
22
+ - Initial project setup
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  # dependabot should continue to update this to the latest hash.
16
- FROM public.ecr.aws/sam/build-python3.10@sha256:a40f492a0cd8d76557f8a187fc00e49e8864b3cea683e74718ce317790c1ce61 AS uv
16
+ FROM public.ecr.aws/sam/build-python3.10@sha256:d821662474d65f3cf2fc97dba2fa807a3adb580d02895fc4545527812550ea65 AS uv
17
17
 
18
18
  # Install the project into `/app`
19
19
  WORKDIR /app
@@ -31,11 +31,11 @@ ENV UV_PYTHON_PREFERENCE=only-system
31
31
  ENV UV_FROZEN=true
32
32
 
33
33
  # Copy the required files first
34
- COPY pyproject.toml uv.lock ./
34
+ COPY pyproject.toml uv.lock uv-requirements.txt ./
35
35
 
36
36
  # Install the project's dependencies using the lockfile and settings
37
37
  RUN --mount=type=cache,target=/root/.cache/uv \
38
- pip install uv && \
38
+ pip install --require-hashes --requirement uv-requirements.txt && \
39
39
  uv sync --frozen --no-install-project --no-dev --no-editable
40
40
 
41
41
  # Then, add the rest of the project source code and install it
@@ -47,7 +47,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
47
47
  # Make the directory just in case it doesn't exist
48
48
  RUN mkdir -p /root/.local
49
49
 
50
- FROM public.ecr.aws/sam/build-python3.10@sha256:a40f492a0cd8d76557f8a187fc00e49e8864b3cea683e74718ce317790c1ce61
50
+ FROM public.ecr.aws/sam/build-python3.10@sha256:d821662474d65f3cf2fc97dba2fa807a3adb580d02895fc4545527812550ea65
51
51
 
52
52
  # Place executables in the environment at the front of the path and include other binaries
53
53
  ENV PATH="/app/.venv/bin:$PATH:/usr/sbin"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: awslabs.prometheus-mcp-server
3
- Version: 0.1.1
3
+ Version: 0.2.1
4
4
  Summary: MCP server for interacting with AWS Managed Prometheus
5
5
  Project-URL: homepage, https://awslabs.github.io/mcp/
6
6
  Project-URL: docs, https://awslabs.github.io/mcp/servers/prometheus-mcp-server/
@@ -47,6 +47,8 @@ This MCP server is designed to be fully compatible with Amazon Q developer CLI,
47
47
 
48
48
  ## Installation
49
49
 
50
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-light.svg)](https://cursor.com/install-mcp?name=awslabs.prometheus-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGF3c2xhYnMucHJvbWV0aGV1cy1tY3Atc2VydmVyQGxhdGVzdCAtLXVybCBodHRwczovL2Fwcy13b3Jrc3BhY2VzLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tL3dvcmtzcGFjZXMvd3MtPFdvcmtzcGFjZSBJRD4gLS1yZWdpb24gPFlvdXIgQVdTIFJlZ2lvbj4gLS1wcm9maWxlIDxZb3VyIENMSSBQcm9maWxlIFtkZWZhdWx0XSBpZiBubyBwcm9maWxlIGlzIHVzZWQ%2BIiwiZW52Ijp7IkZBU1RNQ1BfTE9HX0xFVkVMIjoiREVCVUciLCJBV1NfUFJPRklMRSI6IjxZb3VyIENMSSBQcm9maWxlIFtkZWZhdWx0XSBpZiBubyBwcm9maWxlIGlzIHVzZWQ%2BIn19)
51
+
50
52
  ### Prerequisites
51
53
 
52
54
  - Python 3.10 or higher
@@ -69,23 +71,41 @@ mkdir -p ~/.aws/amazonq/
69
71
  ```
70
72
 
71
73
  2. Add the following to `~/.aws/amazonq/mcp.json`:
74
+
75
+ ### Basic Configuration
76
+ ```json
77
+ {
78
+ "mcpServers": {
79
+ "prometheus": {
80
+ "command": "uvx",
81
+ "args": [
82
+ "awslabs.prometheus-mcp-server@latest"
83
+ ],
84
+ "env": {
85
+ "FASTMCP_LOG_LEVEL": "DEBUG"
86
+ }
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ ### Configuration with Optional Arguments
72
93
  ```json
73
94
  {
74
95
  "mcpServers": {
75
- "awslabs.prometheus-mcp-server": {
96
+ "prometheus": {
76
97
  "command": "uvx",
77
98
  "args": [
78
99
  "awslabs.prometheus-mcp-server@latest",
79
100
  "--url",
80
- "https://aps-workspaces.us-east-1.amazonaws.com/workspaces/ws-<Workspace ID>",
101
+ "https://aps-workspaces.<AWS Region>.amazonaws.com/workspaces/ws-<Workspace ID>",
81
102
  "--region",
82
103
  "<Your AWS Region>",
83
104
  "--profile",
84
- "<Your CLI Profile [default] if no profile is used>"
105
+ "<Your CLI Profile>"
85
106
  ],
86
107
  "env": {
87
- "FASTMCP_LOG_LEVEL": "DEBUG",
88
- "AWS_PROFILE": "<Your CLI Profile [default] if no profile is used>"
108
+ "FASTMCP_LOG_LEVEL": "DEBUG"
89
109
  }
90
110
  }
91
111
  }
@@ -96,30 +116,46 @@ mkdir -p ~/.aws/amazonq/
96
116
 
97
117
  ## Available Tools
98
118
 
99
- 1. **execute_query**
119
+ 1. **GetAvailableWorkspaces**
120
+ - List all available Prometheus workspaces in the specified region
121
+ - Parameters: region (optional)
122
+ - Returns: List of workspaces with IDs, aliases, and status
123
+
124
+ 2. **ExecuteQuery**
100
125
  - Execute instant PromQL queries against Prometheus
101
- - Parameters: query (required), time (optional)
126
+ - Parameters: workspace_id (required), query (required), time (optional), region (optional)
102
127
 
103
- 2. **execute_range_query**
128
+ 3. **ExecuteRangeQuery**
104
129
  - Execute PromQL queries over a time range
105
- - Parameters: query, start time, end time, step interval
130
+ - Parameters: workspace_id (required), query, start time, end time, step interval, region (optional)
106
131
 
107
- 3. **list_metrics**
132
+ 4. **ListMetrics**
108
133
  - Retrieve all available metric names from Prometheus
134
+ - Parameters: workspace_id (required), region (optional)
109
135
  - Returns: Sorted list of metric names
110
136
 
111
- 4. **get_server_info**
137
+ 5. **GetServerInfo**
112
138
  - Retrieve server configuration details
139
+ - Parameters: workspace_id (required), region (optional)
113
140
  - Returns: URL, region, profile, and service information
114
141
 
115
142
  ## Example Queries
116
143
 
117
144
  ```python
145
+ # Get available workspaces
146
+ workspaces = await get_available_workspaces()
147
+ for ws in workspaces['workspaces']:
148
+ print(f"ID: {ws['workspace_id']}, Alias: {ws['alias']}, Status: {ws['status']}")
149
+
118
150
  # Execute an instant query
119
- result = await execute_query("up")
151
+ result = await execute_query(
152
+ workspace_id="ws-12345678-abcd-1234-efgh-123456789012",
153
+ query="up"
154
+ )
120
155
 
121
156
  # Execute a range query
122
157
  data = await execute_range_query(
158
+ workspace_id="ws-12345678-abcd-1234-efgh-123456789012",
123
159
  query="rate(node_cpu_seconds_total[5m])",
124
160
  start="2023-01-01T00:00:00Z",
125
161
  end="2023-01-01T01:00:00Z",
@@ -127,10 +163,14 @@ data = await execute_range_query(
127
163
  )
128
164
 
129
165
  # List available metrics
130
- metrics = await list_metrics()
166
+ metrics = await list_metrics(
167
+ workspace_id="ws-12345678-abcd-1234-efgh-123456789012"
168
+ )
131
169
 
132
170
  # Get server information
133
- info = await get_server_info()
171
+ info = await get_server_info(
172
+ workspace_id="ws-12345678-abcd-1234-efgh-123456789012"
173
+ )
134
174
  ```
135
175
 
136
176
  ## Troubleshooting
@@ -15,6 +15,8 @@ This MCP server is designed to be fully compatible with Amazon Q developer CLI,
15
15
 
16
16
  ## Installation
17
17
 
18
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-light.svg)](https://cursor.com/install-mcp?name=awslabs.prometheus-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGF3c2xhYnMucHJvbWV0aGV1cy1tY3Atc2VydmVyQGxhdGVzdCAtLXVybCBodHRwczovL2Fwcy13b3Jrc3BhY2VzLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tL3dvcmtzcGFjZXMvd3MtPFdvcmtzcGFjZSBJRD4gLS1yZWdpb24gPFlvdXIgQVdTIFJlZ2lvbj4gLS1wcm9maWxlIDxZb3VyIENMSSBQcm9maWxlIFtkZWZhdWx0XSBpZiBubyBwcm9maWxlIGlzIHVzZWQ%2BIiwiZW52Ijp7IkZBU1RNQ1BfTE9HX0xFVkVMIjoiREVCVUciLCJBV1NfUFJPRklMRSI6IjxZb3VyIENMSSBQcm9maWxlIFtkZWZhdWx0XSBpZiBubyBwcm9maWxlIGlzIHVzZWQ%2BIn19)
19
+
18
20
  ### Prerequisites
19
21
 
20
22
  - Python 3.10 or higher
@@ -37,23 +39,41 @@ mkdir -p ~/.aws/amazonq/
37
39
  ```
38
40
 
39
41
  2. Add the following to `~/.aws/amazonq/mcp.json`:
42
+
43
+ ### Basic Configuration
44
+ ```json
45
+ {
46
+ "mcpServers": {
47
+ "prometheus": {
48
+ "command": "uvx",
49
+ "args": [
50
+ "awslabs.prometheus-mcp-server@latest"
51
+ ],
52
+ "env": {
53
+ "FASTMCP_LOG_LEVEL": "DEBUG"
54
+ }
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ ### Configuration with Optional Arguments
40
61
  ```json
41
62
  {
42
63
  "mcpServers": {
43
- "awslabs.prometheus-mcp-server": {
64
+ "prometheus": {
44
65
  "command": "uvx",
45
66
  "args": [
46
67
  "awslabs.prometheus-mcp-server@latest",
47
68
  "--url",
48
- "https://aps-workspaces.us-east-1.amazonaws.com/workspaces/ws-<Workspace ID>",
69
+ "https://aps-workspaces.<AWS Region>.amazonaws.com/workspaces/ws-<Workspace ID>",
49
70
  "--region",
50
71
  "<Your AWS Region>",
51
72
  "--profile",
52
- "<Your CLI Profile [default] if no profile is used>"
73
+ "<Your CLI Profile>"
53
74
  ],
54
75
  "env": {
55
- "FASTMCP_LOG_LEVEL": "DEBUG",
56
- "AWS_PROFILE": "<Your CLI Profile [default] if no profile is used>"
76
+ "FASTMCP_LOG_LEVEL": "DEBUG"
57
77
  }
58
78
  }
59
79
  }
@@ -64,30 +84,46 @@ mkdir -p ~/.aws/amazonq/
64
84
 
65
85
  ## Available Tools
66
86
 
67
- 1. **execute_query**
87
+ 1. **GetAvailableWorkspaces**
88
+ - List all available Prometheus workspaces in the specified region
89
+ - Parameters: region (optional)
90
+ - Returns: List of workspaces with IDs, aliases, and status
91
+
92
+ 2. **ExecuteQuery**
68
93
  - Execute instant PromQL queries against Prometheus
69
- - Parameters: query (required), time (optional)
94
+ - Parameters: workspace_id (required), query (required), time (optional), region (optional)
70
95
 
71
- 2. **execute_range_query**
96
+ 3. **ExecuteRangeQuery**
72
97
  - Execute PromQL queries over a time range
73
- - Parameters: query, start time, end time, step interval
98
+ - Parameters: workspace_id (required), query, start time, end time, step interval, region (optional)
74
99
 
75
- 3. **list_metrics**
100
+ 4. **ListMetrics**
76
101
  - Retrieve all available metric names from Prometheus
102
+ - Parameters: workspace_id (required), region (optional)
77
103
  - Returns: Sorted list of metric names
78
104
 
79
- 4. **get_server_info**
105
+ 5. **GetServerInfo**
80
106
  - Retrieve server configuration details
107
+ - Parameters: workspace_id (required), region (optional)
81
108
  - Returns: URL, region, profile, and service information
82
109
 
83
110
  ## Example Queries
84
111
 
85
112
  ```python
113
+ # Get available workspaces
114
+ workspaces = await get_available_workspaces()
115
+ for ws in workspaces['workspaces']:
116
+ print(f"ID: {ws['workspace_id']}, Alias: {ws['alias']}, Status: {ws['status']}")
117
+
86
118
  # Execute an instant query
87
- result = await execute_query("up")
119
+ result = await execute_query(
120
+ workspace_id="ws-12345678-abcd-1234-efgh-123456789012",
121
+ query="up"
122
+ )
88
123
 
89
124
  # Execute a range query
90
125
  data = await execute_range_query(
126
+ workspace_id="ws-12345678-abcd-1234-efgh-123456789012",
91
127
  query="rate(node_cpu_seconds_total[5m])",
92
128
  start="2023-01-01T00:00:00Z",
93
129
  end="2023-01-01T01:00:00Z",
@@ -95,10 +131,14 @@ data = await execute_range_query(
95
131
  )
96
132
 
97
133
  # List available metrics
98
- metrics = await list_metrics()
134
+ metrics = await list_metrics(
135
+ workspace_id="ws-12345678-abcd-1234-efgh-123456789012"
136
+ )
99
137
 
100
138
  # Get server information
101
- info = await get_server_info()
139
+ info = await get_server_info(
140
+ workspace_id="ws-12345678-abcd-1234-efgh-123456789012"
141
+ )
102
142
  ```
103
143
 
104
144
  ## Troubleshooting
@@ -14,4 +14,4 @@
14
14
 
15
15
  """awslabs Prometheus MCP Server."""
16
16
 
17
- __version__ = '0.1.0'
17
+ __version__ = '0.2.0'
@@ -0,0 +1,50 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Data models for the Prometheus MCP server."""
16
+
17
+ from pydantic import BaseModel, Field
18
+ from typing import List, Optional
19
+
20
+
21
+ class MetricsList(BaseModel):
22
+ """List of available metrics in Prometheus.
23
+
24
+ Attributes:
25
+ metrics: List of metric names available in the Prometheus server.
26
+ """
27
+
28
+ metrics: List[str] = Field(
29
+ description='List of metric names available in the Prometheus server'
30
+ )
31
+
32
+
33
+ class ServerInfo(BaseModel):
34
+ """Information about the Prometheus server configuration.
35
+
36
+ Attributes:
37
+ prometheus_url: URL of the AWS Managed Prometheus endpoint.
38
+ aws_region: AWS region where the Prometheus service is located.
39
+ aws_profile: AWS profile name used for authentication.
40
+ service_name: AWS service name for SigV4 authentication.
41
+ """
42
+
43
+ prometheus_url: Optional[str] = Field(
44
+ None, description='URL of the AWS Managed Prometheus endpoint'
45
+ )
46
+ aws_region: str = Field(description='AWS region where the Prometheus service is located')
47
+ aws_profile: Optional[str] = Field(
48
+ None, description='AWS profile name used for authentication'
49
+ )
50
+ service_name: str = Field(description='AWS service name for SigV4 authentication')