Skip to content

Commit 21cd658

Browse files
committed
feat(server): add command-line argument parsing for transport and port
- Add sys.argv parsing to main() function - Support --transport argument to choose between stdio and http - Support --port argument for HTTP transport - Add __main__ block to allow direct execution Enables running the MCP server via uvx with transport and port options: uvx spec-driven-development-mcp --transport http --port 8000
1 parent 2f021fd commit 21cd658

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

server.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
The 'mcp' instance is automatically discovered by the FastMCP CLI.
55
"""
66

7+
import sys
8+
79
from mcp_server import create_app
810

911
# Create the MCP server instance
@@ -17,6 +19,31 @@ def main() -> None:
1719
This function is called when the package is installed and run via:
1820
uvx spec-driven-development-mcp
1921
20-
It runs the MCP server using stdio transport.
22+
It runs the MCP server using stdio transport by default, or http transport
23+
if --transport http is passed as an argument.
2124
"""
22-
mcp.run()
25+
# Parse command line arguments
26+
transport = "stdio"
27+
port = 8000
28+
args = sys.argv[1:]
29+
30+
# Simple argument parsing for transport and port
31+
if "--transport" in args:
32+
idx = args.index("--transport")
33+
if idx + 1 < len(args):
34+
transport = args[idx + 1]
35+
36+
if "--port" in args:
37+
idx = args.index("--port")
38+
if idx + 1 < len(args):
39+
port = int(args[idx + 1])
40+
41+
# Run the server with the specified transport
42+
if transport == "http":
43+
mcp.run(transport="http", port=port)
44+
else:
45+
mcp.run()
46+
47+
48+
if __name__ == "__main__":
49+
main()

0 commit comments

Comments
 (0)