Skip to content

Commit 36fd642

Browse files
author
wenfeng.wf
committed
Add modify port support
1 parent f4a8d49 commit 36fd642

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "alibabacloud-rds-openapi-mcp-server"
3-
version = "2.0.4"
3+
version = "2.0.5"
44
description = "MCP server for RDS Services via OPENAPI."
55
readme = "README.md"
66
requires-python = ">=3.12"

src/alibabacloud_rds_openapi_mcp_server/server.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424
json_array_to_csv,
2525
get_rds_client,
2626
get_vpc_client,
27-
get_bill_client, get_das_client, convert_datetime_to_timestamp)
27+
get_bill_client, get_das_client, convert_datetime_to_timestamp,
28+
parse_args)
2829

2930
logger = logging.getLogger(__name__)
3031

31-
mcp = FastMCP("Alibaba Cloud RDS OPENAPI")
32+
mcp = FastMCP("Alibaba Cloud RDS OPENAPI", **(parse_args(sys.argv)))
3233

3334

3435
class OpenAPIError(Exception):
@@ -1483,7 +1484,7 @@ async def show_create_table(
14831484

14841485

14851486
def main():
1486-
mcp.run(transport=os.getenv('SERVER_TRANSPORT', 'sse'))
1487+
mcp.run(transport=os.getenv('SERVER_TRANSPORT', 'stdio'))
14871488

14881489

14891490
if __name__ == '__main__':

src/alibabacloud_rds_openapi_mcp_server/utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@
4949
}
5050

5151

52+
def parse_args(argv):
53+
args = {}
54+
i = 1
55+
while i < len(argv):
56+
arg = argv[i]
57+
if arg.startswith('--'):
58+
key = arg[2:]
59+
if i + 1 < len(argv) and not argv[i + 1].startswith('--'):
60+
args[key] = argv[i+1]
61+
i += 2
62+
else:
63+
args[key] = True
64+
i += 1
65+
return args
66+
67+
5268
def transform_to_iso_8601(dt: datetime, timespec: str):
5369
return dt.astimezone(timezone.utc).isoformat(timespec=timespec).replace("+00:00", "Z")
5470

0 commit comments

Comments
 (0)