DEV Community

Cover image for Guided Delegation: Adding Context7 Documentation to My Maven Tools MCP Server
Arvind Menon
Arvind Menon

Posted on • Edited on

Guided Delegation: Adding Context7 Documentation to My Maven Tools MCP Server

How guided delegation bridges dependency analysis with up-to-date docs.


A while back I wrote about building a Maven Central MCP server so Claude / Copilot can answer the boring dependency questions straight from Maven Central.

It worked well for “what version should I be on?”

But when I used it on real upgrades (especially major bumps), the agent would update the pom but then the build would most likely fail due to breaking changes in the libraries. Then I would have to go through documentation searches on the web and fix issues one by one. That's fine, but we can do better.

The Gap: From “What to Upgrade” to “How to Upgrade”

My Maven tools can tell you things like:

  • What the latest stable version is
  • Whether an update is major/minor/patch
  • Which dependencies are aging or stale

That gets you to a decision. It doesn’t get you through the upgrade.

For anything non-trivial you still end up hunting for the right migration guide or “breaking changes” doc. And if the assistant falls back to generic web search, you quickly get stale or out-of-context advice.

That’s where Context7 fits in. It’s another MCP server that can pull version-specific documentation into the assistant’s context.

So the real problem became: how do I combine “Maven intelligence” with “current docs” without jamming everything into one big server?

The Approach: Guided Delegation

I didn’t want to re-implement Context7 inside my project. I just wanted a clean workflow:

  1. Maven Tools does the analysis (versions, stability, update type)
  2. If it looks like a potentially painful upgrade, it returns an extra field with explicit orchestration instructions
  3. The assistant uses those instructions to call Context7 tools (or fall back to normal web search)

That’s what I mean by “guided delegation”: my server doesn’t fetch docs itself — it tells the model exactly how to fetch the docs using the right tools.

Implementation: Dual MCP Architecture with Spring AI

This ended up being mostly configuration.

1) Wire Context7 as an MCP client

In src/main/resources/application.yaml I enable the MCP client and tool callback, and point it at Context7:

spring:
  ai:
    mcp:
      client:
        enabled: true
        type: ASYNC
        request-timeout: 15s
        toolcallback:
          enabled: true
        streamable-http:
          connections:
            context7:
              url: https://mcp.context7.com/

context7:
  enabled: true
Enter fullscreen mode Exit fullscreen mode

With that, Spring AI connects to Context7 and exposes its tools alongside my Maven tools.

2) Add “guidance hints” to the response models

On the Maven side, I don’t call Context7 directly. I just include a context7_guidance field when Context7 is enabled.

Here’s the rough shape of the tool method (trimmed down, but with the real parameters):

@Tool(description = "Bulk upgrade check (versions REQUIRED in input).")
public ToolResponse compare_dependency_versions(
    String currentDependencies,
    @Nullable StabilityFilter stabilityFilter,
    @Nullable Boolean includeSecurityScan) {
  return executeToolOperation(() -> {
    // ... compare versions, optionally scan with OSV
    return new VersionComparison(Instant.now(), results, summary, securitySummary);
  });
}
Enter fullscreen mode Exit fullscreen mode

And the per-dependency comparison result can include a guidance block like this:

{
  "comparison_date": "2026-01-06T12:00:00Z",
  "dependencies": [
    {
      "dependency": "org.springframework.boot:spring-boot-starter",
      "current_version": "2.7.0",
      "latest_version": "3.2.0",
      "update_type": "major",
      "update_available": true,
      "context7_guidance": {
        "orchestration_instructions": "Use resolve-library-id tool with query='spring-boot-starter migration guide breaking changes' and libraryName='spring-boot-starter' to find the library ID. Then use query-docs tool with the returned libraryId and query='spring-boot-starter migration guide breaking changes' to get upgrade instructions. If Context7 doesn't provide sufficient information, perform a web search for 'spring-boot-starter major version upgrade guide'."
      }
    }
  ],
  "update_summary": { "major_updates": 1, "minor_updates": 0, "patch_updates": 0, "no_updates": 0 }
}
Enter fullscreen mode Exit fullscreen mode

That string looks a bit verbose on purpose: it’s meant to be copy-pasteable instructions for the model, not a nice message for humans.

Setup Notes

If you’re running the Docker image, you don’t need a separate Context7 server. The container will call out to https://mcp.context7.com/.

What Changed for Me

The practical difference is that a major upgrade conversation doesn’t stall out after “this is a major update”. The assistant can immediately pull the right docs and keep going.

Also: keeping this as “compose tools + add orchestration hints” felt a lot cleaner than turning Maven Tools into a documentation scraper.

If you try it, I’m curious about two things:

  • Are the context7_guidance instructions actually helpful in your upgrade scenarios?
  • Where do they fall short (too generic, too verbose, wrong query phrasing, etc.)?

Check out the repo if you haven't yet - github.com/arvindand/maven-tools-mcp.


About the Author: I'm Arvind, a senior backend engineer based in Karlsruhe, Germany. I spend most of my time with Java and Spring Boot in enterprise environments, but lately I've been exploring AI integration and being more out in the open (source). You can find me on GitHub or LinkedIn.

Top comments (0)