awslabs.finch-mcp-server 0.1.3__py3-none-any.whl → 0.1.5__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.
@@ -14,4 +14,4 @@
14
14
 
15
15
  """awslabs.finch-mcp-server"""
16
16
 
17
- __version__ = '0.1.0'
17
+ __version__ = '0.1.5'
@@ -24,8 +24,6 @@ import sys
24
24
  # Server name
25
25
  SERVER_NAME = 'finch_mcp_server'
26
26
 
27
- # Log file name
28
- LOG_FILE = 'finch_server.log'
29
27
 
30
28
  # VM states
31
29
  VM_STATE_RUNNING = 'running'
@@ -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 LOG_FILE, SERVER_NAME
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
- # Configure loguru logger
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
- # Remove all default handlers then add our own
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
- logger.info(f'Logs will be written to: {LOG_FILE}')
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
  Metadata-Version: 2.4
2
2
  Name: awslabs.finch-mcp-server
3
- Version: 0.1.3
3
+ Version: 0.1.5
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/
@@ -57,7 +57,7 @@ This MCP server acts as a bridge between MCP clients and Finch, allowing generat
57
57
 
58
58
  | Cursor | VS Code |
59
59
  |:------:|:-------:|
60
- | [![Install MCP Server](https://cursor.com/deeplink/mcp-install-light.svg)](https://cursor.com/install-mcp?name=awslabs.finch-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGF3c2xhYnMuZmluY2gtbWNwLXNlcnZlckBsYXRlc3QiLCJlbnYiOnsiQVdTX1BST0ZJTEUiOiJkZWZhdWx0IiwiQVdTX1JFR0lPTiI6InVzLXdlc3QtMiIsIkZBU1RNQ1BfTE9HX0xFVkVMIjoiSU5GTyJ9LCJ0cmFuc3BvcnRUeXBlIjoic3RkaW8iLCJkaXNhYmxlZCI6ZmFsc2UsImF1dG9BcHByb3ZlIjpbXX0%3D) | [![Install on VS Code](https://img.shields.io/badge/Install_on-VS_Code-FF9900?style=flat-square&logo=visualstudiocode&logoColor=white)](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) |
60
+ | [![Install MCP Server](https://cursor.com/deeplink/mcp-install-light.svg)](https://cursor.com/en/install-mcp?name=awslabs.finch-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGF3c2xhYnMuZmluY2gtbWNwLXNlcnZlckBsYXRlc3QiLCJlbnYiOnsiQVdTX1BST0ZJTEUiOiJkZWZhdWx0IiwiQVdTX1JFR0lPTiI6InVzLXdlc3QtMiIsIkZBU1RNQ1BfTE9HX0xFVkVMIjoiSU5GTyJ9LCJ0cmFuc3BvcnRUeXBlIjoic3RkaW8iLCJkaXNhYmxlZCI6ZmFsc2UsImF1dG9BcHByb3ZlIjpbXX0%3D) | [![Install on VS Code](https://img.shields.io/badge/Install_on-VS_Code-FF9900?style=flat-square&logo=visualstudiocode&logoColor=white)](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
61
 
62
62
  Configure the MCP server in your MCP client configuration:
63
63
 
@@ -204,12 +204,121 @@ Example:
204
204
  - **Error Handling**: Implement proper error handling in your applications when using these tools.
205
205
 
206
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
+
207
314
  ## Troubleshooting
208
315
 
209
316
  - If you encounter permission errors with ECR, verify your AWS credentials and boto3 configuration are properly set up
210
317
  - For Finch VM issues, try running `finch vm stop` and then `finch vm start` manually
211
318
  - If the build fails with errors about missing files, check that your context path is correct
212
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
213
322
 
214
323
  ## Version
215
324
 
@@ -1,17 +1,17 @@
1
1
  awslabs/__init__.py,sha256=-pACKy0qlm5jBycQx_UdX7y03PRTO7uKL1QzktCS2rE,655
2
- awslabs/finch_mcp_server/__init__.py,sha256=h3HPXFMBREimxSsvaysCH8Zb1g1du_mRJcSzQpHZxR4,670
3
- awslabs/finch_mcp_server/consts.py,sha256=djCB0hkR6VbnGTjJ3piPORP4g4N5OqFoFqgb-o6ZM8s,1656
2
+ awslabs/finch_mcp_server/__init__.py,sha256=znLORWkOSKzAcfkg4RLd1tlBqJMlr0Lf4f4898hrEqE,670
3
+ awslabs/finch_mcp_server/consts.py,sha256=oBl88dX-cSiZCPdlGaSTNtc5oIlleYEviO0sYnzYZXM,1610
4
4
  awslabs/finch_mcp_server/models.py,sha256=RrQpjBIKM3Mu2RYKr9zZv66ZdSt63lygjRWlGyUmxtY,1294
5
- awslabs/finch_mcp_server/server.py,sha256=xCs7-tsXw1Q0x6C8MBgSMsNa2HyEoJ3ujwXoxpvn3vU,17399
5
+ awslabs/finch_mcp_server/server.py,sha256=yU4DTViNLKsP37sj-iyTTrb8V90e21r_o0NDqXFzjpE,20865
6
6
  awslabs/finch_mcp_server/utils/__init__.py,sha256=IZiJBNmbi0xUOH0s7ZBIWFuOWoRqdauvE2ibEwUQuXU,746
7
7
  awslabs/finch_mcp_server/utils/build.py,sha256=2xVkfJpm0_b4tW_8moInNbXkqgBOexsH9bSWudpqZCA,5260
8
8
  awslabs/finch_mcp_server/utils/common.py,sha256=OFPZT5B4cfrWWLB1TM_YiQ8p6FAGPDSbKu8IgDkzoWU,6225
9
9
  awslabs/finch_mcp_server/utils/ecr.py,sha256=hB4Oy5HUmF85vxLI6EsQ5Gn8WyA11WAyiWaRy8z8hNQ,3867
10
10
  awslabs/finch_mcp_server/utils/push.py,sha256=ZJYtIT5DrA07i7vTn5aPafSkoTBo4Yq05TqtplxyI0A,4680
11
11
  awslabs/finch_mcp_server/utils/vm.py,sha256=GD8zBAxkkYzZgSM-FgM0sJCkw5XVYsCDSdNQcjLMaYo,16188
12
- awslabs_finch_mcp_server-0.1.3.dist-info/METADATA,sha256=-H6KHylwcp9shiXOq72RxLdB--iZmNfAc-gbznm-4Ow,9563
13
- awslabs_finch_mcp_server-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
- awslabs_finch_mcp_server-0.1.3.dist-info/entry_points.txt,sha256=4fJNznnCPk2jY2ztTYAvEpLeYXcS3wDkgx2gAYdezPY,82
15
- awslabs_finch_mcp_server-0.1.3.dist-info/licenses/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
16
- awslabs_finch_mcp_server-0.1.3.dist-info/licenses/NOTICE,sha256=W4rmEHanXgUYNeoEh6oB-pfuI1RtX4XIvX067GmL-i0,92
17
- awslabs_finch_mcp_server-0.1.3.dist-info/RECORD,,
12
+ awslabs_finch_mcp_server-0.1.5.dist-info/METADATA,sha256=zUof8z9_Dy9kZnT-pMT3-_iUFK5yd3q_1oZpMXELDmM,12353
13
+ awslabs_finch_mcp_server-0.1.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ awslabs_finch_mcp_server-0.1.5.dist-info/entry_points.txt,sha256=4fJNznnCPk2jY2ztTYAvEpLeYXcS3wDkgx2gAYdezPY,82
15
+ awslabs_finch_mcp_server-0.1.5.dist-info/licenses/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
16
+ awslabs_finch_mcp_server-0.1.5.dist-info/licenses/NOTICE,sha256=W4rmEHanXgUYNeoEh6oB-pfuI1RtX4XIvX067GmL-i0,92
17
+ awslabs_finch_mcp_server-0.1.5.dist-info/RECORD,,