22225. Supporting tool refresh
2323"""
2424
25- import argparse
2625import asyncio
2726import httpx
2827import logging
29- import os
3028from fastmcp .server .middleware .error_handling import RetryMiddleware
3129from fastmcp .server .middleware .logging import LoggingMiddleware
3230from fastmcp .server .server import FastMCP
33- from mcp_proxy_for_aws import __version__
31+ from mcp_proxy_for_aws . cli import parse_args
3432from mcp_proxy_for_aws .logging_config import configure_logging
3533from mcp_proxy_for_aws .middleware .tool_filter import ToolFilteringMiddleware
3634from mcp_proxy_for_aws .utils import (
3735 create_transport_with_sigv4 ,
3836 determine_aws_region ,
3937 determine_service_name ,
40- within_range ,
4138)
4239from typing import Any
4340
@@ -111,7 +108,7 @@ def add_retry_middleware(mcp: FastMCP, retries: int) -> None:
111108 mcp .add_middleware (RetryMiddleware (retries ))
112109
113110
114- def add_logging_middleware (mcp : FastMCP , log_level : int ) -> None :
111+ def add_logging_middleware (mcp : FastMCP , log_level : str ) -> None :
115112 """Add logging middleware."""
116113 if log_level != 'DEBUG' :
117114 return
@@ -127,99 +124,6 @@ def add_logging_middleware(mcp: FastMCP, log_level: int) -> None:
127124 )
128125
129126
130- def parse_args ():
131- """Parse command line arguments."""
132- parser = argparse .ArgumentParser (
133- description = f'MCP Proxy for AWS v{ __version__ } ' ,
134- formatter_class = argparse .RawDescriptionHelpFormatter ,
135- epilog = """
136- Examples:
137- # Run with your endpoint
138- mcp-proxy-for-aws <SigV4 MCP endpoint URL>
139-
140- # Run with custom service and profile
141- mcp-proxy-for-aws <SigV4 MCP endpoint URL> --service <aws-service> --profile default
142-
143- # Run with write permissions enabled
144- mcp-proxy-for-aws <SigV4 MCP endpoint URL> --read-only
145- """ ,
146- )
147-
148- parser .add_argument (
149- 'endpoint' ,
150- help = 'SigV4 MCP endpoint URL' ,
151- )
152-
153- parser .add_argument (
154- '--service' ,
155- help = 'AWS service name for SigV4 signing (inferred from endpoint if not provided)' ,
156- )
157-
158- parser .add_argument (
159- '--profile' ,
160- help = 'AWS profile to use (uses AWS_PROFILE environment variable if not provided)' ,
161- default = os .getenv ('AWS_PROFILE' ),
162- )
163-
164- parser .add_argument (
165- '--region' ,
166- help = 'AWS region to use (uses AWS_REGION environment variable if not provided, with final fallback to us-east-1)' ,
167- default = None ,
168- )
169-
170- parser .add_argument (
171- '--read-only' ,
172- action = 'store_true' ,
173- help = 'Disable tools which may require write permissions (readOnlyHint True or unknown)' ,
174- )
175-
176- parser .add_argument (
177- '--log-level' ,
178- choices = ['DEBUG' , 'INFO' , 'WARNING' , 'ERROR' , 'CRITICAL' ],
179- default = 'INFO' ,
180- help = 'Set the logging level (default: INFO)' ,
181- )
182-
183- parser .add_argument (
184- '--retries' ,
185- type = int ,
186- default = 0 ,
187- choices = range (0 , 11 ),
188- metavar = '[0-10]' ,
189- help = 'Number of retries when calling endpoint mcp (default: 0) - setting this to 0 disables retries.' ,
190- )
191-
192- parser .add_argument (
193- '--timeout' ,
194- type = within_range (0 ),
195- default = 180.0 ,
196- help = 'Timeout (seconds) when connecting to endpoint (default: 180)' ,
197- )
198-
199- parser .add_argument (
200- '--connect-timeout' ,
201- type = within_range (0 ),
202- default = 60.0 ,
203- help = 'Connection timeout (seconds) when connecting to endpoint (default: 60)' ,
204- )
205-
206- parser .add_argument (
207- '--read-timeout' ,
208- type = within_range (0 ),
209- default = 120.0 ,
210- help = 'Read timeout (seconds) when connecting to endpoint (default: 120)' ,
211- )
212-
213- parser .add_argument (
214- '--write-timeout' ,
215- type = within_range (0 ),
216- default = 180.0 ,
217- help = 'Write timeout (seconds) when connecting to endpoint (default: 180)' ,
218- )
219-
220- return parser .parse_args ()
221-
222-
223127def main ():
224128 """Run the MCP server."""
225129 args = parse_args ()
0 commit comments