Video summary

Can MCP tools use Spring HTTP interfaces?

Main summary

Key takeaways

Educational

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 @HttpExchange defines the API path, while method annotations such as @GetExchange describe operations. Spring generates the implementation at runtime.
  • Spring Boot 4 and Spring Framework 7 reduce setup work. Previously, developers typically created a RestClient, an HttpServiceProxyFactory, and a proxy for each interface. @ImportHttpServices can 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

  1. 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.
  2. Set up the MCP server.

    • The server uses Spring AI’s MCP Server Web MVC starter.
    • The presenter adds the required RestClient support for HTTP interfaces, noting that it is not included in the standard MVC setup he is using.
  3. Configure the client’s base URL.

    • Put the To-Dos API’s base URL in application.yaml rather than hard-coding a full URL in the client or tool code.
  4. Declare a TodoClient HTTP interface.

    • Use @HttpExchange for the API path and method-specific exchange annotations for operations.
    • The interface defines the supported calls; Spring supplies the implementation at runtime.
  5. Register and optionally customize the interface.

    • Use @ImportHttpServices to register the client.
    • Optionally organize clients into named groups to give different clients different configurations.
    • In the example, a group-specific configuration converts a 404 response into a custom TodoNotFoundException with a clearer message.
  6. Expose an MCP tool using constructor injection.

    • Make a tool class a Spring component and inject TodoClient through 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.
  7. Test the MCP server with MCP Inspector.

    • Run the MCP server on port 8081 and connect to its /mcp endpoint using streaming HTTP.
    • Use the Inspector to view and run the tool, confirming that it returns data from the To-Dos API.

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.

Pro

Translate summary in another language

Pro

Ask questions to this video

Chat for follow-up questions, clarifications, and source-backed answers.

Coming soon

Share this summary

Original video