maven-indexer-mcp
Indexes local Maven and Gradle caches to enable AI agents to search for Java classes, method signatures, and source code, including from internal or obscure libraries.
README
Maven Indexer MCP Server
A Model Context Protocol (MCP) server that indexes your local Maven repository (~/.m2/repository) and Gradle cache (
~/.gradle/caches/modules-2/files-2.1) to provide AI agents with tools to search for Java classes, method signatures,
and source code.
Key Use Case: While AI models are well-versed in popular public libraries (like Spring, Apache Commons, Guava), they often struggle with:
- Internal Company Packages: Private libraries that are not public.
- Non-Well-Known Public Packages: Niche or less popular open-source libraries.
This server bridges that gap by allowing the AI to "read" your local dependencies, effectively giving it knowledge of your private and obscure libraries.
Features
- Semantic Class Search: Search for classes by name or purpose.
- Inheritance Search: Find all implementations of an interface or subclasses of a class.
- On-Demand Analysis: Extracts method signatures and Javadocs directly from JARs.
- Source Code Retrieval: Provides full source code if available.
- Real-time Monitoring: Automatically updates the index when repositories change.
Maven Indexer MCP vs Maven Indexer CLI
This package provides an MCP interface into the Maven/Gradle index. If you are using a coding agent in the terminal, you might benefit from using the CLI + SKILL instead.
-
CLI: Modern coding agents increasingly favor CLI-based workflows exposed as SKILLs over MCP because CLI invocations are more token-efficient: they avoid loading large tool schemas into the model context, allowing agents to act through concise, purpose-built commands. This makes CLI + SKILLs better suited for high-throughput coding agents that must balance dependency lookups with large codebases and reasoning within limited context windows.<br>Learn more about Maven Indexer CLI with SKILLS.
-
MCP: MCP remains the better choice for IDE-integrated agents (Cursor, Kiro, Windsurf, etc.) that benefit from persistent background indexing, automatic repository watching, and seamless tool invocation without any CLI setup. The MCP server indexes your repository in the background and keeps the index up to date automatically.
Getting Started
Add the following config to your MCP client:
{
"mcpServers": {
"maven-indexer": {
"command": "npx",
"args": [
"-y",
"maven-indexer-mcp@latest"
]
}
}
}
This will automatically download and run the latest version of the server. It will auto-detect your Maven repository
location (usually ~/.m2/repository) and Gradle cache.
MCP Client configuration
<details> <summary>Cline</summary>
Follow <a href="https://docs.cline.bot/mcp/configuring-mcp-servers">Cline's MCP guide</a> and use the config provided above. </details>
<details> <summary>Codex</summary>
Follow the <a href="https://github.com/openai/codex/blob/main/docs/advanced.md#model-context-protocol-mcp">configure MCP guide</a> using the standard config from above. </details>
<details> <summary>Cursor</summary>
Click the button to install:
Or install manually:
Go to Cursor Settings -> MCP -> New MCP Server. Use the config provided above.
</details>
<details> <summary>JetBrains AI Assistant & Junie</summary>
Go to Settings | Tools | AI Assistant | Model Context Protocol (MCP) -> Add. Use the config provided above.
The same way maven-indexer can be configured for JetBrains Junie in Settings | Tools | Junie | MCP Settings ->Add.
Use the config provided above.
</details>
<details> <summary>Kiro</summary>
In Kiro Settings, go to Configure MCP > Open Workspace or User MCP Config > Use the configuration snippet
provided above.
Or, from the IDE Activity Bar > Kiro > MCP Servers > Click Open MCP Config. Use the configuration snippet
provided above.
</details>
<details> <summary>Qoder</summary>
In Qoder Settings, go to MCP Server > + Add > Use the configuration snippet provided above.
Alternatively, follow the <a href="https://docs.qoder.com/user-guide/chat/model-context-protocol">MCP guide</a> and use the standard config from above.
</details>
<details> <summary>Trae</summary>
Go to Settings -> MCP -> + Add -> Add Manually to add an MCP Server. Use the config provided above.
</details>
<details> <summary>Windsurf</summary>
Follow the <a href="https://docs.windsurf.com/windsurf/cascade/mcp#mcp-config-json">configure MCP guide</a> using the standard config from above. </details>
Your first prompt
Enter the following prompt in your MCP Client to check if everything is working:
Find the class `StringUtils` in my local maven repository and show me its methods.
Your MCP client should read the class StringUtils from your local Maven repository and show its methods.
Configuration (Optional)
If the auto-detection fails, or if you want to filter which packages are indexed, you can add environment variables to the configuration:
MAVEN_REPO: Absolute path to your local Maven repository (e.g.,/Users/yourname/.m2/repository). Use this if your repository is in a non-standard location.GRADLE_REPO_PATH: Absolute path to your Gradle cache (e.g.,/Users/yourname/.gradle/caches/modules-2/files-2.1).INCLUDED_PACKAGES: Comma-separated list of package patterns to index (e.g.,com.mycompany.*,org.example.*). Default is*(index everything).MAVEN_INDEXER_CFR_PATH: (Optional) Absolute path to a specific CFR decompiler JAR. If not provided, the server will attempt to use its bundled CFR version.VERSION_RESOLUTION_STRATEGY: (Optional) Strategy to choose the version when multiple versions of an artifact are found and no specific coordinate is provided.semver: (Default) Prefer the highest semantic version (e.g. 1.2.0 > 1.1.9).latest-published: Prefer the version with the latest publish time (checks*.pom.lastUpdatedfirst, then file modification time).latest-used: Prefer the version most recently imported/used by the user (based on file creation time).
Example with optional configuration:
{
"mcpServers": {
"maven-indexer": {
"command": "npx",
"args": [
"-y",
"maven-indexer-mcp@latest"
],
"env": {
"MAVEN_REPO": "/Users/yourname/.m2/repository",
"GRADLE_REPO_PATH": "/Users/yourname/.gradle/caches/modules-2/files-2.1",
"INCLUDED_PACKAGES": "com.mycompany.*",
"MAVEN_INDEXER_CFR_PATH": "/path/to/cfr-0.152.jar",
"VERSION_RESOLUTION_STRATEGY": "semver"
}
}
}
}
Local Development
If you prefer to run from source:
-
Clone the repository:
git clone https://github.com/tangcent/maven-indexer-mcp.git cd maven-indexer-mcp -
Install dependencies and build:
npm install npm run build -
Use the absolute path in your config:
{ "mcpServers": { "maven-indexer": { "command": "node", "args": ["/absolute/path/to/maven-indexer-mcp/build/index.js"] } } }
Available Tools
search_classes: Search for Java classes in the local Maven repository and Gradle caches.-
WHEN TO USE: 1. Internal/Private Code: You need to find a class from a company-internal library. 2. Obscure Libraries: You are using a less common public library that the AI doesn't know well. 3. Version Verification: You need to check exactly which version of a class is present locally.
- Note: For well-known libraries (e.g., standard Java lib, Spring), the AI likely knows the class structure already, so this tool is less critical.
-
Examples: "Show me the source of StringUtils", "What methods are available on DateTimeUtils?", "Where is this class imported from?".
-
Input:
className(e.g., "StringUtils", "Json parser") -
Output: List of matching classes with their artifacts.
-
get_class_details: Decompile and read the source code of external libraries/dependencies. Use this instead of 'SearchCodebase' for classes that are imported but defined in JAR files.- Key Value: "Don't guess what the internal library does—read the code."
- Tip: Essential for internal/proprietary code where documentation is scarce or non-existent.
- Input:
className(required),artifactId(optional),type("signatures", "docs", "source") - Output: Method signatures, Javadocs, or full source code.
- Note: If
artifactIdis omitted, the tool automatically selects the best available artifact (preferring those with source code attached).
search_artifacts: Search for artifacts in Maven/Gradle caches by coordinate (groupId, artifactId).search_implementations: Search for classes that implement a specific interface or extend a specific class. Useful for finding SPI implementations in external libraries.- Input:
className(e.g. "java.util.List") - Output: List of implementation/subclass names and their artifacts.
- Input:
refresh_index: Trigger a re-scan of the Maven repository.
Development
- Run tests:
npm test - Watch mode:
npm run watch
License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。