awslabs.prometheus-mcp-server 0.1.1__tar.gz → 0.2.2__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.
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/.gitignore +11 -0
- awslabs_prometheus_mcp_server-0.2.2/CHANGELOG.md +22 -0
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/Dockerfile +32 -22
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/PKG-INFO +58 -16
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/README.md +56 -14
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/awslabs/prometheus_mcp_server/__init__.py +1 -1
- awslabs_prometheus_mcp_server-0.2.2/awslabs/prometheus_mcp_server/models.py +50 -0
- awslabs_prometheus_mcp_server-0.2.2/awslabs/prometheus_mcp_server/server.py +1106 -0
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/docker-healthcheck.sh +7 -7
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/pyproject.toml +2 -2
- awslabs_prometheus_mcp_server-0.2.2/tests/conftest.py +29 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_aws_credentials.py +116 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_config_manager.py +112 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_consts.py +78 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_coverage_gaps.py +128 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_coverage_improvement.py +240 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_final_coverage.py +35 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_main.py +242 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_models.py +76 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_prometheus_client.py +117 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_prometheus_connection.py +143 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_security_validator.py +91 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_server_coverage.py +222 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_tools.py +635 -0
- awslabs_prometheus_mcp_server-0.2.2/tests/test_workspace_config.py +399 -0
- awslabs_prometheus_mcp_server-0.2.2/uv-requirements.txt +26 -0
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/uv.lock +663 -463
- awslabs_prometheus_mcp_server-0.1.1/CHANGELOG.md +0 -12
- awslabs_prometheus_mcp_server-0.1.1/awslabs/prometheus_mcp_server/models.py +0 -108
- awslabs_prometheus_mcp_server-0.1.1/awslabs/prometheus_mcp_server/server.py +0 -668
- awslabs_prometheus_mcp_server-0.1.1/tests/test_config.py +0 -366
- awslabs_prometheus_mcp_server-0.1.1/tests/test_edge_cases.py +0 -125
- awslabs_prometheus_mcp_server-0.1.1/tests/test_error_handling.py +0 -139
- awslabs_prometheus_mcp_server-0.1.1/tests/test_main.py +0 -137
- awslabs_prometheus_mcp_server-0.1.1/tests/test_make_prometheus_request.py +0 -263
- awslabs_prometheus_mcp_server-0.1.1/tests/test_models.py +0 -179
- awslabs_prometheus_mcp_server-0.1.1/tests/test_prometheus_connection.py +0 -150
- awslabs_prometheus_mcp_server-0.1.1/tests/test_remaining_coverage.py +0 -127
- awslabs_prometheus_mcp_server-0.1.1/tests/test_server.py +0 -128
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/.python-version +0 -0
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/LICENSE +0 -0
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/NOTICE +0 -0
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/awslabs/__init__.py +0 -0
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/awslabs/prometheus_mcp_server/consts.py +0 -0
- {awslabs_prometheus_mcp_server-0.1.1 → awslabs_prometheus_mcp_server-0.2.2}/tests/test_init.py +0 -0
|
@@ -244,6 +244,10 @@ pyrightconfig.json
|
|
|
244
244
|
.history
|
|
245
245
|
.ionide
|
|
246
246
|
|
|
247
|
+
### Kiro
|
|
248
|
+
# Ignore Kiro config files
|
|
249
|
+
.kiro/
|
|
250
|
+
|
|
247
251
|
### Windows ###
|
|
248
252
|
# Windows thumbnail cache files
|
|
249
253
|
Thumbs.db
|
|
@@ -563,3 +567,10 @@ samples/mcp-integration-with-nova-canvas/output/*
|
|
|
563
567
|
|
|
564
568
|
memory-bank/*
|
|
565
569
|
.clinerules
|
|
570
|
+
|
|
571
|
+
# OpenAPI MCP Server specific ignores
|
|
572
|
+
src/openapi-mcp-server/generated-diagrams/*
|
|
573
|
+
src/openapi-mcp-server/*.txt
|
|
574
|
+
src/openapi-mcp-server/*-coverage.xml
|
|
575
|
+
src/openapi-mcp-server/junit.xml
|
|
576
|
+
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/
|
|
16
|
+
FROM public.ecr.aws/docker/library/python:3.13.5-alpine3.21@sha256:c9a09c45a4bcc618c7f7128585b8dd0d41d0c31a8a107db4c8255ffe0b69375d AS uv
|
|
17
17
|
|
|
18
18
|
# Install the project into `/app`
|
|
19
19
|
WORKDIR /app
|
|
@@ -31,40 +31,50 @@ 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
|
+
|
|
36
|
+
# Python optimization and uv configuration
|
|
37
|
+
ENV PIP_NO_CACHE_DIR=1 \
|
|
38
|
+
PIP_DISABLE_PIP_VERSION_CHECK=1
|
|
39
|
+
|
|
40
|
+
# Install system dependencies and Python package manager
|
|
41
|
+
RUN apk update && \
|
|
42
|
+
apk add --no-cache --virtual .build-deps \
|
|
43
|
+
build-base \
|
|
44
|
+
gcc \
|
|
45
|
+
musl-dev \
|
|
46
|
+
libffi-dev \
|
|
47
|
+
openssl-dev \
|
|
48
|
+
cargo
|
|
35
49
|
|
|
36
50
|
# Install the project's dependencies using the lockfile and settings
|
|
37
51
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
38
|
-
pip install uv && \
|
|
39
|
-
uv sync --frozen --no-install-project --no-dev --no-editable
|
|
52
|
+
pip install --require-hashes --requirement uv-requirements.txt --no-cache-dir && \
|
|
53
|
+
uv sync --python 3.13 --frozen --no-install-project --no-dev --no-editable
|
|
40
54
|
|
|
41
55
|
# Then, add the rest of the project source code and install it
|
|
42
56
|
# Installing separately from its dependencies allows optimal layer caching
|
|
43
57
|
COPY . /app
|
|
44
58
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
45
|
-
uv sync --frozen --no-dev --no-editable
|
|
59
|
+
uv sync --python 3.13 --frozen --no-dev --no-editable
|
|
46
60
|
|
|
47
61
|
# Make the directory just in case it doesn't exist
|
|
48
62
|
RUN mkdir -p /root/.local
|
|
49
63
|
|
|
50
|
-
FROM public.ecr.aws/
|
|
64
|
+
FROM public.ecr.aws/docker/library/python:3.13.5-alpine3.21@sha256:c9a09c45a4bcc618c7f7128585b8dd0d41d0c31a8a107db4c8255ffe0b69375d
|
|
51
65
|
|
|
52
66
|
# Place executables in the environment at the front of the path and include other binaries
|
|
53
|
-
ENV PATH="/app/.venv/bin:$PATH
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
# Install
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
chmod o+x /root
|
|
65
|
-
|
|
66
|
-
# Get the project from the uv layer
|
|
67
|
-
COPY --from=uv --chown=app:app /root/.local /root/.local
|
|
67
|
+
ENV PATH="/app/.venv/bin:$PATH" \
|
|
68
|
+
PYTHONUNBUFFERED=1
|
|
69
|
+
|
|
70
|
+
# Install runtime dependencies and create application user
|
|
71
|
+
RUN apk update && \
|
|
72
|
+
apk add --no-cache ca-certificates && \
|
|
73
|
+
update-ca-certificates && \
|
|
74
|
+
addgroup -S app && \
|
|
75
|
+
adduser -S app -G app -h /app
|
|
76
|
+
|
|
77
|
+
# Copy application artifacts from build stage
|
|
68
78
|
COPY --from=uv --chown=app:app /app/.venv /app/.venv
|
|
69
79
|
|
|
70
80
|
# Get healthcheck script
|
|
@@ -74,5 +84,5 @@ COPY ./docker-healthcheck.sh /usr/local/bin/docker-healthcheck.sh
|
|
|
74
84
|
USER app
|
|
75
85
|
|
|
76
86
|
# When running the container, add --db-path and a bind mount to the host's db file
|
|
77
|
-
HEALTHCHECK --interval=
|
|
87
|
+
HEALTHCHECK --interval=60s --timeout=10s --start-period=10s --retries=3 CMD ["docker-healthcheck.sh"]
|
|
78
88
|
ENTRYPOINT ["awslabs.prometheus-mcp-server"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: awslabs.prometheus-mcp-server
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.2
|
|
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/
|
|
@@ -24,7 +24,7 @@ Requires-Python: >=3.10
|
|
|
24
24
|
Requires-Dist: boto3>=1.38.7
|
|
25
25
|
Requires-Dist: httpx>=0.28.1
|
|
26
26
|
Requires-Dist: loguru>=0.7.0
|
|
27
|
-
Requires-Dist: mcp[cli]>=1.
|
|
27
|
+
Requires-Dist: mcp[cli]>=1.11.0
|
|
28
28
|
Requires-Dist: pydantic>=2.0.0
|
|
29
29
|
Requires-Dist: python-dotenv>=1.0.0
|
|
30
30
|
Requires-Dist: requests>=2.32.3
|
|
@@ -47,6 +47,10 @@ This MCP server is designed to be fully compatible with Amazon Q developer CLI,
|
|
|
47
47
|
|
|
48
48
|
## Installation
|
|
49
49
|
|
|
50
|
+
| Cursor | VS Code |
|
|
51
|
+
|:------:|:-------:|
|
|
52
|
+
| [](https://cursor.com/install-mcp?name=awslabs.prometheus-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGF3c2xhYnMucHJvbWV0aGV1cy1tY3Atc2VydmVyQGxhdGVzdCAtLXVybCBodHRwczovL2Fwcy13b3Jrc3BhY2VzLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tL3dvcmtzcGFjZXMvd3MtPFdvcmtzcGFjZSBJRD4gLS1yZWdpb24gPFlvdXIgQVdTIFJlZ2lvbj4gLS1wcm9maWxlIDxZb3VyIENMSSBQcm9maWxlIFtkZWZhdWx0XSBpZiBubyBwcm9maWxlIGlzIHVzZWQ%2BIiwiZW52Ijp7IkZBU1RNQ1BfTE9HX0xFVkVMIjoiREVCVUciLCJBV1NfUFJPRklMRSI6IjxZb3VyIENMSSBQcm9maWxlIFtkZWZhdWx0XSBpZiBubyBwcm9maWxlIGlzIHVzZWQ%2BIn19) | [](https://insiders.vscode.dev/redirect/mcp/install?name=Prometheus%20MCP%20Server&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22awslabs.prometheus-mcp-server%40latest%22%2C%22--url%22%2C%22https%3A%2F%2Faps-workspaces.us-east-1.amazonaws.com%2Fworkspaces%2Fws-%3CWorkspace%20ID%3E%22%2C%22--region%22%2C%22%3CYour%20AWS%20Region%3E%22%2C%22--profile%22%2C%22%3CYour%20CLI%20Profile%20%5Bdefault%5D%20if%20no%20profile%20is%20used%3E%22%5D%2C%22env%22%3A%7B%22FASTMCP_LOG_LEVEL%22%3A%22DEBUG%22%2C%22AWS_PROFILE%22%3A%22%3CYour%20CLI%20Profile%20%5Bdefault%5D%20if%20no%20profile%20is%20used%3E%22%7D%7D) |
|
|
53
|
+
|
|
50
54
|
### Prerequisites
|
|
51
55
|
|
|
52
56
|
- Python 3.10 or higher
|
|
@@ -69,23 +73,41 @@ mkdir -p ~/.aws/amazonq/
|
|
|
69
73
|
```
|
|
70
74
|
|
|
71
75
|
2. Add the following to `~/.aws/amazonq/mcp.json`:
|
|
76
|
+
|
|
77
|
+
### Basic Configuration
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"prometheus": {
|
|
82
|
+
"command": "uvx",
|
|
83
|
+
"args": [
|
|
84
|
+
"awslabs.prometheus-mcp-server@latest"
|
|
85
|
+
],
|
|
86
|
+
"env": {
|
|
87
|
+
"FASTMCP_LOG_LEVEL": "DEBUG"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Configuration with Optional Arguments
|
|
72
95
|
```json
|
|
73
96
|
{
|
|
74
97
|
"mcpServers": {
|
|
75
|
-
"
|
|
98
|
+
"prometheus": {
|
|
76
99
|
"command": "uvx",
|
|
77
100
|
"args": [
|
|
78
101
|
"awslabs.prometheus-mcp-server@latest",
|
|
79
102
|
"--url",
|
|
80
|
-
"https://aps-workspaces
|
|
103
|
+
"https://aps-workspaces.<AWS Region>.amazonaws.com/workspaces/ws-<Workspace ID>",
|
|
81
104
|
"--region",
|
|
82
105
|
"<Your AWS Region>",
|
|
83
106
|
"--profile",
|
|
84
|
-
"<Your CLI Profile
|
|
107
|
+
"<Your CLI Profile>"
|
|
85
108
|
],
|
|
86
109
|
"env": {
|
|
87
|
-
"FASTMCP_LOG_LEVEL": "DEBUG"
|
|
88
|
-
"AWS_PROFILE": "<Your CLI Profile [default] if no profile is used>"
|
|
110
|
+
"FASTMCP_LOG_LEVEL": "DEBUG"
|
|
89
111
|
}
|
|
90
112
|
}
|
|
91
113
|
}
|
|
@@ -96,30 +118,46 @@ mkdir -p ~/.aws/amazonq/
|
|
|
96
118
|
|
|
97
119
|
## Available Tools
|
|
98
120
|
|
|
99
|
-
1. **
|
|
121
|
+
1. **GetAvailableWorkspaces**
|
|
122
|
+
- List all available Prometheus workspaces in the specified region
|
|
123
|
+
- Parameters: region (optional)
|
|
124
|
+
- Returns: List of workspaces with IDs, aliases, and status
|
|
125
|
+
|
|
126
|
+
2. **ExecuteQuery**
|
|
100
127
|
- Execute instant PromQL queries against Prometheus
|
|
101
|
-
- Parameters: query (required), time (optional)
|
|
128
|
+
- Parameters: workspace_id (required), query (required), time (optional), region (optional)
|
|
102
129
|
|
|
103
|
-
|
|
130
|
+
3. **ExecuteRangeQuery**
|
|
104
131
|
- Execute PromQL queries over a time range
|
|
105
|
-
- Parameters: query, start time, end time, step interval
|
|
132
|
+
- Parameters: workspace_id (required), query, start time, end time, step interval, region (optional)
|
|
106
133
|
|
|
107
|
-
|
|
134
|
+
4. **ListMetrics**
|
|
108
135
|
- Retrieve all available metric names from Prometheus
|
|
136
|
+
- Parameters: workspace_id (required), region (optional)
|
|
109
137
|
- Returns: Sorted list of metric names
|
|
110
138
|
|
|
111
|
-
|
|
139
|
+
5. **GetServerInfo**
|
|
112
140
|
- Retrieve server configuration details
|
|
141
|
+
- Parameters: workspace_id (required), region (optional)
|
|
113
142
|
- Returns: URL, region, profile, and service information
|
|
114
143
|
|
|
115
144
|
## Example Queries
|
|
116
145
|
|
|
117
146
|
```python
|
|
147
|
+
# Get available workspaces
|
|
148
|
+
workspaces = await get_available_workspaces()
|
|
149
|
+
for ws in workspaces['workspaces']:
|
|
150
|
+
print(f"ID: {ws['workspace_id']}, Alias: {ws['alias']}, Status: {ws['status']}")
|
|
151
|
+
|
|
118
152
|
# Execute an instant query
|
|
119
|
-
result = await execute_query(
|
|
153
|
+
result = await execute_query(
|
|
154
|
+
workspace_id="ws-12345678-abcd-1234-efgh-123456789012",
|
|
155
|
+
query="up"
|
|
156
|
+
)
|
|
120
157
|
|
|
121
158
|
# Execute a range query
|
|
122
159
|
data = await execute_range_query(
|
|
160
|
+
workspace_id="ws-12345678-abcd-1234-efgh-123456789012",
|
|
123
161
|
query="rate(node_cpu_seconds_total[5m])",
|
|
124
162
|
start="2023-01-01T00:00:00Z",
|
|
125
163
|
end="2023-01-01T01:00:00Z",
|
|
@@ -127,10 +165,14 @@ data = await execute_range_query(
|
|
|
127
165
|
)
|
|
128
166
|
|
|
129
167
|
# List available metrics
|
|
130
|
-
metrics = await list_metrics(
|
|
168
|
+
metrics = await list_metrics(
|
|
169
|
+
workspace_id="ws-12345678-abcd-1234-efgh-123456789012"
|
|
170
|
+
)
|
|
131
171
|
|
|
132
172
|
# Get server information
|
|
133
|
-
info = await get_server_info(
|
|
173
|
+
info = await get_server_info(
|
|
174
|
+
workspace_id="ws-12345678-abcd-1234-efgh-123456789012"
|
|
175
|
+
)
|
|
134
176
|
```
|
|
135
177
|
|
|
136
178
|
## Troubleshooting
|
|
@@ -15,6 +15,10 @@ This MCP server is designed to be fully compatible with Amazon Q developer CLI,
|
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
|
+
| Cursor | VS Code |
|
|
19
|
+
|:------:|:-------:|
|
|
20
|
+
| [](https://cursor.com/install-mcp?name=awslabs.prometheus-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGF3c2xhYnMucHJvbWV0aGV1cy1tY3Atc2VydmVyQGxhdGVzdCAtLXVybCBodHRwczovL2Fwcy13b3Jrc3BhY2VzLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tL3dvcmtzcGFjZXMvd3MtPFdvcmtzcGFjZSBJRD4gLS1yZWdpb24gPFlvdXIgQVdTIFJlZ2lvbj4gLS1wcm9maWxlIDxZb3VyIENMSSBQcm9maWxlIFtkZWZhdWx0XSBpZiBubyBwcm9maWxlIGlzIHVzZWQ%2BIiwiZW52Ijp7IkZBU1RNQ1BfTE9HX0xFVkVMIjoiREVCVUciLCJBV1NfUFJPRklMRSI6IjxZb3VyIENMSSBQcm9maWxlIFtkZWZhdWx0XSBpZiBubyBwcm9maWxlIGlzIHVzZWQ%2BIn19) | [](https://insiders.vscode.dev/redirect/mcp/install?name=Prometheus%20MCP%20Server&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22awslabs.prometheus-mcp-server%40latest%22%2C%22--url%22%2C%22https%3A%2F%2Faps-workspaces.us-east-1.amazonaws.com%2Fworkspaces%2Fws-%3CWorkspace%20ID%3E%22%2C%22--region%22%2C%22%3CYour%20AWS%20Region%3E%22%2C%22--profile%22%2C%22%3CYour%20CLI%20Profile%20%5Bdefault%5D%20if%20no%20profile%20is%20used%3E%22%5D%2C%22env%22%3A%7B%22FASTMCP_LOG_LEVEL%22%3A%22DEBUG%22%2C%22AWS_PROFILE%22%3A%22%3CYour%20CLI%20Profile%20%5Bdefault%5D%20if%20no%20profile%20is%20used%3E%22%7D%7D) |
|
|
21
|
+
|
|
18
22
|
### Prerequisites
|
|
19
23
|
|
|
20
24
|
- Python 3.10 or higher
|
|
@@ -37,23 +41,41 @@ mkdir -p ~/.aws/amazonq/
|
|
|
37
41
|
```
|
|
38
42
|
|
|
39
43
|
2. Add the following to `~/.aws/amazonq/mcp.json`:
|
|
44
|
+
|
|
45
|
+
### Basic Configuration
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"mcpServers": {
|
|
49
|
+
"prometheus": {
|
|
50
|
+
"command": "uvx",
|
|
51
|
+
"args": [
|
|
52
|
+
"awslabs.prometheus-mcp-server@latest"
|
|
53
|
+
],
|
|
54
|
+
"env": {
|
|
55
|
+
"FASTMCP_LOG_LEVEL": "DEBUG"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Configuration with Optional Arguments
|
|
40
63
|
```json
|
|
41
64
|
{
|
|
42
65
|
"mcpServers": {
|
|
43
|
-
"
|
|
66
|
+
"prometheus": {
|
|
44
67
|
"command": "uvx",
|
|
45
68
|
"args": [
|
|
46
69
|
"awslabs.prometheus-mcp-server@latest",
|
|
47
70
|
"--url",
|
|
48
|
-
"https://aps-workspaces
|
|
71
|
+
"https://aps-workspaces.<AWS Region>.amazonaws.com/workspaces/ws-<Workspace ID>",
|
|
49
72
|
"--region",
|
|
50
73
|
"<Your AWS Region>",
|
|
51
74
|
"--profile",
|
|
52
|
-
"<Your CLI Profile
|
|
75
|
+
"<Your CLI Profile>"
|
|
53
76
|
],
|
|
54
77
|
"env": {
|
|
55
|
-
"FASTMCP_LOG_LEVEL": "DEBUG"
|
|
56
|
-
"AWS_PROFILE": "<Your CLI Profile [default] if no profile is used>"
|
|
78
|
+
"FASTMCP_LOG_LEVEL": "DEBUG"
|
|
57
79
|
}
|
|
58
80
|
}
|
|
59
81
|
}
|
|
@@ -64,30 +86,46 @@ mkdir -p ~/.aws/amazonq/
|
|
|
64
86
|
|
|
65
87
|
## Available Tools
|
|
66
88
|
|
|
67
|
-
1. **
|
|
89
|
+
1. **GetAvailableWorkspaces**
|
|
90
|
+
- List all available Prometheus workspaces in the specified region
|
|
91
|
+
- Parameters: region (optional)
|
|
92
|
+
- Returns: List of workspaces with IDs, aliases, and status
|
|
93
|
+
|
|
94
|
+
2. **ExecuteQuery**
|
|
68
95
|
- Execute instant PromQL queries against Prometheus
|
|
69
|
-
- Parameters: query (required), time (optional)
|
|
96
|
+
- Parameters: workspace_id (required), query (required), time (optional), region (optional)
|
|
70
97
|
|
|
71
|
-
|
|
98
|
+
3. **ExecuteRangeQuery**
|
|
72
99
|
- Execute PromQL queries over a time range
|
|
73
|
-
- Parameters: query, start time, end time, step interval
|
|
100
|
+
- Parameters: workspace_id (required), query, start time, end time, step interval, region (optional)
|
|
74
101
|
|
|
75
|
-
|
|
102
|
+
4. **ListMetrics**
|
|
76
103
|
- Retrieve all available metric names from Prometheus
|
|
104
|
+
- Parameters: workspace_id (required), region (optional)
|
|
77
105
|
- Returns: Sorted list of metric names
|
|
78
106
|
|
|
79
|
-
|
|
107
|
+
5. **GetServerInfo**
|
|
80
108
|
- Retrieve server configuration details
|
|
109
|
+
- Parameters: workspace_id (required), region (optional)
|
|
81
110
|
- Returns: URL, region, profile, and service information
|
|
82
111
|
|
|
83
112
|
## Example Queries
|
|
84
113
|
|
|
85
114
|
```python
|
|
115
|
+
# Get available workspaces
|
|
116
|
+
workspaces = await get_available_workspaces()
|
|
117
|
+
for ws in workspaces['workspaces']:
|
|
118
|
+
print(f"ID: {ws['workspace_id']}, Alias: {ws['alias']}, Status: {ws['status']}")
|
|
119
|
+
|
|
86
120
|
# Execute an instant query
|
|
87
|
-
result = await execute_query(
|
|
121
|
+
result = await execute_query(
|
|
122
|
+
workspace_id="ws-12345678-abcd-1234-efgh-123456789012",
|
|
123
|
+
query="up"
|
|
124
|
+
)
|
|
88
125
|
|
|
89
126
|
# Execute a range query
|
|
90
127
|
data = await execute_range_query(
|
|
128
|
+
workspace_id="ws-12345678-abcd-1234-efgh-123456789012",
|
|
91
129
|
query="rate(node_cpu_seconds_total[5m])",
|
|
92
130
|
start="2023-01-01T00:00:00Z",
|
|
93
131
|
end="2023-01-01T01:00:00Z",
|
|
@@ -95,10 +133,14 @@ data = await execute_range_query(
|
|
|
95
133
|
)
|
|
96
134
|
|
|
97
135
|
# List available metrics
|
|
98
|
-
metrics = await list_metrics(
|
|
136
|
+
metrics = await list_metrics(
|
|
137
|
+
workspace_id="ws-12345678-abcd-1234-efgh-123456789012"
|
|
138
|
+
)
|
|
99
139
|
|
|
100
140
|
# Get server information
|
|
101
|
-
info = await get_server_info(
|
|
141
|
+
info = await get_server_info(
|
|
142
|
+
workspace_id="ws-12345678-abcd-1234-efgh-123456789012"
|
|
143
|
+
)
|
|
102
144
|
```
|
|
103
145
|
|
|
104
146
|
## Troubleshooting
|
|
@@ -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')
|