Menu

Integrations / Frameworks & SDKs

Spring AI

MillionShort search for a Spring AI ChatClient, through the MCP client starter.

Copy as MarkdownOpen in ChatGPT (opens in a new tab)Open in Claude (opens in a new tab)

MCPJavaNothing of ours to installWorks with no keyChecked 2026-11-19

Spring AI's MCP client Boot starter connects to the servers named in your application properties, discovers their tools and exposes them as a SyncMcpToolCallbackProvider bean. Add the MillionShort MCP server as a streamable HTTP connection, add the key with a request customizer, and pass the provider to a ChatClient; the model then gets the server's tools: search, get_domain_info, list_sources and the tools of the other endpoints, such as extract, places, map and crawl (the MCP page lists them all).

1Install

Add the MCP client starter (its version comes from the Spring AI BOM; 2.0.2 is current) next to the starter for your model:

Example
Text
<dependency>
  <groupId>org.springframework.ai</groupId>
  <artifactId>spring-ai-starter-mcp-client</artifactId>
</dependency>

This starter uses the JDK HttpClient. Spring recommends the WebFlux starter, spring-ai-starter-mcp-client-webflux, for production; its headers are set differently (see Settings below). Get a MillionShort key in the dashboard.

2Connect the server

Name the connection under streamable-http. Spring builds the address from url and endpoint (default /mcp); the endpoint is an absolute path, so it replaces the path of url, and the full address works as url:

application.yml
spring:
  ai:
    mcp:
      client:
        streamable-http:
          connections:
            millionshort:
              url: https://mcp.millionshort.com/mcp
              endpoint: /mcp

The connection properties carry no headers. With the spring-ai-starter-mcp-client starter, the key goes in a McpSyncHttpClientRequestCustomizer bean, which sees every request the HttpClient transports send, so it checks the address before adding the key. Without a key, leave the bean out.

Java
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpClientRequestCustomizer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
class MillionShortMcpConfig {

    @Bean
    McpSyncHttpClientRequestCustomizer millionshortAuth(@Value("${MILLIONSHORT_API_KEY}") String apiKey) {
        return (builder, method, endpoint, body, context) -> {
            if ("https://mcp.millionshort.com/mcp".equals(endpoint.toString())) {
                builder.header("Authorization", "Bearer " + apiKey);
            }
        };
    }
}

3Give the tools to a ChatClient

Spring does not add MCP tools to a ChatClient by itself. Inject the provider and pass it as default tools, or per call with .tools(mcpTools):

Java
@Autowired SyncMcpToolCallbackProvider mcpTools;

ChatClient chatClient = ChatClient.builder(chatModel)
    .defaultTools(mcpTools)
    .build();

String answer = chatClient.prompt()
    .user("Find independent blogs about home espresso, without the 1,000 most popular sites.")
    .call()
    .content();

4Check it works

Start the application: the starter connects to millionshort at startup. mcpTools.getToolCallbacks() should hold search, get_domain_info, list_sources and the tools of the other endpoints (the MCP page lists them); with no key, fewer, search and list_sources among them. Spring adds a prefix to a tool's name only when two connections have tools of the same name. Then ask the question in step 3: the answer should cite pages. If the model answers from memory, say when to search in its system prompt:

Use the MillionShort search tool for anything recent, niche, or that needs a source. To reach lesser-known sites, set remove_top_sites (for example 1000). Cite the URLs it returns.

MCP configuration

The same address for every client: https://mcp.millionshort.com/mcp, streamable HTTP.

ModeHowWhat the agent gets
API keySend Authorization: Bearer ms-YOUR_API_KEYEvery tool, at your plan's limits; calls use your credits
No keySend no Authorization headersearch, list_sources and a few more; one source and up to 5 results a search, 10 free searches a day

Tools

ToolWhat it doesWithout a keyCost
searchSearches the web and the specialist sources, with the popularity, domain, page-type, topic, site and date filtersYes: one source, up to 5 results1 credit per source searched, first 10 results
get_domain_infoPopularity and risk for up to 25 sitesNo1 credit
list_sourcesThe sources, page types and topics search acceptsYes: source namesFree
The tools of the other endpointsextract, map, crawl, places and more: the MCP page lists themA few, such as placesWhat the API call behind each costs

Settings

VariableMeaning
MILLIONSHORT_API_KEYYour key, read by the customizer bean as a Spring property. Leave the bean out for the no-key mode

With the WebFlux starter, Spring's docs say to configure a WebClient.Builder bean (for example with an ExchangeFilterFunction) instead of the customizer; they show it for OAuth only, so we do not give a sample. The client is application-scoped: one MCP session per connection, shared by every request, which is fine for our stateless server.

Costs and limits

A tool call costs what the API call behind it costs: 1 credit per source searched for the first 10 results, 1 credit for a domain lookup, nothing for the list of sources, the price of the endpoint for the other tools, and nothing at all in the no-key mode. An agent that loops can make many calls: give it a step limit, and ask for fewer results when a few will do. Credits and limits has the numbers.

When it fails

What you seeWhyFix
The server does not connect, or no tools are listedThe address or the transport is not the one the server speaksUse exactly https://mcp.millionshort.com/mcp and the streamable HTTP transport (often called http), not SSE
401 or "unauthorized"The key is wrong, or it was sent without Bearer Send Authorization: Bearer ms-..., or leave the header out to use the no-key mode
"10 free searches a day without a key"The no-key mode's daily searches are used upAdd a key: it is free in the dashboard
INSUFFICIENT_CREDITSThe plan's credits are used upStop and add credits; retrying does not help
The agent answers from memory, or uses another searchNothing told it when to use this oneTurn off its own search where it can be (this page says how), and add the line for its instructions
The model never sees the toolsThe provider was not passed to the ChatClientPass mcpTools with .defaultTools(...) or .tools(...)
Requests go out with no keyThe customizer is for the HttpClient starter, and you use the WebFlux oneSet the header on the WebClient.Builder instead

This page as Markdown ยท llms.txt