Video summary
Can MCP tools use Spring HTTP interfaces?
Main summary
Key takeaways
Summary
Dan Vega demonstrates how to use Spring HTTP interfaces inside an MCP server. The central idea is that an MCP tool can call another service through an injected HTTP client interface instead of implementing its own REST client.
Main Ideas
- HTTP interfaces describe an API as a Java interface. An interface annotated with
@HttpExchangedefines the API path, while method annotations such as@GetExchangedescribe operations. Spring generates the implementation at runtime. - Spring Boot 4 and Spring Framework 7 reduce setup work. Previously, developers typically created a
RestClient, anHttpServiceProxyFactory, and a proxy for each interface.@ImportHttpServicescan now register HTTP services more directly and supports grouping and customization. - The approach works in an MCP server just as it does elsewhere in Spring. An MCP tool can receive the HTTP client through constructor injection and use it to call a separate API.
- The pattern can help with CRUD integrations and prototypes. Defining client contracts in advance can reduce repetitive code and help teams or coding agents get an integration running sooner. It is optional; developers can still implement REST calls directly.
- HTTP interfaces may replace some OpenFeign use cases. Projects that use OpenFeign only for this kind of client may be able to avoid an additional dependency by using Spring’s built-in functionality.
Demonstration Methodology
-
Run a separate To-Dos API.
- The example API provides basic CRUD operations: list tasks, find one by ID, create, update, and delete.
- It runs on port
8080.
-
Set up the MCP server.
- The server uses Spring AI’s MCP Server Web MVC starter.
- The presenter adds the required
RestClientsupport for HTTP interfaces, noting that it is not included in the standard MVC setup he is using.
-
Configure the client’s base URL.
- Put the To-Dos API’s base URL in
application.yamlrather than hard-coding a full URL in the client or tool code.
- Put the To-Dos API’s base URL in
-
Declare a
TodoClientHTTP interface.- Use
@HttpExchangefor the API path and method-specific exchange annotations for operations. - The interface defines the supported calls; Spring supplies the implementation at runtime.
- Use
-
Register and optionally customize the interface.
- Use
@ImportHttpServicesto register the client. - Optionally organize clients into named groups to give different clients different configurations.
- In the example, a group-specific configuration converts a
404response into a customTodoNotFoundExceptionwith a clearer message.
- Use
-
Expose an MCP tool using constructor injection.
- Make a tool class a Spring component and inject
TodoClientthrough its constructor. - The example’s “to-do list” tool calls the client’s “find all” operation and returns the tasks, including their IDs, names, and completion status.
- Make a tool class a Spring component and inject
-
Test the MCP server with MCP Inspector.
- Run the MCP server on port
8081and connect to its/mcpendpoint using streaming HTTP. - Use the Inspector to view and run the tool, confirming that it returns data from the To-Dos API.
- Run the MCP server on port
The broader lesson is that adding AI or an MCP server does not require abandoning established Spring practices. Existing Spring clients, dependency injection, and configuration can remain part of the integration.
Speakers and Sources Featured
- Dan Vega — Presenter and tutorial host.
- Nate Schutta — Mentioned as Vega’s co-presenter at Porto Tech Hub.
- Dr. Venkat Subramaniam — Mentioned as a speaker at JFall.
- Adam Bean — Mentioned in connection with the JFall program.
- An unnamed JFall attendee — Credited with asking whether HTTP interfaces can be used in MCP servers.
- Spring HTTP interfaces, Spring Framework, and Spring Boot — The technologies being explained.
- Spring AI MCP Server and MCP Inspector — Used in the demonstration.
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.