Skip to main content

Test Spring MCP Server with VS Code

Overview

This page shows how to connect VS Code to the Spring sample MCP server so you can test source-generated MCP tools (for example, open_account, deposit_funds, and projection read tools) from chat.

Spring exposes MCP in Spring.Gateway with:

  • builder.Services.AddMcpServer().WithHttpTransport().WithGeneratedMcpTools().WithTools<SpringGatewayPingMcpTools>();
  • app.MapMcp("/mcp"); (mapped in Development environment only)

Reference: Spring.Gateway Program.cs

Before You Begin

  • VS Code with GitHub Copilot Chat enabled
  • This repository checked out locally
  • .NET SDK installed

Step 1: Start Spring Locally

From the repository root, run:

pwsh ./run-spring.ps1

This script builds samples.slnx and starts samples/Spring/Spring.AppHost/Spring.AppHost.csproj, which launches the Spring services for local development.

When Spring is running from run-spring.ps1, Spring uses these default endpoints from launch settings:

  • Spring.Gateway HTTP: http://localhost:5101
  • Spring.Gateway HTTPS: https://localhost:7101
  • Spring.Runtime HTTP health: http://localhost:5300/health
  • Aspire dashboard: https://localhost:17272

For MCP over HTTP, use http://localhost:5101/mcp.

Step 2: Add the MCP Server to VS Code

Open (or create) .vscode/mcp.json in the workspace root and add a server entry:

{
"servers": {
"springBank": {
"type": "http",
"url": "http://localhost:5101/mcp"
}
}
}

Notes:

  • Keep the server name in camelCase (springBank).
  • If you change launch settings, update this URL to match your Spring.Gateway HTTP port.
  • MCP client behavior and UI workflows can change across VS Code releases; use the official MCP documentation linked in References.

Verify

  1. Open Chat in VS Code.
  2. Open the tools picker and ensure tools from springBank are enabled.
  3. Ask a prompt that should use Spring tools, for example:
Use the springBank tools to open a bank account for Ada Lovelace with an initial deposit of 100.
  1. Ask a follow-up read prompt, for example:
Use the springBank tools to fetch the balance projection for that account.
  1. Ask a quick connectivity prompt for the manually registered ping tool:
Use the springBank tools to call spring_gateway_ping.

Troubleshooting

  • Server not listed or not starting: verify .vscode/mcp.json is valid JSON and the URL is reachable.
  • No tools discovered: confirm Spring is running and that /mcp is mapped in Spring.Gateway.
  • Tools mismatch after code changes: restart Spring with pwsh ./run-spring.ps1 so regenerated tools are loaded.

Summary

Spring exposes MCP tools at http://localhost:5101/mcp in Development, with both generated domain tools and a manual spring_gateway_ping tool.

Next Steps

References