awslabs.cloudwatch-appsignals-mcp-server 0.1.3__tar.gz → 0.1.5__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_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/PKG-INFO +23 -18
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/README.md +22 -17
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/awslabs/cloudwatch_appsignals_mcp_server/__init__.py +1 -1
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/awslabs/cloudwatch_appsignals_mcp_server/server.py +25 -6
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/pyproject.toml +1 -1
- awslabs_cloudwatch_appsignals_mcp_server-0.1.5/tests/conftest.py +11 -0
- awslabs_cloudwatch_appsignals_mcp_server-0.1.5/tests/test_aws_profile.py +145 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/.gitignore +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/.python-version +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/CHANGELOG.md +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/Dockerfile +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/LICENSE +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/NOTICE +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/awslabs/__init__.py +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/awslabs/cloudwatch_appsignals_mcp_server/sli_report_client.py +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/docker-healthcheck.sh +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/tests/test_initialization.py +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/tests/test_server.py +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/tests/test_sli_report_client.py +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/uv-requirements.txt +0 -0
- {awslabs_cloudwatch_appsignals_mcp_server-0.1.3 → awslabs_cloudwatch_appsignals_mcp_server-0.1.5}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: awslabs.cloudwatch-appsignals-mcp-server
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: An AWS Labs Model Context Protocol (MCP) server for AWS Application Signals
|
|
5
5
|
Project-URL: Homepage, https://awslabs.github.io/mcp/
|
|
6
6
|
Project-URL: Documentation, https://awslabs.github.io/mcp/servers/cloudwatch-appsignals-mcp-server/
|
|
@@ -82,7 +82,7 @@ This server enables AI assistants like Claude, GitHub Copilot, and Amazon Q to h
|
|
|
82
82
|
|
|
83
83
|
| Cursor | VS Code |
|
|
84
84
|
|:------:|:-------:|
|
|
85
|
-
| [](https://cursor.com/install-mcp?name=awslabs.cloudwatch-appsignals-mcp-server&config=eyJhdXRvQXBwcm92ZSI6W10sImRpc2FibGVkIjpmYWxzZSwidGltZW91dCI6NjAsImNvbW1hbmQiOiJ1dnggYXdzbGFicy5jbG91ZHdhdGNoLWFwcHNpZ25hbHMtbWNwLXNlcnZlckBsYXRlc3QiLCJlbnYiOnsiQVdTX1BST0ZJTEUiOiJbVGhlIEFXUyBQcm9maWxlIE5hbWUgdG8gdXNlIGZvciBBV1MgYWNjZXNzXSIsIkFXU19SRUdJT04iOiJbVGhlIEFXUyByZWdpb24gdG8gcnVuIGluXSIsIkZBU1RNQ1BfTE9HX0xFVkVMIjoiRVJST1IifSwidHJhbnNwb3J0VHlwZSI6InN0ZGlvIn0%3D) | [](https://insiders.vscode.dev/redirect/mcp/install?name=CloudWatch%20Application%20Signals%20MCP%20Server&config=%7B%22autoApprove%22%3A%5B%5D%2C%22disabled%22%3Afalse%2C%22timeout%22%3A60%2C%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22awslabs.cloudwatch-appsignals-mcp-server%40latest%22%5D%2C%22env%22%3A%7B%22AWS_PROFILE%22%3A%22%5BThe%20AWS%20Profile%20Name%20to%20use%20for%20AWS%20access%5D%22%2C%22AWS_REGION%22%3A%22%5BThe%20AWS%20region%20to%20run%20in%5D%22%2C%22FASTMCP_LOG_LEVEL%22%3A%22ERROR%22%7D%2C%22transportType%22%3A%22stdio%22%7D) |
|
|
85
|
+
| [](https://cursor.com/en/install-mcp?name=awslabs.cloudwatch-appsignals-mcp-server&config=eyJhdXRvQXBwcm92ZSI6W10sImRpc2FibGVkIjpmYWxzZSwidGltZW91dCI6NjAsImNvbW1hbmQiOiJ1dnggYXdzbGFicy5jbG91ZHdhdGNoLWFwcHNpZ25hbHMtbWNwLXNlcnZlckBsYXRlc3QiLCJlbnYiOnsiQVdTX1BST0ZJTEUiOiJbVGhlIEFXUyBQcm9maWxlIE5hbWUgdG8gdXNlIGZvciBBV1MgYWNjZXNzXSIsIkFXU19SRUdJT04iOiJbVGhlIEFXUyByZWdpb24gdG8gcnVuIGluXSIsIkZBU1RNQ1BfTE9HX0xFVkVMIjoiRVJST1IifSwidHJhbnNwb3J0VHlwZSI6InN0ZGlvIn0%3D) | [](https://insiders.vscode.dev/redirect/mcp/install?name=CloudWatch%20Application%20Signals%20MCP%20Server&config=%7B%22autoApprove%22%3A%5B%5D%2C%22disabled%22%3Afalse%2C%22timeout%22%3A60%2C%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22awslabs.cloudwatch-appsignals-mcp-server%40latest%22%5D%2C%22env%22%3A%7B%22AWS_PROFILE%22%3A%22%5BThe%20AWS%20Profile%20Name%20to%20use%20for%20AWS%20access%5D%22%2C%22AWS_REGION%22%3A%22%5BThe%20AWS%20region%20to%20run%20in%5D%22%2C%22FASTMCP_LOG_LEVEL%22%3A%22ERROR%22%7D%2C%22transportType%22%3A%22stdio%22%7D) |
|
|
86
86
|
|
|
87
87
|
### Installing via `uv`
|
|
88
88
|
|
|
@@ -96,17 +96,15 @@ use [`uvx`](https://docs.astral.sh/uv/guides/tools/) to directly run *awslabs.cl
|
|
|
96
96
|
```json
|
|
97
97
|
{
|
|
98
98
|
"mcpServers": {
|
|
99
|
-
"awslabs.cloudwatch-appsignals-mcp
|
|
99
|
+
"awslabs.cloudwatch-appsignals-mcp": {
|
|
100
100
|
"autoApprove": [],
|
|
101
101
|
"disabled": false,
|
|
102
|
-
"timeout": 60,
|
|
103
102
|
"command": "uvx",
|
|
104
103
|
"args": [
|
|
105
104
|
"awslabs.cloudwatch-appsignals-mcp-server@latest"
|
|
106
105
|
],
|
|
107
106
|
"env": {
|
|
108
|
-
"
|
|
109
|
-
"AWS_SECRET_ACCESS_KEY": "[AWS Access Key]",
|
|
107
|
+
"AWS_PROFILE": "[The AWS Profile Name to use for AWS access]",
|
|
110
108
|
"AWS_REGION": "[AWS Region]",
|
|
111
109
|
"FASTMCP_LOG_LEVEL": "ERROR"
|
|
112
110
|
},
|
|
@@ -130,7 +128,11 @@ On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
|
130
128
|
"mcpServers": {
|
|
131
129
|
"awslabs.cloudwatch-appsignals-mcp-server": {
|
|
132
130
|
"command": "uvx",
|
|
133
|
-
"args": ["--from", "/absolute/path/to/cloudwatch-appsignals-mcp-server", "awslabs.cloudwatch-appsignals-mcp-server"]
|
|
131
|
+
"args": ["--from", "/absolute/path/to/cloudwatch-appsignals-mcp-server", "awslabs.cloudwatch-appsignals-mcp-server"],
|
|
132
|
+
"env": {
|
|
133
|
+
"AWS_PROFILE": "[The AWS Profile Name to use for AWS access]",
|
|
134
|
+
"AWS_REGION": "[AWS Region]"
|
|
135
|
+
}
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
}
|
|
@@ -145,7 +147,11 @@ On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
|
145
147
|
"mcpServers": {
|
|
146
148
|
"awslabs.cloudwatch-appsignals-mcp-server": {
|
|
147
149
|
"command": "uvx",
|
|
148
|
-
"args": ["awslabs.cloudwatch-appsignals-mcp-server@latest"]
|
|
150
|
+
"args": ["awslabs.cloudwatch-appsignals-mcp-server@latest"],
|
|
151
|
+
"env": {
|
|
152
|
+
"AWS_PROFILE": "[The AWS Profile Name to use for AWS access]",
|
|
153
|
+
"AWS_REGION": "[AWS Region]"
|
|
154
|
+
}
|
|
149
155
|
}
|
|
150
156
|
}
|
|
151
157
|
}
|
|
@@ -168,9 +174,9 @@ On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
|
168
174
|
"run",
|
|
169
175
|
"-i",
|
|
170
176
|
"--rm",
|
|
171
|
-
"-
|
|
172
|
-
"-e", "
|
|
173
|
-
"-e", "AWS_REGION=[
|
|
177
|
+
"-v", "${HOME}/.aws:/root/.aws:ro",
|
|
178
|
+
"-e", "AWS_PROFILE=[The AWS Profile Name to use for AWS access]",
|
|
179
|
+
"-e", "AWS_REGION=[AWS Region]",
|
|
174
180
|
"awslabs/cloudwatch-appsignals-mcp-server:latest"
|
|
175
181
|
]
|
|
176
182
|
}
|
|
@@ -293,19 +299,18 @@ The server requires the following AWS IAM permissions:
|
|
|
293
299
|
|
|
294
300
|
### Environment Variables
|
|
295
301
|
|
|
302
|
+
- `AWS_PROFILE` - AWS profile name to use for authentication (defaults to `default` profile)
|
|
296
303
|
- `AWS_REGION` - AWS region (defaults to us-east-1)
|
|
297
304
|
- `MCP_CLOUDWATCH_APPSIGNALS_LOG_LEVEL` - Logging level (defaults to INFO)
|
|
298
305
|
|
|
299
306
|
### AWS Credentials
|
|
300
307
|
|
|
301
|
-
This server uses
|
|
302
|
-
- Environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, etc.)
|
|
303
|
-
- AWS credentials file (`~/.aws/credentials`)
|
|
304
|
-
- AWS config file (`~/.aws/config`)
|
|
305
|
-
- IAM roles (when running on EC2, ECS, Lambda, etc.)
|
|
306
|
-
- And other standard AWS credential providers
|
|
308
|
+
This server uses AWS profiles for authentication. Set the `AWS_PROFILE` environment variable to use a specific profile from your `~/.aws/credentials` file.
|
|
307
309
|
|
|
308
|
-
|
|
310
|
+
The server will use the standard AWS credential chain via boto3, which includes:
|
|
311
|
+
- AWS Profile specified by `AWS_PROFILE` environment variable
|
|
312
|
+
- Default profile from AWS credentials file
|
|
313
|
+
- IAM roles when running on EC2, ECS, Lambda, etc.
|
|
309
314
|
|
|
310
315
|
## Development
|
|
311
316
|
|
|
@@ -52,7 +52,7 @@ This server enables AI assistants like Claude, GitHub Copilot, and Amazon Q to h
|
|
|
52
52
|
|
|
53
53
|
| Cursor | VS Code |
|
|
54
54
|
|:------:|:-------:|
|
|
55
|
-
| [](https://cursor.com/install-mcp?name=awslabs.cloudwatch-appsignals-mcp-server&config=eyJhdXRvQXBwcm92ZSI6W10sImRpc2FibGVkIjpmYWxzZSwidGltZW91dCI6NjAsImNvbW1hbmQiOiJ1dnggYXdzbGFicy5jbG91ZHdhdGNoLWFwcHNpZ25hbHMtbWNwLXNlcnZlckBsYXRlc3QiLCJlbnYiOnsiQVdTX1BST0ZJTEUiOiJbVGhlIEFXUyBQcm9maWxlIE5hbWUgdG8gdXNlIGZvciBBV1MgYWNjZXNzXSIsIkFXU19SRUdJT04iOiJbVGhlIEFXUyByZWdpb24gdG8gcnVuIGluXSIsIkZBU1RNQ1BfTE9HX0xFVkVMIjoiRVJST1IifSwidHJhbnNwb3J0VHlwZSI6InN0ZGlvIn0%3D) | [](https://insiders.vscode.dev/redirect/mcp/install?name=CloudWatch%20Application%20Signals%20MCP%20Server&config=%7B%22autoApprove%22%3A%5B%5D%2C%22disabled%22%3Afalse%2C%22timeout%22%3A60%2C%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22awslabs.cloudwatch-appsignals-mcp-server%40latest%22%5D%2C%22env%22%3A%7B%22AWS_PROFILE%22%3A%22%5BThe%20AWS%20Profile%20Name%20to%20use%20for%20AWS%20access%5D%22%2C%22AWS_REGION%22%3A%22%5BThe%20AWS%20region%20to%20run%20in%5D%22%2C%22FASTMCP_LOG_LEVEL%22%3A%22ERROR%22%7D%2C%22transportType%22%3A%22stdio%22%7D) |
|
|
55
|
+
| [](https://cursor.com/en/install-mcp?name=awslabs.cloudwatch-appsignals-mcp-server&config=eyJhdXRvQXBwcm92ZSI6W10sImRpc2FibGVkIjpmYWxzZSwidGltZW91dCI6NjAsImNvbW1hbmQiOiJ1dnggYXdzbGFicy5jbG91ZHdhdGNoLWFwcHNpZ25hbHMtbWNwLXNlcnZlckBsYXRlc3QiLCJlbnYiOnsiQVdTX1BST0ZJTEUiOiJbVGhlIEFXUyBQcm9maWxlIE5hbWUgdG8gdXNlIGZvciBBV1MgYWNjZXNzXSIsIkFXU19SRUdJT04iOiJbVGhlIEFXUyByZWdpb24gdG8gcnVuIGluXSIsIkZBU1RNQ1BfTE9HX0xFVkVMIjoiRVJST1IifSwidHJhbnNwb3J0VHlwZSI6InN0ZGlvIn0%3D) | [](https://insiders.vscode.dev/redirect/mcp/install?name=CloudWatch%20Application%20Signals%20MCP%20Server&config=%7B%22autoApprove%22%3A%5B%5D%2C%22disabled%22%3Afalse%2C%22timeout%22%3A60%2C%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22awslabs.cloudwatch-appsignals-mcp-server%40latest%22%5D%2C%22env%22%3A%7B%22AWS_PROFILE%22%3A%22%5BThe%20AWS%20Profile%20Name%20to%20use%20for%20AWS%20access%5D%22%2C%22AWS_REGION%22%3A%22%5BThe%20AWS%20region%20to%20run%20in%5D%22%2C%22FASTMCP_LOG_LEVEL%22%3A%22ERROR%22%7D%2C%22transportType%22%3A%22stdio%22%7D) |
|
|
56
56
|
|
|
57
57
|
### Installing via `uv`
|
|
58
58
|
|
|
@@ -66,17 +66,15 @@ use [`uvx`](https://docs.astral.sh/uv/guides/tools/) to directly run *awslabs.cl
|
|
|
66
66
|
```json
|
|
67
67
|
{
|
|
68
68
|
"mcpServers": {
|
|
69
|
-
"awslabs.cloudwatch-appsignals-mcp
|
|
69
|
+
"awslabs.cloudwatch-appsignals-mcp": {
|
|
70
70
|
"autoApprove": [],
|
|
71
71
|
"disabled": false,
|
|
72
|
-
"timeout": 60,
|
|
73
72
|
"command": "uvx",
|
|
74
73
|
"args": [
|
|
75
74
|
"awslabs.cloudwatch-appsignals-mcp-server@latest"
|
|
76
75
|
],
|
|
77
76
|
"env": {
|
|
78
|
-
"
|
|
79
|
-
"AWS_SECRET_ACCESS_KEY": "[AWS Access Key]",
|
|
77
|
+
"AWS_PROFILE": "[The AWS Profile Name to use for AWS access]",
|
|
80
78
|
"AWS_REGION": "[AWS Region]",
|
|
81
79
|
"FASTMCP_LOG_LEVEL": "ERROR"
|
|
82
80
|
},
|
|
@@ -100,7 +98,11 @@ On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
|
100
98
|
"mcpServers": {
|
|
101
99
|
"awslabs.cloudwatch-appsignals-mcp-server": {
|
|
102
100
|
"command": "uvx",
|
|
103
|
-
"args": ["--from", "/absolute/path/to/cloudwatch-appsignals-mcp-server", "awslabs.cloudwatch-appsignals-mcp-server"]
|
|
101
|
+
"args": ["--from", "/absolute/path/to/cloudwatch-appsignals-mcp-server", "awslabs.cloudwatch-appsignals-mcp-server"],
|
|
102
|
+
"env": {
|
|
103
|
+
"AWS_PROFILE": "[The AWS Profile Name to use for AWS access]",
|
|
104
|
+
"AWS_REGION": "[AWS Region]"
|
|
105
|
+
}
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
}
|
|
@@ -115,7 +117,11 @@ On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
|
115
117
|
"mcpServers": {
|
|
116
118
|
"awslabs.cloudwatch-appsignals-mcp-server": {
|
|
117
119
|
"command": "uvx",
|
|
118
|
-
"args": ["awslabs.cloudwatch-appsignals-mcp-server@latest"]
|
|
120
|
+
"args": ["awslabs.cloudwatch-appsignals-mcp-server@latest"],
|
|
121
|
+
"env": {
|
|
122
|
+
"AWS_PROFILE": "[The AWS Profile Name to use for AWS access]",
|
|
123
|
+
"AWS_REGION": "[AWS Region]"
|
|
124
|
+
}
|
|
119
125
|
}
|
|
120
126
|
}
|
|
121
127
|
}
|
|
@@ -138,9 +144,9 @@ On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
|
138
144
|
"run",
|
|
139
145
|
"-i",
|
|
140
146
|
"--rm",
|
|
141
|
-
"-
|
|
142
|
-
"-e", "
|
|
143
|
-
"-e", "AWS_REGION=[
|
|
147
|
+
"-v", "${HOME}/.aws:/root/.aws:ro",
|
|
148
|
+
"-e", "AWS_PROFILE=[The AWS Profile Name to use for AWS access]",
|
|
149
|
+
"-e", "AWS_REGION=[AWS Region]",
|
|
144
150
|
"awslabs/cloudwatch-appsignals-mcp-server:latest"
|
|
145
151
|
]
|
|
146
152
|
}
|
|
@@ -263,19 +269,18 @@ The server requires the following AWS IAM permissions:
|
|
|
263
269
|
|
|
264
270
|
### Environment Variables
|
|
265
271
|
|
|
272
|
+
- `AWS_PROFILE` - AWS profile name to use for authentication (defaults to `default` profile)
|
|
266
273
|
- `AWS_REGION` - AWS region (defaults to us-east-1)
|
|
267
274
|
- `MCP_CLOUDWATCH_APPSIGNALS_LOG_LEVEL` - Logging level (defaults to INFO)
|
|
268
275
|
|
|
269
276
|
### AWS Credentials
|
|
270
277
|
|
|
271
|
-
This server uses
|
|
272
|
-
- Environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, etc.)
|
|
273
|
-
- AWS credentials file (`~/.aws/credentials`)
|
|
274
|
-
- AWS config file (`~/.aws/config`)
|
|
275
|
-
- IAM roles (when running on EC2, ECS, Lambda, etc.)
|
|
276
|
-
- And other standard AWS credential providers
|
|
278
|
+
This server uses AWS profiles for authentication. Set the `AWS_PROFILE` environment variable to use a specific profile from your `~/.aws/credentials` file.
|
|
277
279
|
|
|
278
|
-
|
|
280
|
+
The server will use the standard AWS credential chain via boto3, which includes:
|
|
281
|
+
- AWS Profile specified by `AWS_PROFILE` environment variable
|
|
282
|
+
- Default profile from AWS credentials file
|
|
283
|
+
- IAM roles when running on EC2, ECS, Lambda, etc.
|
|
279
284
|
|
|
280
285
|
## Development
|
|
281
286
|
|
|
@@ -44,14 +44,33 @@ logger.debug(f'CloudWatch AppSignals MCP Server initialized with log level: {log
|
|
|
44
44
|
AWS_REGION = os.environ.get('AWS_REGION', 'us-east-1')
|
|
45
45
|
logger.debug(f'Using AWS region: {AWS_REGION}')
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
|
|
48
|
+
# Initialize AWS clients
|
|
49
|
+
def _initialize_aws_clients():
|
|
50
|
+
"""Initialize AWS clients with proper configuration."""
|
|
49
51
|
config = Config(user_agent_extra=f'awslabs.cloudwatch-appsignals-mcp-server/{__version__}')
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
|
|
53
|
+
# Check for AWS_PROFILE environment variable
|
|
54
|
+
if aws_profile := os.environ.get('AWS_PROFILE'):
|
|
55
|
+
logger.debug(f'Using AWS profile: {aws_profile}')
|
|
56
|
+
session = boto3.Session(profile_name=aws_profile, region_name=AWS_REGION)
|
|
57
|
+
logs = session.client('logs', config=config)
|
|
58
|
+
appsignals = session.client('application-signals', config=config)
|
|
59
|
+
cloudwatch = session.client('cloudwatch', config=config)
|
|
60
|
+
xray = session.client('xray', config=config)
|
|
61
|
+
else:
|
|
62
|
+
logs = boto3.client('logs', region_name=AWS_REGION, config=config)
|
|
63
|
+
appsignals = boto3.client('application-signals', region_name=AWS_REGION, config=config)
|
|
64
|
+
cloudwatch = boto3.client('cloudwatch', region_name=AWS_REGION, config=config)
|
|
65
|
+
xray = boto3.client('xray', region_name=AWS_REGION, config=config)
|
|
66
|
+
|
|
54
67
|
logger.debug('AWS clients initialized successfully')
|
|
68
|
+
return logs, appsignals, cloudwatch, xray
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# Initialize clients at module level
|
|
72
|
+
try:
|
|
73
|
+
logs_client, appsignals_client, cloudwatch_client, xray_client = _initialize_aws_clients()
|
|
55
74
|
except Exception as e:
|
|
56
75
|
logger.error(f'Failed to initialize AWS clients: {str(e)}')
|
|
57
76
|
raise
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Pytest configuration for CloudWatch Application Signals MCP Server tests."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# Set test environment variables before any imports
|
|
7
|
+
os.environ['AWS_ACCESS_KEY_ID'] = 'testing'
|
|
8
|
+
os.environ['AWS_SECRET_ACCESS_KEY'] = 'testing' # pragma: allowlist secret
|
|
9
|
+
os.environ['AWS_SECURITY_TOKEN'] = 'testing'
|
|
10
|
+
os.environ['AWS_SESSION_TOKEN'] = 'testing'
|
|
11
|
+
os.environ.pop('AWS_PROFILE', None)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""Test AWS profile handling in isolation."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import pytest
|
|
5
|
+
from unittest.mock import MagicMock, patch
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_aws_profile_branch_coverage():
|
|
9
|
+
"""Test the AWS_PROFILE environment variable branch coverage."""
|
|
10
|
+
# Test the condition when AWS_PROFILE is set
|
|
11
|
+
with patch.dict(os.environ, {'AWS_PROFILE': 'test-profile'}):
|
|
12
|
+
assert os.environ.get('AWS_PROFILE') == 'test-profile'
|
|
13
|
+
|
|
14
|
+
# Test walrus operator assignment
|
|
15
|
+
if aws_profile := os.environ.get('AWS_PROFILE'):
|
|
16
|
+
assert aws_profile == 'test-profile'
|
|
17
|
+
|
|
18
|
+
# Test the condition when AWS_PROFILE is not set
|
|
19
|
+
with patch.dict(os.environ, {}, clear=True):
|
|
20
|
+
assert os.environ.get('AWS_PROFILE') is None
|
|
21
|
+
|
|
22
|
+
# Test walrus operator assignment with None
|
|
23
|
+
if aws_profile := os.environ.get('AWS_PROFILE'):
|
|
24
|
+
pytest.fail('Should not enter this branch when AWS_PROFILE is not set')
|
|
25
|
+
else:
|
|
26
|
+
assert aws_profile is None
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_aws_client_initialization_flow():
|
|
30
|
+
"""Test the client initialization flow with and without AWS_PROFILE."""
|
|
31
|
+
import boto3
|
|
32
|
+
from botocore.config import Config
|
|
33
|
+
|
|
34
|
+
# Mock config
|
|
35
|
+
config = MagicMock(spec=Config)
|
|
36
|
+
|
|
37
|
+
# Test with AWS_PROFILE
|
|
38
|
+
with patch('boto3.Session') as mock_session:
|
|
39
|
+
mock_session_instance = MagicMock()
|
|
40
|
+
mock_session.return_value = mock_session_instance
|
|
41
|
+
|
|
42
|
+
# Simulate the server initialization logic
|
|
43
|
+
aws_profile = 'test-profile'
|
|
44
|
+
AWS_REGION = 'us-west-2'
|
|
45
|
+
|
|
46
|
+
if aws_profile:
|
|
47
|
+
session = boto3.Session(profile_name=aws_profile, region_name=AWS_REGION)
|
|
48
|
+
session.client('logs', config=config)
|
|
49
|
+
session.client('application-signals', config=config)
|
|
50
|
+
session.client('cloudwatch', config=config)
|
|
51
|
+
session.client('xray', config=config)
|
|
52
|
+
|
|
53
|
+
# Verify calls
|
|
54
|
+
mock_session.assert_called_once_with(
|
|
55
|
+
profile_name='test-profile', region_name='us-west-2'
|
|
56
|
+
)
|
|
57
|
+
assert mock_session_instance.client.call_count == 4
|
|
58
|
+
|
|
59
|
+
# Test without AWS_PROFILE
|
|
60
|
+
with patch('boto3.client') as mock_client:
|
|
61
|
+
AWS_REGION = 'us-east-1'
|
|
62
|
+
aws_profile = None
|
|
63
|
+
|
|
64
|
+
if not aws_profile:
|
|
65
|
+
boto3.client('logs', region_name=AWS_REGION, config=config)
|
|
66
|
+
boto3.client('application-signals', region_name=AWS_REGION, config=config)
|
|
67
|
+
boto3.client('cloudwatch', region_name=AWS_REGION, config=config)
|
|
68
|
+
boto3.client('xray', region_name=AWS_REGION, config=config)
|
|
69
|
+
|
|
70
|
+
# Verify calls
|
|
71
|
+
assert mock_client.call_count == 4
|
|
72
|
+
for call in mock_client.call_args_list:
|
|
73
|
+
assert call.kwargs['region_name'] == 'us-east-1'
|
|
74
|
+
assert call.kwargs['config'] == config
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_server_initialization_with_aws_profile_coverage():
|
|
78
|
+
"""Test to ensure AWS_PROFILE code path gets coverage."""
|
|
79
|
+
# This test simulates the exact logic from server.py to ensure coverage
|
|
80
|
+
import boto3
|
|
81
|
+
from botocore.config import Config
|
|
82
|
+
|
|
83
|
+
# Mock the actual initialization logic
|
|
84
|
+
mock_session = MagicMock()
|
|
85
|
+
mock_session_instance = MagicMock()
|
|
86
|
+
mock_session.return_value = mock_session_instance
|
|
87
|
+
|
|
88
|
+
with patch.dict(os.environ, {'AWS_PROFILE': 'test-profile'}):
|
|
89
|
+
with patch('boto3.Session', mock_session):
|
|
90
|
+
# This is the exact code from server.py that needs coverage
|
|
91
|
+
config = MagicMock(spec=Config)
|
|
92
|
+
AWS_REGION = 'us-east-1'
|
|
93
|
+
|
|
94
|
+
# Check for AWS_PROFILE environment variable (exact code from server.py)
|
|
95
|
+
if aws_profile := os.environ.get('AWS_PROFILE'):
|
|
96
|
+
# This block needs coverage
|
|
97
|
+
session = boto3.Session(profile_name=aws_profile, region_name=AWS_REGION)
|
|
98
|
+
session.client('logs', config=config)
|
|
99
|
+
session.client('application-signals', config=config)
|
|
100
|
+
session.client('cloudwatch', config=config)
|
|
101
|
+
session.client('xray', config=config)
|
|
102
|
+
|
|
103
|
+
# Verify the AWS profile was used
|
|
104
|
+
mock_session.assert_called_once_with(
|
|
105
|
+
profile_name='test-profile', region_name='us-east-1'
|
|
106
|
+
)
|
|
107
|
+
assert mock_session_instance.client.call_count == 4
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def test_initialize_aws_clients_with_profile():
|
|
111
|
+
"""Test _initialize_aws_clients function with AWS_PROFILE set."""
|
|
112
|
+
from awslabs.cloudwatch_appsignals_mcp_server.server import _initialize_aws_clients
|
|
113
|
+
|
|
114
|
+
# Mock the necessary components
|
|
115
|
+
mock_session = MagicMock()
|
|
116
|
+
mock_session_instance = MagicMock()
|
|
117
|
+
mock_session.return_value = mock_session_instance
|
|
118
|
+
mock_client = MagicMock()
|
|
119
|
+
mock_session_instance.client.return_value = mock_client
|
|
120
|
+
|
|
121
|
+
with patch.dict(os.environ, {'AWS_PROFILE': 'test-profile', 'AWS_REGION': 'us-east-1'}):
|
|
122
|
+
with patch('awslabs.cloudwatch_appsignals_mcp_server.server.boto3.Session', mock_session):
|
|
123
|
+
with patch('awslabs.cloudwatch_appsignals_mcp_server.server.Config'):
|
|
124
|
+
# Call the initialization function
|
|
125
|
+
logs, appsignals, cloudwatch, xray = _initialize_aws_clients()
|
|
126
|
+
|
|
127
|
+
# Verify Session was called with the profile
|
|
128
|
+
mock_session.assert_called_once()
|
|
129
|
+
call_kwargs = mock_session.call_args[1]
|
|
130
|
+
assert call_kwargs['profile_name'] == 'test-profile'
|
|
131
|
+
assert call_kwargs['region_name'] == 'us-east-1'
|
|
132
|
+
|
|
133
|
+
# Verify all clients were created
|
|
134
|
+
assert mock_session_instance.client.call_count == 4
|
|
135
|
+
client_calls = [call[0][0] for call in mock_session_instance.client.call_args_list]
|
|
136
|
+
assert 'logs' in client_calls
|
|
137
|
+
assert 'application-signals' in client_calls
|
|
138
|
+
assert 'cloudwatch' in client_calls
|
|
139
|
+
assert 'xray' in client_calls
|
|
140
|
+
|
|
141
|
+
# Verify the returned clients
|
|
142
|
+
assert logs == mock_client
|
|
143
|
+
assert appsignals == mock_client
|
|
144
|
+
assert cloudwatch == mock_client
|
|
145
|
+
assert xray == mock_client
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|