1717
1818from mcpm .clients .client_registry import ClientRegistry
1919from mcpm .router .share import Tunnel
20- from mcpm .utils .config import ConfigManager
20+ from mcpm .utils .config import MCPM_AUTH_HEADER , MCPM_PROFILE_HEADER , ConfigManager
2121from mcpm .utils .platform import get_log_directory , get_pid_directory
2222
2323logging .basicConfig (level = logging .INFO , format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" )
@@ -116,8 +116,9 @@ def router():
116116
117117@router .command (name = "on" )
118118@click .help_option ("-h" , "--help" )
119+ @click .option ("--sse" , "-s" , is_flag = True , help = "Use SSE endpoint(deprecated)" )
119120@click .option ("--verbose" , "-v" , is_flag = True , help = "Enable verbose output" )
120- def start_router (verbose ):
121+ def start_router (sse , verbose ):
121122 """Start MCPRouter as a daemon process.
122123
123124 Example:
@@ -140,12 +141,17 @@ def start_router(verbose):
140141 auth_enabled = config .get ("auth_enabled" , False )
141142 api_key = config .get ("api_key" )
142143
144+ if sse :
145+ app_path = "mcpm.router.sse_app:app"
146+ else :
147+ app_path = "mcpm.router.app:app"
148+
143149 # prepare uvicorn command
144150 uvicorn_cmd = [
145151 sys .executable ,
146152 "-m" ,
147153 "uvicorn" ,
148- "mcpm.router.app:app" ,
154+ app_path ,
149155 "--host" ,
150156 host ,
151157 "--port" ,
@@ -197,17 +203,29 @@ def start_router(verbose):
197203
198204 api_key = api_key if auth_enabled else None
199205
200- # Show URL with or without authentication based on API key availability
201- if api_key :
202- # Show authenticated URL
203- console .print (f"SSE Server URL: [green]http://{ host } :{ port } /sse?s={ api_key } [/]" )
204- console .print ("\n [bold cyan]To use a specific profile with authentication:[/]" )
205- console .print (f"[green]http://{ host } :{ port } /sse?s={ api_key } &profile=<profile_name>[/]" )
206+ if sse :
207+ console .print ("\n [bold yellow]SSE router is not recommended[/]" )
208+ console .print (f"Remote Server URL: [green]http://{ host } :{ port } /sse[/]" )
209+ if api_key :
210+ console .print ("\n [bold cyan]To use a specific profile with authentication:[/]" )
211+ console .print (
212+ f"Remote Server URL with authentication: [green]http://{ host } :{ port } /sse?s={ api_key } &profile=<profile_name>[/]"
213+ )
214+ else :
215+ console .print ("\n [bold cyan]To use a specific profile:[/]" )
216+ console .print (
217+ f"Remote Server URL with authentication: [green]http://{ host } :{ port } /sse?profile=<profile_name>[/]"
218+ )
206219 else :
207- # Show URL without authentication
208- console .print (f"SSE Server URL: [green]http://{ host } :{ port } /sse[/]" )
209- console .print ("\n [bold cyan]To use a specific profile:[/]" )
210- console .print (f"[green]http://{ host } :{ port } /sse?profile=<profile_name>[/]" )
220+ console .print (f"Remote Server URL: [green]http://{ host } :{ port } /mcp/[/]" )
221+ if api_key :
222+ console .print ("\n [bold cyan]To use a specific profile with authentication:[/]" )
223+ console .print ("[bold]Request headers:[/]" )
224+ console .print (f"{ MCPM_AUTH_HEADER } : { api_key } " )
225+ else :
226+ console .print ("\n [bold cyan]To use a specific profile:[/]" )
227+ console .print ("[bold]Request headers:[/]" )
228+ console .print (f"{ MCPM_PROFILE_HEADER } : <profile_name>" )
211229
212230 console .print ("\n [yellow]Use 'mcpm router off' to stop the router.[/]" )
213231
@@ -432,16 +450,18 @@ def share(address, profile, http):
432450 share_url = tunnel .start_tunnel ()
433451 share_pid = tunnel .proc .pid if tunnel .proc else None
434452 api_key = config .get ("api_key" ) if config .get ("auth_enabled" ) else None
435- share_url = share_url + "/sse"
453+
454+ share_url = share_url + "/mcp/"
436455 # save share pid and link to config
437456 config_manager .save_share_config (share_url , share_pid )
438457 profile = profile or "<your_profile>"
439458
440459 # print share link
441460 console .print (f"[bold green]Router is sharing at { share_url } [/]" )
442- console .print (
443- f"[green]Your profile can be accessed with the url { share_url } ?{ f's={ api_key } &' if api_key else '' } profile={ profile } [/]\n "
444- )
461+ console .print (f"[green]Your profile can be accessed with the url { share_url } [/]\n " )
462+ if api_key :
463+ console .print (f"[green]Authorize with header { MCPM_AUTH_HEADER } : { api_key } [/]" )
464+ console .print (f"[green]Specify profile with header { MCPM_PROFILE_HEADER } : { profile } [/]" )
445465 console .print (
446466 "[bold yellow]Be careful about the share link, it will be exposed to the public. Make sure to share to trusted users only.[/]"
447467 )
0 commit comments