@@ -289,8 +289,15 @@ async def get_option_resource_with_channel(option_name: str, channel: str):
289289if __name__ == "__main__" :
290290 import uvicorn
291291 import logging
292+ import argparse
292293 from fastapi .middleware .cors import CORSMiddleware
293294
295+ # Parse command-line arguments
296+ parser = argparse .ArgumentParser (description = "NixMCP Server" )
297+ parser .add_argument ("--reload" , action = "store_true" , help = "Enable hot reloading for development" )
298+ parser .add_argument ("--port" , type = int , default = 9421 , help = "Port to run the server on (default: 9421)" )
299+ args = parser .parse_args ()
300+
294301 # Enable debug logging
295302 logging .basicConfig (level = logging .DEBUG )
296303
@@ -324,12 +331,19 @@ def debug_mcp_registered():
324331 print (f"Error accessing resources: { e } " )
325332 print (f"MCP object dir: { dir (mcp )} " )
326333
334+ port = args .port
327335 print ("\n Debug access URLs:" )
328- print (" - Test URL: http://localhost:8000/mcp/resource?uri=nixos://package/python" )
329- print (" - Direct FastAPI: http://localhost:8000/packages/python" )
330-
331- print ("\n Starting NixMCP server on port 8000..." )
332- print ("Access FastAPI docs at http://localhost:8000/docs" )
333- print ("Access MCP endpoints at http://localhost:8000/mcp" )
334-
335- uvicorn .run ("server:app" , host = "0.0.0.0" , port = 8000 , log_level = "debug" )
336+ print (f" - Test URL: http://localhost:{ port } /mcp/resource?uri=nixos://package/python" )
337+ print (f" - Direct FastAPI: http://localhost:{ port } /packages/python" )
338+
339+ print (f"\n Starting NixMCP server on port { port } ..." )
340+ print (f"Access FastAPI docs at http://localhost:{ port } /docs" )
341+ print (f"Access MCP endpoints at http://localhost:{ port } /mcp" )
342+
343+ uvicorn .run (
344+ "server:app" ,
345+ host = "0.0.0.0" ,
346+ port = port ,
347+ log_level = "debug" ,
348+ reload = args .reload
349+ )
0 commit comments