-
Notifications
You must be signed in to change notification settings - Fork 781
Refactor CLI: dev umbrella, default main.py, smart server defaults, clearer init #469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
f553b98
2139f84
1a37972
749dbaf
e5623ef
d983c65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,8 @@ | |||||||||||||
| attach_stdio_servers, | ||||||||||||||
| attach_url_servers, | ||||||||||||||
| load_user_app, | ||||||||||||||
| detect_default_script, | ||||||||||||||
| select_servers_from_config, | ||||||||||||||
| ) | ||||||||||||||
| from mcp_agent.cli.utils.url_parser import generate_server_configs, parse_server_urls | ||||||||||||||
| from mcp_agent.workflows.factory import create_llm | ||||||||||||||
|
|
@@ -99,14 +101,17 @@ def chat( | |||||||||||||
| npx: Optional[str] = typer.Option(None, "--npx"), | ||||||||||||||
| uvx: Optional[str] = typer.Option(None, "--uvx"), | ||||||||||||||
| stdio: Optional[str] = typer.Option(None, "--stdio"), | ||||||||||||||
| script: Optional[Path] = typer.Option(Path("agent.py"), "--script"), | ||||||||||||||
| script: Optional[Path] = typer.Option(None, "--script"), | ||||||||||||||
| list_servers: bool = typer.Option(False, "--list-servers"), | ||||||||||||||
| list_tools: bool = typer.Option(False, "--list-tools"), | ||||||||||||||
| list_resources: bool = typer.Option(False, "--list-resources"), | ||||||||||||||
| server: Optional[str] = typer.Option( | ||||||||||||||
| None, "--server", help="Filter to a single server" | ||||||||||||||
| ), | ||||||||||||||
| ) -> None: | ||||||||||||||
| # Resolve script with auto-detection | ||||||||||||||
| script = detect_default_script(script) | ||||||||||||||
|
|
||||||||||||||
| server_list = servers_csv.split(",") if servers_csv else None | ||||||||||||||
|
|
||||||||||||||
| url_servers = None | ||||||||||||||
|
|
@@ -140,12 +145,17 @@ def chat( | |||||||||||||
| else: | ||||||||||||||
| server_list.extend(list(stdio_servers.keys())) | ||||||||||||||
|
|
||||||||||||||
| # Smart defaults for servers | ||||||||||||||
| resolved_server_list = select_servers_from_config( | ||||||||||||||
| servers_csv, url_servers, stdio_servers | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
| # Listing mode (no generation) | ||||||||||||||
| if list_servers or list_tools or list_resources: | ||||||||||||||
| try: | ||||||||||||||
|
|
||||||||||||||
| async def _list(): | ||||||||||||||
| app_obj = load_user_app(script or Path("agent.py")) | ||||||||||||||
| app_obj = load_user_app(script) | ||||||||||||||
| await app_obj.initialize() | ||||||||||||||
| attach_url_servers(app_obj, url_servers) | ||||||||||||||
| attach_stdio_servers(app_obj, stdio_servers) | ||||||||||||||
|
|
@@ -163,7 +173,7 @@ async def _list(): | |||||||||||||
| agent = Agent( | ||||||||||||||
| name="chat-lister", | ||||||||||||||
| instruction="You list tools and resources", | ||||||||||||||
| server_names=target_servers, | ||||||||||||||
| server_names=resolved_server_list or target_servers, | ||||||||||||||
| context=app_obj.context, | ||||||||||||||
| ) | ||||||||||||||
|
Comment on lines
+181
to
183
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Honor --server filter in Agent.server_names. If resolved_server_list is non-empty, it currently overrides a provided --server. Prefer the explicit filter. Apply: - server_names=resolved_server_list or target_servers,
+ server_names=([server] if server else (resolved_server_list or target_servers)),📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| async with agent: | ||||||||||||||
|
|
@@ -203,7 +213,7 @@ async def _list(): | |||||||||||||
| ): | ||||||||||||||
|
|
||||||||||||||
| async def _parallel_repl(): | ||||||||||||||
| app_obj = load_user_app(script or Path("agent.py")) | ||||||||||||||
| app_obj = load_user_app(script) | ||||||||||||||
| await app_obj.initialize() | ||||||||||||||
| attach_url_servers(app_obj, url_servers) | ||||||||||||||
| attach_stdio_servers(app_obj, stdio_servers) | ||||||||||||||
|
|
@@ -227,7 +237,7 @@ async def _parallel_repl(): | |||||||||||||
| provider = prov_guess | ||||||||||||||
| llm = create_llm( | ||||||||||||||
| agent_name=m, | ||||||||||||||
| server_names=server_list or [], | ||||||||||||||
| server_names=resolved_server_list or [], | ||||||||||||||
| provider=(provider or "openai"), | ||||||||||||||
| model=m, | ||||||||||||||
| context=app_obj.context, | ||||||||||||||
|
|
@@ -276,7 +286,9 @@ async def _parallel_repl(): | |||||||||||||
| ag = _Agent( | ||||||||||||||
| name="chat-lister", | ||||||||||||||
| instruction="list tools", | ||||||||||||||
| server_names=[srv] if srv else (server_list or []), | ||||||||||||||
| server_names=[srv] | ||||||||||||||
| if srv | ||||||||||||||
| else (resolved_server_list or []), | ||||||||||||||
| context=app_obj.context, | ||||||||||||||
| ) | ||||||||||||||
| async with ag: | ||||||||||||||
|
|
@@ -294,7 +306,9 @@ async def _parallel_repl(): | |||||||||||||
| ag = _Agent( | ||||||||||||||
| name="chat-lister", | ||||||||||||||
| instruction="list resources", | ||||||||||||||
| server_names=[srv] if srv else (server_list or []), | ||||||||||||||
| server_names=[srv] | ||||||||||||||
| if srv | ||||||||||||||
| else (resolved_server_list or []), | ||||||||||||||
| context=app_obj.context, | ||||||||||||||
| ) | ||||||||||||||
| async with ag: | ||||||||||||||
|
|
@@ -367,8 +381,8 @@ async def _gen(llm_instance): | |||||||||||||
| try: | ||||||||||||||
| out = asyncio.run( | ||||||||||||||
| _run_single_model( | ||||||||||||||
| script=script or Path("agent.py"), | ||||||||||||||
| servers=server_list, | ||||||||||||||
| script=script, | ||||||||||||||
| servers=resolved_server_list, | ||||||||||||||
| url_servers=url_servers, | ||||||||||||||
| stdio_servers=stdio_servers, | ||||||||||||||
| model=m, | ||||||||||||||
|
|
@@ -394,7 +408,7 @@ async def _gen(llm_instance): | |||||||||||||
| ): | ||||||||||||||
| # Interactive loop | ||||||||||||||
| async def _repl(): | ||||||||||||||
| app_obj = load_user_app(script or Path("agent.py")) | ||||||||||||||
| app_obj = load_user_app(script) | ||||||||||||||
| await app_obj.initialize() | ||||||||||||||
| attach_url_servers(app_obj, url_servers) | ||||||||||||||
| attach_stdio_servers(app_obj, stdio_servers) | ||||||||||||||
|
|
@@ -416,7 +430,7 @@ async def _repl(): | |||||||||||||
| provider = model_id.split(":", 1)[0] | ||||||||||||||
| llm = create_llm( | ||||||||||||||
| agent_name=(name or "chat"), | ||||||||||||||
| server_names=server_list or [], | ||||||||||||||
| server_names=resolved_server_list or [], | ||||||||||||||
| provider=(provider or "openai"), | ||||||||||||||
| model=model_id, | ||||||||||||||
| context=app_obj.context, | ||||||||||||||
|
|
@@ -476,7 +490,7 @@ async def _repl(): | |||||||||||||
| # Recreate LLM with new model | ||||||||||||||
| llm_local = create_llm( | ||||||||||||||
| agent_name=(name or "chat"), | ||||||||||||||
| server_names=server_list or [], | ||||||||||||||
| server_names=resolved_server_list or [], | ||||||||||||||
| provider=(prov or "openai"), | ||||||||||||||
| model=model_id, | ||||||||||||||
| context=app_obj.context, | ||||||||||||||
|
|
@@ -502,7 +516,9 @@ async def _repl(): | |||||||||||||
| ag = Agent( | ||||||||||||||
| name="chat-lister", | ||||||||||||||
| instruction="list tools", | ||||||||||||||
| server_names=[srv] if srv else (server_list or []), | ||||||||||||||
| server_names=[srv] | ||||||||||||||
| if srv | ||||||||||||||
| else (resolved_server_list or []), | ||||||||||||||
| context=app_obj.context, | ||||||||||||||
| ) | ||||||||||||||
| async with ag: | ||||||||||||||
|
|
@@ -521,7 +537,9 @@ async def _repl(): | |||||||||||||
| ag = Agent( | ||||||||||||||
| name="chat-lister", | ||||||||||||||
| instruction="list resources", | ||||||||||||||
| server_names=[srv] if srv else (server_list or []), | ||||||||||||||
| server_names=[srv] | ||||||||||||||
| if srv | ||||||||||||||
| else (resolved_server_list or []), | ||||||||||||||
| context=app_obj.context, | ||||||||||||||
| ) | ||||||||||||||
| async with ag: | ||||||||||||||
|
|
@@ -698,8 +716,8 @@ async def _repl(): | |||||||||||||
| else: | ||||||||||||||
| out = asyncio.run( | ||||||||||||||
| _run_single_model( | ||||||||||||||
| script=script or Path("agent.py"), | ||||||||||||||
| servers=server_list, | ||||||||||||||
| script=script, | ||||||||||||||
| servers=resolved_server_list, | ||||||||||||||
| url_servers=url_servers, | ||||||||||||||
| stdio_servers=stdio_servers, | ||||||||||||||
| model=model, | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -100,6 +100,7 @@ def init( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print(f"Template: [cyan]{template}[/cyan] - {templates[template]}\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| files_created = [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| entry_script_name: str | None = None | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Always create config files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config_path = dir / "mcp_agent.config.yaml" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -122,15 +123,35 @@ def init( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Create template-specific files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if template == "basic": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| agent_path = dir / "agent.py" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Determine entry script name and handle existing files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| script_name = "main.py" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| script_path = dir / script_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| agent_content = _load_template("basic_agent.py") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if agent_content and _write(agent_path, agent_content, force): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| files_created.append("agent.py") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Make executable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| agent_path.chmod(agent_path.stat().st_mode | 0o111) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| except Exception: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if agent_content: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| write_force_flag = force | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if script_path.exists() and not force: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if Confirm.ask(f"{script_path} exists. Overwrite?", default=False): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| write_force_flag = True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Ask for an alternate filename and ensure it ends with .py | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| alt_name = Prompt.ask( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Enter a filename to save the agent", default="agent.py" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not alt_name.endswith(".py"): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| alt_name += ".py" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| script_name = alt_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| script_path = dir / script_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # keep write_force_flag as-is to allow overwrite prompt if needed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if _write(script_path, agent_content, write_force_flag): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| files_created.append(script_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| entry_script_name = script_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Make executable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| script_path.chmod(script_path.stat().st_mode | 0o111) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| except Exception: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif template == "server": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+126
to
156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Harden alt filename handling to prevent path escapes. A user can enter an absolute path (e.g., “/tmp/x.py”) or include “../”, which would write outside the target dir. Constrain to a basename and ensure the resolved path remains within - alt_name = Prompt.ask(
- "Enter a filename to save the agent", default="agent.py"
- )
- if not alt_name.endswith(".py"):
- alt_name += ".py"
- script_name = alt_name
- script_path = dir / script_name
+ alt_name = Prompt.ask(
+ "Enter a filename to save the agent", default="agent.py"
+ )
+ if not alt_name.endswith(".py"):
+ alt_name += ".py"
+ base_dir = dir.resolve()
+ # Keep only basename and ensure path stays within target dir
+ script_name = Path(alt_name).name
+ candidate_path = (base_dir / script_name).resolve()
+ try:
+ candidate_path.relative_to(base_dir)
+ except ValueError:
+ console.print("[red]Filename must be within the target directory[/red]")
+ raise typer.Exit(1)
+ script_path = candidate_path
+ if script_path.exists() and script_path.is_dir():
+ console.print(f"[red]{script_path} is a directory; choose a .py filename[/red]")
+ raise typer.Exit(1)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| server_path = dir / "server.py" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -185,20 +206,29 @@ def init( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print("2. Review and customize [cyan]mcp_agent.config.yaml[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if template == "basic": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print("3. Run your agent: [cyan]python agent.py[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print(" Or use: [cyan]mcp-agent dev --script agent.py[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print(" Or chat: [cyan]mcp-agent chat[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_file = entry_script_name or "main.py" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print(f"3. Run your agent: [cyan]uv run {run_file}[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| f" Or use: [cyan]mcp-agent dev start --script {run_file}[/cyan]" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| f" Or serve: [cyan]mcp-agent dev serve --script {run_file}[/cyan]" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print(" Or chat: [cyan]mcp-agent dev chat[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "4. Edit config: [cyan]mcp-agent config edit[/cyan] (then rerun)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif template == "server": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print("3. Run the server: [cyan]python server.py[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print("3. Run the server: [cyan]uv run server.py[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| " Or serve: [cyan]mcp-agent serve --script server.py[/cyan]" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainCommand mismatch with CLI reorg: use Runtime commands moved under - console.print(
- " Or serve: [cyan]mcp-agent serve --script server.py[/cyan]"
- )
+ console.print(
+ " Or serve: [cyan]mcp-agent dev serve --script server.py[/cyan]"
+ )Search for other stale references: 🏁 Script executed: #!/bin/bash
rg -nP -C1 '\bmcp-agent\s+serve\b'Length of output: 1811 Replace remaining Runtime commands were moved under the
- console.print(
- " Or serve: [cyan]mcp-agent serve --script server.py[/cyan]"
- )
+ console.print(
+ " Or serve: [cyan]mcp-agent dev serve --script server.py[/cyan]"
+ )
📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif template == "token": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print("3. Run the example: [cyan]python token_example.py[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print("3. Run the example: [cyan]uv run token_example.py[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print(" Watch token usage in real-time!") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif template == "factory": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print("3. Customize agents in [cyan]agents.yaml[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print("4. Run the factory: [cyan]python factory.py[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print("4. Run the factory: [cyan]uv run factory.py[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif template == "minimal": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print("3. Create your agent script") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.print(" See examples: [cyan]mcp-agent quickstart[/cyan]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart server defaults wired — good. One functional inconsistency remains.
/prompt still uses server_list instead of resolved_server_list, so dynamic/configured servers are ignored there.
📝 Committable suggestion
🤖 Prompt for AI Agents
💡 Verification agent
🧩 Analysis chain
Quick sweep for any other legacy
server_listusages.Run this to ensure no other call paths still rely on server_list for server_names.
🏁 Script executed:
Length of output: 1248
Replace remaining legacy
server_listusages withresolved_server_list.rg found three call sites still passing
server_list; update them to pass the resolved list (or callselect_servers_from_configin that scope) and preserveor []defaults where appropriate.🤖 Prompt for AI Agents