When scaffolding a Python/FastMCP (HTTP transport) MCP server project with the
toolkit and pressing F5 ("Debug in Agent Builder"), the client tries to connect to
http://localhost:/mcp before the Python server has finished starting, resulting in:
Error when calling MCP Server <name>: SSE error: TypeError: fetch failed:
connect ECONNREFUSED 127.0.0.1:3001
Root cause:
In the generated .vscode/tasks.json, the "Open Agent Builder" and "Start MCP Inspector"
tasks use "dependsOn": ["Start MCP Server"] WITHOUT "dependsOrder": "sequence".
By default VS Code runs dependent tasks in parallel, so the client task fires at the
same time as the server task instead of waiting for it to finish starting — it loses
the race almost every time.
Steps to reproduce:
- Scaffold a new MCP server project (Python, HTTP transport) with the toolkit.
- Open the generated .vscode/tasks.json and note that "Open Agent Builder" depends
on "Start MCP Server" with no dependsOrder set.
- Open Run and Debug, select "Debug in Agent Builder", press F5.
- Observe ECONNREFUSED in the toolkit's output log, even though the Python server
actually starts successfully a couple seconds later.
Expected behavior:
The client should only attempt to connect once the MCP server is actually listening.
Suggested fix:
Add "dependsOrder": "sequence" to both tasks in the generated template. Note that
even with this alone, the background problemMatcher (matching "Application startup
complete") doesn't always get detected in time due to output buffering, so a more
robust fix is to insert an intermediate task with a short fixed delay (e.g.
timeout /t 5 /nobreak on Windows) between the server task and the client task.
Environment:
- OS: Windows 11
- VS Code version:
- Extension version:
Si usás la Opción A (Help: Report Issue), te deja editar el cuerpo del issue antes de enviarlo — pegá este texto en la
descripción y dejá que VS Code complete el resto.
Sources:
When scaffolding a Python/FastMCP (HTTP transport) MCP server project with the
toolkit and pressing F5 ("Debug in Agent Builder"), the client tries to connect to
http://localhost:/mcp before the Python server has finished starting, resulting in:
Root cause:
In the generated .vscode/tasks.json, the "Open Agent Builder" and "Start MCP Inspector"
tasks use "dependsOn": ["Start MCP Server"] WITHOUT "dependsOrder": "sequence".
By default VS Code runs dependent tasks in parallel, so the client task fires at the
same time as the server task instead of waiting for it to finish starting — it loses
the race almost every time.
Steps to reproduce:
on "Start MCP Server" with no dependsOrder set.
actually starts successfully a couple seconds later.
Expected behavior:
The client should only attempt to connect once the MCP server is actually listening.
Suggested fix:
Add "dependsOrder": "sequence" to both tasks in the generated template. Note that
even with this alone, the background problemMatcher (matching "Application startup
complete") doesn't always get detected in time due to output buffering, so a more
robust fix is to insert an intermediate task with a short fixed delay (e.g.
timeout /t 5 /nobreakon Windows) between the server task and the client task.Environment:
Si usás la Opción A (Help: Report Issue), te deja editar el cuerpo del issue antes de enviarlo — pegá este texto en la
descripción y dejá que VS Code complete el resto.
Sources:
(https://marketplace.visualstudio.com/items?itemName=ms-windows-ai-studio.windows-ai-studio)