<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Varun Kancharla on Medium]]></title>
        <description><![CDATA[Stories by Varun Kancharla on Medium]]></description>
        <link>https://medium.com/@kancharla.varunkumar?source=rss-987c4475d2d7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ZqwmVyfvCUjUQWDf</url>
            <title>Stories by Varun Kancharla on Medium</title>
            <link>https://medium.com/@kancharla.varunkumar?source=rss-987c4475d2d7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 11:41:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kancharla.varunkumar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Documentation MCP Server with Spring AI, Apache Nutch, and Solr]]></title>
            <link>https://medium.com/@kancharla.varunkumar/building-a-documentation-mcp-server-with-spring-ai-apache-nutch-and-solr-66bb51dba944?source=rss-987c4475d2d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/66bb51dba944</guid>
            <category><![CDATA[spring-ai]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[apache-solr]]></category>
            <category><![CDATA[apache-nutch]]></category>
            <category><![CDATA[mcps]]></category>
            <dc:creator><![CDATA[Varun Kancharla]]></dc:creator>
            <pubDate>Thu, 13 Aug 2026 11:09:54 GMT</pubDate>
            <atom:updated>2026-08-13T11:09:54.392Z</atom:updated>
            <content:encoded><![CDATA[<p>A step-by-step guide to crawling documentation with Nutch, indexing it in Solr, and exposing it to Claude via a custom MCP server.</p><p>AI assistants are becoming increasingly useful for developers, but there is still a fundamental problem: <strong>how do we make an AI assistant work with the latest, domain-specific information?</strong></p><p>If you’re working with an internal product, the AI assistant simply doesn’t know anything about it. What we want instead is an assistant that can search the latest product documentation and answer questions based on the most up-to-date content — not whatever was in its training data.</p><p>In this guide, I’ll walk through crawling a website with <strong>Apache Nutch</strong>, indexing the content in <strong>Apache Solr</strong>, and exposing it to AI assistants like Claude through a custom-built <strong>MCP server</strong> using <strong>Spring AI</strong>.</p><p>I’ve used the <a href="https://www.keycloak.org/">Keycloak documentation</a> as the example here, mainly because I don’t want to expose my internal documentation to the public. 😄</p><h3>TL;DR — The Pipeline</h3><ul><li><strong>Apache Nutch</strong> crawls the target documentation site and extracts page content</li><li><strong>Apache Solr</strong> indexes that content so it can be queried efficiently</li><li>A <strong>Spring Boot MCP server</strong> exposes a @Tool-annotated method that queries Solr</li><li><strong>Claude Code</strong> connects to the MCP server and answers questions using live, indexed documentation instead of stale training data</li></ul><figure><img alt="High level architecture of Documentation MCP server using Spring AI, Apache Solr, and Apache Nutch." src="https://cdn-images-1.medium.com/max/1024/1*rY3Bgy1nzShaWQD2O_t7Pg.png" /></figure><h3>What You’ll Need</h3><ul><li><a href="https://nutch.apache.org/">Apache Nutch</a> 1.22 (source package, not binary — see note below)</li><li><a href="https://solr.apache.org/">Apache Solr</a> 8.11.4</li><li>Java + Maven</li><li><a href="https://ant.apache.org/">Apache Ant</a> (required only if building Nutch from source)</li><li>A <a href="https://spring.io/projects/spring-boot">Spring Boot</a> project with the spring-ai-starter-mcp-server dependency</li><li>Claude Code, to register and use the finished MCP server</li></ul><h4>1. Crawling Documentation with Apache Nutch</h4><p>Nutch is a highly extensible, scalable open-source web crawler. In this pipeline it’s responsible for:</p><ul><li>Discovering documentation URLs</li><li>Fetching web pages</li><li>Following links</li><li>Extracting page content</li><li>Maintaining crawl state</li><li>Sending the crawled content to Solr</li></ul><p>I recommend downloading the <strong>source package</strong> instead of the binary distribution. I used Nutch 1.22, the latest version at the time of writing, along with Solr 8.11.4.</p><p><strong>A note on authentication:</strong> while crawling an internal documentation site protected with Basic Authentication, I ran into an issue where the server returned an HTTP 200 instead of a 401 when Nutch first hit the seed URL. As a result, Nutch never sent credentials, because it was waiting for a 401 challenge that never came.</p><p>The fix was to enable preemptive authentication in the protocol-httpclient plugin, by adding the following line to Http#configureClient():</p><pre>client.getParams().setAuthenticationPreemptive(true);</pre><p>This makes Nutch send credentials on the initial request rather than waiting to be challenged.</p><h4><strong>Nutch Configuration</strong></h4><p>Configure ${NUTCH_HOME}/conf/nutch-site.xml — this is where you declare the crawler&#39;s agent name, the plugins to include, and authentication details.</p><pre>&lt;configuration&gt;<br>    &lt;property&gt;<br>        &lt;name&gt;http.agent.name&lt;/name&gt;<br>        &lt;value&gt;keycloak-docs-crawler&lt;/value&gt;<br>    &lt;/property&gt;<br>    &lt;property&gt;<br>        &lt;name&gt;plugin.includes&lt;/name&gt;<br>        &lt;value&gt;protocol-httpclient|urlfilter-regex|parse-(html|tika)|index-(basic|anchor)|indexer-solr|scoring-opic|urlnormalizer-(pass|regex|basic)&lt;/value&gt;<br>    &lt;/property&gt;<br>    &lt;property&gt;<br>        &lt;name&gt;http.auth.file&lt;/name&gt;<br>        &lt;value&gt;httpclient-auth.xml&lt;/value&gt;<br>        &lt;description&gt;Authentication configuration file for &#39;protocol-httpclient&#39; plugin.&lt;/description&gt;<br>    &lt;/property&gt;<br>    &lt;property&gt; <br>        &lt;name&gt;solr.server.url&lt;/name&gt;<br>        &lt;value&gt;http://localhost:8983/solr/docs&lt;/value&gt;<br>    &lt;/property&gt;<br>&lt;/configuration&gt;</pre><p>It’s important to define a regex URL pattern in ${NUTCH_HOME}/conf/regex-urlfilter.txt to restrict the crawl to a single site — otherwise the crawler may follow external links and end up crawling much more than intended. Here&#39;s the filter I used to restrict the crawl to keycloak.org:</p><pre>+^https?://www\.keycloak\.org/.*$</pre><p>Next, define the Solr indexer settings in ${NUTCH_HOME}/conf/index-writers.xml. This tells Nutch which Solr collection to write to and how to map fields:</p><pre>&lt;writer id=&quot;indexer_solr_1&quot; class=&quot;org.apache.nutch.indexwriter.solr.SolrIndexWriter&quot;&gt;<br>    &lt;parameters&gt;<br>      &lt;param name=&quot;type&quot; value=&quot;http&quot;/&gt;<br>      &lt;param name=&quot;url&quot; value=&quot;http://localhost:8983/solr/docs&quot;/&gt;<br>      &lt;param name=&quot;collection&quot; value=&quot;&quot;/&gt;<br>      &lt;param name=&quot;weight.field&quot; value=&quot;&quot;/&gt;<br>      &lt;param name=&quot;commitSize&quot; value=&quot;1000&quot;/&gt;<br>      &lt;param name=&quot;auth&quot; value=&quot;false&quot;/&gt;<br>      &lt;param name=&quot;username&quot; value=&quot;&quot;/&gt;<br>      &lt;param name=&quot;password&quot; value=&quot;&quot;/&gt;<br>      &lt;param name=&quot;auth.header.name&quot; value=&quot;&quot;/&gt;<br>      &lt;param name=&quot;auth.header.value&quot; value=&quot;&quot;/&gt;<br>    &lt;/parameters&gt;<br>    &lt;mapping&gt;<br>      &lt;copy&gt;&lt;/copy&gt;<br>      &lt;rename&gt;<br>        &lt;field source=&quot;metatag.description&quot; dest=&quot;description&quot;/&gt;<br>        &lt;field source=&quot;metatag.keywords&quot; dest=&quot;keywords&quot;/&gt;<br>      &lt;/rename&gt;<br>      &lt;remove&gt;<br>        &lt;field source=&quot;segment&quot;/&gt;<br>      &lt;/remove&gt;<br>    &lt;/mapping&gt;<br>  &lt;/writer&gt;</pre><p>Now define a seed URL for the crawler in a text file — call it keycloak-seed-url.txt — and add https://www.keycloak.org/ to it.</p><blockquote><strong><em>Note:</em></strong><em> Make sure Apache Ant is installed and on your path if you’re building Nutch from source. If you’re using the Nutch binary distribution instead, Ant isn’t required.</em></blockquote><h4>2. Indexing Crawled Content in Apache Solr</h4><p>Once pages are crawled, we need an efficient way to search them. Nutch indexes each crawled document into Solr along with metadata like:</p><ul><li>URL</li><li>Title</li><li>Content</li><li>Content type</li><li>Metadata</li></ul><p>The key idea here is that we’re <em>not</em> asking the AI model to consume the entire documentation corpus. Instead, the MCP server queries Solr and retrieves only the relevant documents on demand.</p><h4>Create the Solr core</h4><pre># 1. Create core<br>$SOLR_HOME/bin/solr create -c docs<br><br># 2. Remove Solr&#39;s managed schema<br>rm $SOLR_HOME/server/solr/docs/conf/managed-schema<br><br># 3. Copy Nutch schema<br>cp $NUTCH_HOME/plugins/indexer-solr/schema.xml \<br>   $SOLR_HOME/server/solr/docs/conf/schema.xml<br><br># 4. Reload<br>$SOLR_HOME/bin/solr reload -c docs</pre><p>Make sure Solr is running before executing these commands.</p><h4>Run the crawl</h4><p>Rather than running Nutch’s fetch, parse, updatedb, and invertlinks steps individually, use the crawl command, which orchestrates the full loop for you:</p><pre># 1. This path is generated after compiling using ant<br>export crawl=&quot;${NUTCH_HOME}/runtime/local/bin/crawl&quot;<br><br># 2. Crawl&#39;s &amp; indexes documents to solr for every iteration<br>$crawl -i -s keycloak-seed-url.txt keycloakdb 10</pre><p>Once that finishes, query the docs core using a keyword like &quot;keycloak&quot; in the Solr admin UI — you should start seeing indexed results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iIQ45hAdC4QOVakMEejPaA.png" /></figure><p>With the pipeline crawling and indexing working end to end, let’s move to the most interesting part: building the MCP server.</p><h4>3. Building the MCP Server with Spring AI</h4><p>Create a Spring Boot project via Spring Initializr and add the spring-ai-starter-mcp-server dependency. Since recent Spring Boot versions no longer ship built-in Solr support, also add solr-solrj to interact with Solr directly.</p><h4>application.yml:</h4><pre>spring:<br>  ai:<br>    mcp:<br>      server:<br>        name: docs-mcp-server<br>        version: 1.0.0<br>  application:<br>    name: docs-mcp-server<br>  data:<br>    solr:<br>      host: http://localhost:8983/solr<br>      collection: docs<br>  main:<br>    banner-mode: off<br>    web-application-type: none</pre><h4>The document DTO</h4><p>This class maps to the structure of documents indexed in Solr:</p><pre>public class KeycloakDocument {<br><br>    public static final String COLLECTION = &quot;docs&quot;;<br><br>    private String url;<br>    private String content;<br>    private float boost;<br>    private String title;<br><br>    public String getUrl() {<br>        return url;<br>    }<br><br>    public void setUrl(String url) {<br>        this.url = url;<br>    }<br><br>    public String getContent() {<br>        return content;<br>    }<br><br>    public void setContent(String content) {<br>        this.content = content;<br>    }<br><br>    public float getBoost() {<br>        return boost;<br>    }<br><br>    public void setBoost(float boost) {<br>        this.boost = boost;<br>    }<br><br>    public String getTitle() {<br>        return title;<br>    }<br><br>    public void setTitle(String title) {<br>        this.title = title;<br>    }<br><br>}</pre><p>Note: COLLECTION should match the Solr core name configured in application.yml — in this example, docs.</p><h4>The DocumentService (and the MCP tool)</h4><p>This service connects to Solr and retrieves indexed content. The key part is the @Tool annotation — it&#39;s what makes this method discoverable and callable by any MCP client, including Claude.</p><pre>@Service<br>public class DocumentService {<br><br>    private final SolrClient solrClient;<br><br>    @Autowired<br>    public DocumentService(SolrClient solrClient) {<br>        this.solrClient = solrClient;<br>    }<br><br>    @Tool(name = &quot;get_keycloak_documentation&quot;, description = &quot;Get keycloak release information, server docs, installation information, server setup info.&quot;)<br>    public List&lt;KeycloakDocument&gt; getKeycloakInformation(String request) {<br>        SolrQuery query = new SolrQuery();<br>        query.setQuery(&quot;content:&quot; + ClientUtils.escapeQueryChars(request));<br><br>        try {<br>            QueryResponse response = solrClient.query(KeycloakDocument.COLLECTION, query);<br>            return toDocuments(response).stream()<br>                    .sorted(Comparator.comparing(KeycloakDocument::getBoost))<br>                    .limit(3)<br>                    .toList();<br>        } catch (SolrServerException | IOException e) {<br>            throw new IllegalStateException(&quot;Failed to query Solr for keycloak documentation&quot;, e);<br>        }<br>    }<br><br>    private List&lt;KeycloakDocument&gt; toDocuments(QueryResponse response) {<br>        List&lt;KeycloakDocument&gt; documents = new ArrayList&lt;&gt;();<br>        for (SolrDocument solrDocument : response.getResults()) {<br>            KeycloakDocument document = new KeycloakDocument();<br>            document.setUrl(firstString(solrDocument, &quot;url&quot;));<br>            document.setContent(firstString(solrDocument, &quot;content&quot;));<br>            document.setTitle(firstString(solrDocument, &quot;title&quot;));<br>            Object boost = firstValue(solrDocument, &quot;boost&quot;);<br>            if (boost instanceof Number number) {<br>                document.setBoost(number.floatValue());<br>            }<br>            documents.add(document);<br>        }<br>        return documents;<br>    }<br><br>    private String firstString(SolrDocument solrDocument, String field) {<br>        Object value = firstValue(solrDocument, field);<br>        return value == null ? null : value.toString();<br>    }<br><br>    private Object firstValue(SolrDocument solrDocument, String field) {<br>        Object value = solrDocument.getFieldValue(field);<br>        if (value instanceof List&lt;?&gt; list) {<br>            return list.isEmpty() ? null : list.getFirst();<br>        }<br>        return value;<br>    }<br>}</pre><h4>Wiring up the beans</h4><pre>@Configuration<br>public class ApplicationConfiguration {<br><br>    @Value(&quot;${spring.data.solr.host}&quot;)<br>    private String solrHost;<br><br>    @Bean<br>    public SolrClient solrClient() {<br>        return new HttpSolrClient.Builder(solrHost).build();<br>    }<br>    <br>    @Bean<br>    public List&lt;ToolCallback&gt; getKeycloakReleaseDocument(DocumentService documentService) {<br>        return List.of(ToolCallbacks.from(documentService));<br>    }<br>}</pre><p>Now build the project:</p><pre>mvn clean package</pre><p>This produces docs-mcp-server-1.0.0.jar in the target folder.</p><h4>4. Connecting the MCP Server to Claude Code</h4><p>I use Claude Code for my day-to-day coding tasks — because, well, who doesn’t? Register the local MCP server with this command:</p><pre>claude mcp add docs-mcp-server --transport stdio -- java -jar /absolute/path/to/project/target/docs-mcp-server-1.0.0.jar</pre><p>From here, any Keycloak-related question asked in a Claude Code session will be answered using the freshly crawled and indexed documentation — not stale training data.</p><h4>Wrapping Up</h4><p>We built a complete pipeline: <strong>Nutch crawls → Solr indexes → an MCP server queries → Claude answers.</strong> The nice part about this architecture is that the AI model never has to ingest the entire documentation corpus — it just asks a targeted question through the MCP tool and gets back a handful of relevant, up-to-date documents.</p><p>I used keycloak.org here purely as a public stand-in, but the exact same process works for wiring an organization’s internal product documentation into any MCP-compatible AI assistant. If you try this out or run into issues along the way, I’d love to hear about it in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66bb51dba944" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>