awslabs.finch-mcp-server 0.1.2__tar.gz → 0.1.4__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_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/PKG-INFO +115 -2
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/README.md +113 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/awslabs/finch_mcp_server/__init__.py +1 -1
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/awslabs/finch_mcp_server/consts.py +0 -2
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/awslabs/finch_mcp_server/server.py +113 -24
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/pyproject.toml +2 -2
- awslabs_finch_mcp_server-0.1.4/tests/test_cli_flags.py +871 -0
- awslabs_finch_mcp_server-0.1.4/tests/test_logging_configuration.py +257 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/tests/test_server.py +48 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/uv.lock +208 -8
- awslabs_finch_mcp_server-0.1.2/.pre-commit-config.yaml +0 -14
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/.gitignore +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/.python-version +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/CHANGELOG.md +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/LICENSE +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/NOTICE +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/awslabs/__init__.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/awslabs/finch_mcp_server/models.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/awslabs/finch_mcp_server/utils/__init__.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/awslabs/finch_mcp_server/utils/build.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/awslabs/finch_mcp_server/utils/common.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/awslabs/finch_mcp_server/utils/ecr.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/awslabs/finch_mcp_server/utils/push.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/awslabs/finch_mcp_server/utils/vm.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/tests/__init__.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/tests/test_utils_build.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/tests/test_utils_common.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/tests/test_utils_ecr.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/tests/test_utils_push.py +0 -0
- {awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/tests/test_utils_vm.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: awslabs.finch-mcp-server
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: A Model Context Protocol server for Finch to build and push container images
|
|
5
5
|
Project-URL: Homepage, https://awslabs.github.io/mcp/
|
|
6
6
|
Project-URL: Documentation, https://awslabs.github.io/mcp/servers/finch-mcp-server/
|
|
@@ -23,7 +23,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
23
23
|
Requires-Python: >=3.10
|
|
24
24
|
Requires-Dist: boto3>=1.28.0
|
|
25
25
|
Requires-Dist: loguru>=0.7.0
|
|
26
|
-
Requires-Dist: mcp[cli]>=1.
|
|
26
|
+
Requires-Dist: mcp[cli]>=1.11.0
|
|
27
27
|
Requires-Dist: pydantic>=2.0.0
|
|
28
28
|
Requires-Dist: pyyaml>=6.0
|
|
29
29
|
Description-Content-Type: text/markdown
|
|
@@ -55,6 +55,10 @@ This MCP server acts as a bridge between MCP clients and Finch, allowing generat
|
|
|
55
55
|
|
|
56
56
|
### Installation
|
|
57
57
|
|
|
58
|
+
| Cursor | VS Code |
|
|
59
|
+
|:------:|:-------:|
|
|
60
|
+
| [](https://cursor.com/install-mcp?name=awslabs.finch-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGF3c2xhYnMuZmluY2gtbWNwLXNlcnZlckBsYXRlc3QiLCJlbnYiOnsiQVdTX1BST0ZJTEUiOiJkZWZhdWx0IiwiQVdTX1JFR0lPTiI6InVzLXdlc3QtMiIsIkZBU1RNQ1BfTE9HX0xFVkVMIjoiSU5GTyJ9LCJ0cmFuc3BvcnRUeXBlIjoic3RkaW8iLCJkaXNhYmxlZCI6ZmFsc2UsImF1dG9BcHByb3ZlIjpbXX0%3D) | [](https://insiders.vscode.dev/redirect/mcp/install?name=Finch%20MCP%20Server&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22awslabs.finch-mcp-server%40latest%22%5D%2C%22env%22%3A%7B%22AWS_PROFILE%22%3A%22default%22%2C%22AWS_REGION%22%3A%22us-west-2%22%2C%22FASTMCP_LOG_LEVEL%22%3A%22INFO%22%7D%2C%22transportType%22%3A%22stdio%22%2C%22disabled%22%3Afalse%2C%22autoApprove%22%3A%5B%5D%7D) |
|
|
61
|
+
|
|
58
62
|
Configure the MCP server in your MCP client configuration:
|
|
59
63
|
|
|
60
64
|
#### Default Mode (Read-only AWS Resources)
|
|
@@ -200,12 +204,121 @@ Example:
|
|
|
200
204
|
- **Error Handling**: Implement proper error handling in your applications when using these tools.
|
|
201
205
|
|
|
202
206
|
|
|
207
|
+
## Logging
|
|
208
|
+
|
|
209
|
+
The Finch MCP server provides comprehensive logging capabilities to help with debugging and monitoring operations.
|
|
210
|
+
|
|
211
|
+
### Log Destinations
|
|
212
|
+
|
|
213
|
+
By default, the server logs to two destinations:
|
|
214
|
+
1. **stderr** - Standard error output (follows MCP protocol standards)
|
|
215
|
+
2. **File** - Persistent log file for detailed debugging
|
|
216
|
+
|
|
217
|
+
### File Logging
|
|
218
|
+
|
|
219
|
+
#### Default Log Location
|
|
220
|
+
|
|
221
|
+
Logs are automatically saved to platform-specific directories:
|
|
222
|
+
- **macOS/Linux**: `~/.finch/finch-mcp-server/finch_mcp_server.log`
|
|
223
|
+
- **Windows**: `%LOCALAPPDATA%\finch-mcp-server\finch_mcp_server.log`
|
|
224
|
+
|
|
225
|
+
#### Custom Log File Location
|
|
226
|
+
|
|
227
|
+
Specify a custom log file path using the `FINCH_MCP_LOG_FILE` environment variable:
|
|
228
|
+
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"mcpServers": {
|
|
232
|
+
"awslabs.finch-mcp-server": {
|
|
233
|
+
"command": "uvx",
|
|
234
|
+
"args": ["awslabs.finch-mcp-server@latest"],
|
|
235
|
+
"env": {
|
|
236
|
+
"FINCH_MCP_LOG_FILE": "~/logs/finch-mcp-server.log"
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### Disable File Logging
|
|
244
|
+
|
|
245
|
+
To log only to stderr (following strict MCP standards), disable file logging:
|
|
246
|
+
|
|
247
|
+
```json
|
|
248
|
+
{
|
|
249
|
+
"mcpServers": {
|
|
250
|
+
"awslabs.finch-mcp-server": {
|
|
251
|
+
"command": "uvx",
|
|
252
|
+
"args": ["awslabs.finch-mcp-server@latest"],
|
|
253
|
+
"env": {
|
|
254
|
+
"FINCH_DISABLE_FILE_LOGGING": "true"
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Or use the command line argument in the args array:
|
|
262
|
+
```json
|
|
263
|
+
{
|
|
264
|
+
"mcpServers": {
|
|
265
|
+
"awslabs.finch-mcp-server": {
|
|
266
|
+
"command": "uvx",
|
|
267
|
+
"args": [
|
|
268
|
+
"awslabs.finch-mcp-server@latest",
|
|
269
|
+
"--disable-file-logging"
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Log Features
|
|
277
|
+
|
|
278
|
+
#### Automatic Log Rotation
|
|
279
|
+
- Log files are automatically rotated when they exceed 10 MB
|
|
280
|
+
- Old logs are compressed (gzip) and retained for 7 days
|
|
281
|
+
- This prevents disk space issues from large log files
|
|
282
|
+
|
|
283
|
+
#### Sensitive Data Protection
|
|
284
|
+
The logging system automatically redacts sensitive information from log messages:
|
|
285
|
+
- AWS access keys and secret keys
|
|
286
|
+
- API keys, passwords, and tokens
|
|
287
|
+
- JWT tokens and OAuth credentials
|
|
288
|
+
- URLs containing embedded credentials
|
|
289
|
+
|
|
290
|
+
#### Log Format
|
|
291
|
+
- **stderr**: `{time} | {level} | {message}`
|
|
292
|
+
- **File**: `{time} | {level} | {name}:{function}:{line} | {message}`
|
|
293
|
+
|
|
294
|
+
The file format includes additional context (function name and line number) for detailed debugging.
|
|
295
|
+
|
|
296
|
+
### Example Configuration
|
|
297
|
+
|
|
298
|
+
```json
|
|
299
|
+
{
|
|
300
|
+
"mcpServers": {
|
|
301
|
+
"awslabs.finch-mcp-server": {
|
|
302
|
+
"command": "uvx",
|
|
303
|
+
"args": ["awslabs.finch-mcp-server@latest"],
|
|
304
|
+
"env": {
|
|
305
|
+
"AWS_PROFILE": "default",
|
|
306
|
+
"AWS_REGION": "us-west-2",
|
|
307
|
+
"FINCH_MCP_LOG_FILE": "~/logs/finch-mcp-server.log"
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
203
314
|
## Troubleshooting
|
|
204
315
|
|
|
205
316
|
- If you encounter permission errors with ECR, verify your AWS credentials and boto3 configuration are properly set up
|
|
206
317
|
- For Finch VM issues, try running `finch vm stop` and then `finch vm start` manually
|
|
207
318
|
- If the build fails with errors about missing files, check that your context path is correct
|
|
208
319
|
- For general Finch issues, consult the [Finch documentation](https://github.com/runfinch/finch)
|
|
320
|
+
- **Check the logs**: Enable DEBUG level logging and examine the log files for detailed error information
|
|
321
|
+
- **Log file permissions**: If file logging fails, the server will continue with stderr-only logging and show a warning message
|
|
209
322
|
|
|
210
323
|
## Version
|
|
211
324
|
|
|
@@ -25,6 +25,10 @@ This MCP server acts as a bridge between MCP clients and Finch, allowing generat
|
|
|
25
25
|
|
|
26
26
|
### Installation
|
|
27
27
|
|
|
28
|
+
| Cursor | VS Code |
|
|
29
|
+
|:------:|:-------:|
|
|
30
|
+
| [](https://cursor.com/install-mcp?name=awslabs.finch-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGF3c2xhYnMuZmluY2gtbWNwLXNlcnZlckBsYXRlc3QiLCJlbnYiOnsiQVdTX1BST0ZJTEUiOiJkZWZhdWx0IiwiQVdTX1JFR0lPTiI6InVzLXdlc3QtMiIsIkZBU1RNQ1BfTE9HX0xFVkVMIjoiSU5GTyJ9LCJ0cmFuc3BvcnRUeXBlIjoic3RkaW8iLCJkaXNhYmxlZCI6ZmFsc2UsImF1dG9BcHByb3ZlIjpbXX0%3D) | [](https://insiders.vscode.dev/redirect/mcp/install?name=Finch%20MCP%20Server&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22awslabs.finch-mcp-server%40latest%22%5D%2C%22env%22%3A%7B%22AWS_PROFILE%22%3A%22default%22%2C%22AWS_REGION%22%3A%22us-west-2%22%2C%22FASTMCP_LOG_LEVEL%22%3A%22INFO%22%7D%2C%22transportType%22%3A%22stdio%22%2C%22disabled%22%3Afalse%2C%22autoApprove%22%3A%5B%5D%7D) |
|
|
31
|
+
|
|
28
32
|
Configure the MCP server in your MCP client configuration:
|
|
29
33
|
|
|
30
34
|
#### Default Mode (Read-only AWS Resources)
|
|
@@ -170,12 +174,121 @@ Example:
|
|
|
170
174
|
- **Error Handling**: Implement proper error handling in your applications when using these tools.
|
|
171
175
|
|
|
172
176
|
|
|
177
|
+
## Logging
|
|
178
|
+
|
|
179
|
+
The Finch MCP server provides comprehensive logging capabilities to help with debugging and monitoring operations.
|
|
180
|
+
|
|
181
|
+
### Log Destinations
|
|
182
|
+
|
|
183
|
+
By default, the server logs to two destinations:
|
|
184
|
+
1. **stderr** - Standard error output (follows MCP protocol standards)
|
|
185
|
+
2. **File** - Persistent log file for detailed debugging
|
|
186
|
+
|
|
187
|
+
### File Logging
|
|
188
|
+
|
|
189
|
+
#### Default Log Location
|
|
190
|
+
|
|
191
|
+
Logs are automatically saved to platform-specific directories:
|
|
192
|
+
- **macOS/Linux**: `~/.finch/finch-mcp-server/finch_mcp_server.log`
|
|
193
|
+
- **Windows**: `%LOCALAPPDATA%\finch-mcp-server\finch_mcp_server.log`
|
|
194
|
+
|
|
195
|
+
#### Custom Log File Location
|
|
196
|
+
|
|
197
|
+
Specify a custom log file path using the `FINCH_MCP_LOG_FILE` environment variable:
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"mcpServers": {
|
|
202
|
+
"awslabs.finch-mcp-server": {
|
|
203
|
+
"command": "uvx",
|
|
204
|
+
"args": ["awslabs.finch-mcp-server@latest"],
|
|
205
|
+
"env": {
|
|
206
|
+
"FINCH_MCP_LOG_FILE": "~/logs/finch-mcp-server.log"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
#### Disable File Logging
|
|
214
|
+
|
|
215
|
+
To log only to stderr (following strict MCP standards), disable file logging:
|
|
216
|
+
|
|
217
|
+
```json
|
|
218
|
+
{
|
|
219
|
+
"mcpServers": {
|
|
220
|
+
"awslabs.finch-mcp-server": {
|
|
221
|
+
"command": "uvx",
|
|
222
|
+
"args": ["awslabs.finch-mcp-server@latest"],
|
|
223
|
+
"env": {
|
|
224
|
+
"FINCH_DISABLE_FILE_LOGGING": "true"
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Or use the command line argument in the args array:
|
|
232
|
+
```json
|
|
233
|
+
{
|
|
234
|
+
"mcpServers": {
|
|
235
|
+
"awslabs.finch-mcp-server": {
|
|
236
|
+
"command": "uvx",
|
|
237
|
+
"args": [
|
|
238
|
+
"awslabs.finch-mcp-server@latest",
|
|
239
|
+
"--disable-file-logging"
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Log Features
|
|
247
|
+
|
|
248
|
+
#### Automatic Log Rotation
|
|
249
|
+
- Log files are automatically rotated when they exceed 10 MB
|
|
250
|
+
- Old logs are compressed (gzip) and retained for 7 days
|
|
251
|
+
- This prevents disk space issues from large log files
|
|
252
|
+
|
|
253
|
+
#### Sensitive Data Protection
|
|
254
|
+
The logging system automatically redacts sensitive information from log messages:
|
|
255
|
+
- AWS access keys and secret keys
|
|
256
|
+
- API keys, passwords, and tokens
|
|
257
|
+
- JWT tokens and OAuth credentials
|
|
258
|
+
- URLs containing embedded credentials
|
|
259
|
+
|
|
260
|
+
#### Log Format
|
|
261
|
+
- **stderr**: `{time} | {level} | {message}`
|
|
262
|
+
- **File**: `{time} | {level} | {name}:{function}:{line} | {message}`
|
|
263
|
+
|
|
264
|
+
The file format includes additional context (function name and line number) for detailed debugging.
|
|
265
|
+
|
|
266
|
+
### Example Configuration
|
|
267
|
+
|
|
268
|
+
```json
|
|
269
|
+
{
|
|
270
|
+
"mcpServers": {
|
|
271
|
+
"awslabs.finch-mcp-server": {
|
|
272
|
+
"command": "uvx",
|
|
273
|
+
"args": ["awslabs.finch-mcp-server@latest"],
|
|
274
|
+
"env": {
|
|
275
|
+
"AWS_PROFILE": "default",
|
|
276
|
+
"AWS_REGION": "us-west-2",
|
|
277
|
+
"FINCH_MCP_LOG_FILE": "~/logs/finch-mcp-server.log"
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
173
284
|
## Troubleshooting
|
|
174
285
|
|
|
175
286
|
- If you encounter permission errors with ECR, verify your AWS credentials and boto3 configuration are properly set up
|
|
176
287
|
- For Finch VM issues, try running `finch vm stop` and then `finch vm start` manually
|
|
177
288
|
- If the build fails with errors about missing files, check that your context path is correct
|
|
178
289
|
- For general Finch issues, consult the [Finch documentation](https://github.com/runfinch/finch)
|
|
290
|
+
- **Check the logs**: Enable DEBUG level logging and examine the log files for detailed error information
|
|
291
|
+
- **Log file permissions**: If file logging fails, the server will continue with stderr-only logging and show a warning message
|
|
179
292
|
|
|
180
293
|
## Version
|
|
181
294
|
|
{awslabs_finch_mcp_server-0.1.2 → awslabs_finch_mcp_server-0.1.4}/awslabs/finch_mcp_server/server.py
RENAMED
|
@@ -23,7 +23,7 @@ purposes only and are not meant for production use cases.
|
|
|
23
23
|
import os
|
|
24
24
|
import re
|
|
25
25
|
import sys
|
|
26
|
-
from awslabs.finch_mcp_server.consts import
|
|
26
|
+
from awslabs.finch_mcp_server.consts import SERVER_NAME
|
|
27
27
|
|
|
28
28
|
# Import Pydantic models for input validation
|
|
29
29
|
from awslabs.finch_mcp_server.models import Result
|
|
@@ -46,11 +46,97 @@ from awslabs.finch_mcp_server.utils.vm import (
|
|
|
46
46
|
)
|
|
47
47
|
from loguru import logger
|
|
48
48
|
from mcp.server.fastmcp import FastMCP
|
|
49
|
+
from pathlib import Path
|
|
49
50
|
from pydantic import Field
|
|
50
51
|
from typing import Any, Dict, List, Optional
|
|
51
52
|
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
def get_default_log_path():
|
|
55
|
+
"""Get platform-appropriate persistent log directory."""
|
|
56
|
+
if os.name == 'nt': # Windows
|
|
57
|
+
app_data = os.environ.get('LOCALAPPDATA')
|
|
58
|
+
if not app_data:
|
|
59
|
+
return None # No suitable location found
|
|
60
|
+
log_dir = os.path.join(app_data, 'finch-mcp-server')
|
|
61
|
+
else: # Unix/Linux/macOS
|
|
62
|
+
# Use ~/.finch/finch-mcp-server/ for persistent logs
|
|
63
|
+
if 'HOME' in os.environ:
|
|
64
|
+
log_dir = os.path.join(Path.home(), '.finch', 'finch-mcp-server')
|
|
65
|
+
else:
|
|
66
|
+
return None # No suitable location found
|
|
67
|
+
|
|
68
|
+
# Create directory if it doesn't exist (including parent directories)
|
|
69
|
+
try:
|
|
70
|
+
os.makedirs(log_dir, exist_ok=True)
|
|
71
|
+
log_file_path = os.path.join(log_dir, 'finch_mcp_server.log')
|
|
72
|
+
return log_file_path
|
|
73
|
+
except (OSError, PermissionError):
|
|
74
|
+
# Return None if we can't create the directory
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def configure_logging(server_name: str = 'finch-mcp-server'):
|
|
79
|
+
"""Configure logging based on environment variables and command line arguments.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
server_name: Name to bind to the logger for identification
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
The configured logger instance
|
|
86
|
+
|
|
87
|
+
"""
|
|
88
|
+
logger.remove()
|
|
89
|
+
|
|
90
|
+
# Configure logging destinations
|
|
91
|
+
log_level = os.environ.get('FASTMCP_LOG_LEVEL', 'INFO')
|
|
92
|
+
file_logging_disabled = os.environ.get('FINCH_DISABLE_FILE_LOGGING', '').lower() in (
|
|
93
|
+
'true',
|
|
94
|
+
'1',
|
|
95
|
+
'yes',
|
|
96
|
+
)
|
|
97
|
+
custom_log_file = os.environ.get('FINCH_MCP_LOG_FILE') # User-specified log file location
|
|
98
|
+
|
|
99
|
+
# Always log to stderr (MCP standard)
|
|
100
|
+
logger.add(
|
|
101
|
+
sys.stderr,
|
|
102
|
+
level=log_level,
|
|
103
|
+
format='{time:YYYY-MM-DD HH:mm:ss} | {level} | {message}',
|
|
104
|
+
filter=sensitive_data_filter,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
# File logging (default to app data directory unless disabled or custom location specified)
|
|
108
|
+
if not file_logging_disabled:
|
|
109
|
+
log_file = custom_log_file or get_default_log_path()
|
|
110
|
+
|
|
111
|
+
if log_file:
|
|
112
|
+
try:
|
|
113
|
+
logger.add(
|
|
114
|
+
log_file,
|
|
115
|
+
level=log_level,
|
|
116
|
+
format='{time:YYYY-MM-DD HH:mm:ss} | {level} | {name}:{function}:{line} | {message}',
|
|
117
|
+
filter=sensitive_data_filter,
|
|
118
|
+
rotation='10 MB',
|
|
119
|
+
retention='7 days',
|
|
120
|
+
compression='gz',
|
|
121
|
+
)
|
|
122
|
+
# Log initialization message to ensure file gets created
|
|
123
|
+
logger.info('File logging initialized successfully')
|
|
124
|
+
except (OSError, PermissionError) as e:
|
|
125
|
+
# If we can't write to the log file, warn but continue with stderr only
|
|
126
|
+
logger.warning(
|
|
127
|
+
f'Could not create log file at {log_file}: {e}. Logging to stderr only.'
|
|
128
|
+
)
|
|
129
|
+
else:
|
|
130
|
+
# No suitable location found for log file
|
|
131
|
+
logger.warning(
|
|
132
|
+
'Could not find suitable location for log file. Logging to stderr only.'
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Re-bind logger with server name
|
|
136
|
+
bound_logger = logger.bind(name=server_name)
|
|
137
|
+
return bound_logger
|
|
138
|
+
|
|
139
|
+
|
|
54
140
|
def sensitive_data_filter(record):
|
|
55
141
|
"""Filter that redacts sensitive information from log messages.
|
|
56
142
|
|
|
@@ -133,27 +219,9 @@ def sensitive_data_filter(record):
|
|
|
133
219
|
return True
|
|
134
220
|
|
|
135
221
|
|
|
136
|
-
#
|
|
222
|
+
# Initialize basic stderr-only logging until we parse arguments
|
|
137
223
|
logger.remove()
|
|
138
|
-
|
|
139
|
-
log_level = os.environ.get('FASTMCP_LOG_LEVEL', 'INFO').upper()
|
|
140
|
-
logger.add(
|
|
141
|
-
LOG_FILE,
|
|
142
|
-
rotation='10 MB',
|
|
143
|
-
retention=7,
|
|
144
|
-
level=log_level,
|
|
145
|
-
format='{time:YYYY-MM-DD HH:mm:ss} | {level} | {name}:{function}:{line} | {message}',
|
|
146
|
-
filter=sensitive_data_filter,
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
# Add a handler for stderr
|
|
150
|
-
logger.add(
|
|
151
|
-
sys.stderr,
|
|
152
|
-
level=log_level,
|
|
153
|
-
format='{time:YYYY-MM-DD HH:mm:ss} | {level} | {message}',
|
|
154
|
-
filter=sensitive_data_filter,
|
|
155
|
-
)
|
|
156
|
-
|
|
224
|
+
logger.add(sys.stderr, level='INFO', filter=sensitive_data_filter)
|
|
157
225
|
logger = logger.bind(name=SERVER_NAME)
|
|
158
226
|
|
|
159
227
|
# Initialize the MCP server
|
|
@@ -438,11 +506,20 @@ def main(enable_aws_resource_write: bool = False):
|
|
|
438
506
|
set_enable_aws_resource_write(enable_aws_resource_write)
|
|
439
507
|
|
|
440
508
|
logger.info('Starting Finch MCP server')
|
|
441
|
-
|
|
509
|
+
|
|
510
|
+
# Log where logs are going
|
|
511
|
+
log_file = os.environ.get('FINCH_MCP_LOG_FILE')
|
|
512
|
+
if log_file:
|
|
513
|
+
logger.info(f'Logging to stderr and file: {log_file}')
|
|
514
|
+
elif os.environ.get('FINCH_DISABLE_FILE_LOGGING'):
|
|
515
|
+
logger.warning('Logging to stderr only')
|
|
516
|
+
else:
|
|
517
|
+
logger.info('Logging to stderr and default logging file')
|
|
518
|
+
|
|
442
519
|
mcp.run(transport='stdio')
|
|
443
520
|
|
|
444
521
|
|
|
445
|
-
if __name__ == '__main__':
|
|
522
|
+
if __name__ == '__main__': # pragma: no cover
|
|
446
523
|
import argparse
|
|
447
524
|
|
|
448
525
|
parser = argparse.ArgumentParser(description='Run the Finch MCP server')
|
|
@@ -451,6 +528,18 @@ if __name__ == '__main__':
|
|
|
451
528
|
action='store_true',
|
|
452
529
|
help='Enable AWS resource creation and modification (disabled by default)',
|
|
453
530
|
)
|
|
531
|
+
parser.add_argument(
|
|
532
|
+
'--disable-file-logging',
|
|
533
|
+
action='store_true',
|
|
534
|
+
help='Disable file logging entirely (stderr only, follows MCP standard)',
|
|
535
|
+
)
|
|
454
536
|
args = parser.parse_args()
|
|
455
537
|
|
|
538
|
+
# Set disable file logging from command line if provided
|
|
539
|
+
if args.disable_file_logging:
|
|
540
|
+
os.environ['FINCH_DISABLE_FILE_LOGGING'] = 'true'
|
|
541
|
+
|
|
542
|
+
# Configure logging after parsing arguments
|
|
543
|
+
configure_logging()
|
|
544
|
+
|
|
456
545
|
main(enable_aws_resource_write=args.enable_aws_resource_write)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "awslabs.finch-mcp-server"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.4"
|
|
4
4
|
description = "A Model Context Protocol server for Finch to build and push container images"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -20,7 +20,7 @@ classifiers = [
|
|
|
20
20
|
"Programming Language :: Python :: 3.13",
|
|
21
21
|
]
|
|
22
22
|
dependencies = [
|
|
23
|
-
"mcp[cli]>=1.
|
|
23
|
+
"mcp[cli]>=1.11.0",
|
|
24
24
|
"pydantic>=2.0.0",
|
|
25
25
|
"boto3>=1.28.0",
|
|
26
26
|
"loguru>=0.7.0",
|