Connect VS Code to MCP Gateway
Visual Studio Code can connect to the AISIX MCP endpoint as a remote Streamable HTTP client. It sends an AISIX caller API key, discovers only the tools that key may use, and invokes those tools through the gateway without receiving upstream server credentials.
VS Code remains responsible for selecting a model, deciding when to request a tool, obtaining any required approval, and presenting the result. This connection sends MCP tool traffic through AISIX; it does not route model requests through the gateway. Where VS Code supports a compatible model override, configure that path separately if model traffic should also use AISIX.
This guide connects VS Code to the aggregated /mcp endpoint. You can continue from Set Up MCP Gateway, which grants the caller only everything__echo, or use an existing AISIX environment and a safe tool the caller may access.
Prerequisites
Before starting, prepare the following:
- Either complete Set Up MCP Gateway and retain
AISIX_PROXYandAISIX_MCP_KEY, or obtain an AISIX proxy origin and caller API key from the team that operates the gateway. For an existing environment, export them with those variable names and choose one safe permitted tool for verification. - Install Visual Studio Code with an agent-capable chat provider configured.
- Make sure VS Code can reach the AISIX proxy URL. VS Code on the gateway host can use the quickstart address; a remote development environment needs an address it can reach.
The example uses workspace configuration and a protected input, so the connection can be reviewed with the project without committing the caller API key.
Configure the Connection
Create .vscode/mcp.json in the workspace. Replace the example URL with $AISIX_PROXY/mcp:
{
"inputs": [
{
"type": "promptString",
"id": "aisix-mcp-key",
"description": "AISIX caller API key",
"password": true
}
],
"servers": {
"aisix": {
"type": "http",
"url": "https://gateway.example.com/mcp",
"headers": {
"Authorization": "Bearer ${input:aisix-mcp-key}"
}
}
}
}
This configuration applies to chat running in the local VS Code extension host. VS Code does not forward servers that require interactive inputs such as ${input:aisix-mcp-key} to Agent Host sessions. For an Agent Host session, use its portable workspace .mcp.json or user-level ~/.copilot/mcp-config.json path and a supported non-interactive secret source.
Open the Command Palette and run MCP: List Servers. Select aisix, then select Start Server. If VS Code asks whether you trust the workspace or server configuration, review the file before approving it. When prompted, enter the caller API key value stored in AISIX_MCP_KEY, not the variable name. VS Code stores the protected input separately from the workspace file.
Open the chat tool picker with Configure Tools and confirm that the selected permitted tool appears under the AISIX server. For the Everything fixture, only everything__echo should appear, and the MCP output log should report that one tool was discovered.
Verify a Tool Call
The prompt below uses the Everything fixture from the setup guide. For an existing MCP server, substitute a permitted tool name, valid arguments, and an expected result. In VS Code agent chat, ask it to use the exact tool instead of relying on automatic tool selection:
Use the MCP tool everything__echo with the message "hello through AISIX". Return the tool result exactly.
Review and approve the invocation if VS Code requests confirmation. With the Everything fixture, the result should be:
Echo: hello through AISIX
Confirm the complete path:
- VS Code shows the permitted tool and does not show tools excluded by the caller's effective grant. For the fixture, only
everything__echoshould appear. - AISIX MCP observability records a successful
tools/callfor the expected caller API key and server. - VS Code displays the tool result returned through AISIX.
Tool discovery proves that the connection and caller grant work. It does not prove that the model will select a tool or that VS Code's approval policy permits execution, so retain the explicit tool-call test.
Troubleshoot VS Code
| Symptom | Check |
|---|---|
| VS Code does not start the server | Trust the intended workspace, run MCP: List Servers, and start aisix. Use Show Output to inspect the MCP connection log. |
VS Code returns 401 | Confirm the protected input contains the AISIX caller API key, not an upstream MCP credential. |
| The connection succeeds but no tools appear | Follow Troubleshoot Tool Access to check the server and effective grant. After changing the grant, run MCP: Reset Cached Tools. |
| The tool appears but the agent does not call it | Name the selected tool explicitly, enable it with Configure Tools, and review the tool-approval policy. For the fixture, select everything__echo. |
| Agent Host cannot use the server | Interactive ${input:...} values are not forwarded to Agent Host. Use its portable MCP configuration and a non-interactive secret source. |
Next Steps
- Client Authentication: use gateway API keys, OAuth sign-in, or anonymous access for suitable trusted networks.
- Control Tool Access: grant exact tools, server patterns, or every registered tool.
- Observability: inspect MCP calls by caller, server, tool, and outcome.