Commons Attribution 4.0 International License. 6 MCP Protocol (stdio) MCP Protocol (stdio) MCP Protocol (Streamable HTTP, SSE) Local Data Source Your Computer Internet Remote Service A Remote Service B Web APIs Web APIs MCP Server MCP Server MCP Server Host with MCP Client (IDE, Claude Desktop, CLI, Java Application)
Commons Attribution 4.0 International License. 14 @Service public class QuoteService { @Tool(description = "Get Kai's favorite movie quote") public String getKaisFavoriteMovieQuote() { return "With great power comes great responsibility."; } }
Commons Attribution 4.0 International License. 15 @Tool(description = """ Get the top-ranked movies from IMDb. The API supports pagination using the pageNumber and pageSize parameters. The pageNumber starts at 0. The default pageSize is 10, with a maximum of 250.""") public String getTopRankedMovies(int pageNumber, int pageSize) { return restClient.get() .uri("/movies?page[number]={pageNumber}&page[size]={pageSize}", pageNumber, pageSize) .retrieve() .body(String.class); }
Commons Attribution 4.0 International License. 16 @Tool(description = """ Get the current weather forecast for a specific latitude and longitude. Units can be 'metric' or 'imperial’; the default is 'metric'. """) public String getWeatherForecastByLocation( double latitude, double longitude, String units) { return restClient.get() .uri("/current?latitude={latitude}" + "&longitude={longitude}&units={units}", latitude, longitude, units) .retrieve() .body(String.class); }