javarepo-mcp

A Model Context Protocol extension that finds and retrieves the source code of Java classes from Maven repositories.

GitHub Stars

0

User Rating

Not Rated

Favorites

0

Views

5

Forks

0

Issues

0

README
JavaRepo MCP

A Model Context Protocol extension that finds and retrieves the source code of Java classes from Maven repositories.

Overview

JavaRepo MCP is a tool that helps developers access Java source code directly from Maven artifacts. It provides a Model Context Protocol (MCP) server extension that can be integrated with compatible editors and IDEs, allowing you to view and inspect the source code of libraries and dependencies without leaving your development environment.

Features
  • Source Code Retrieval: Looks up Java classes from Maven artifacts by their coordinates (groupId, artifactId, version) and fully qualified class name
  • Source Lookup Strategy:
    1. First tries to find the original source code in the Maven sources JAR
    2. Then searches for the source code in the local file system
    3. If source code is not found, decompiles the class using CFR
  • MCP Integration: Built as a Model Context Protocol tool for seamless integration with compatible editors and tools
Requirements
  • Java 17 or higher
  • Maven repository with the target libraries
Installation
  1. Clone the repository:

    git clone https://github.com/yourusername/javarepo-mcp.git
    
  2. Build the project:

    cd javarepo-mcp
    mvn clean package
    
  3. The built JAR will be available at target/javarepo-mcp-1.0-SNAPSHOT.jar

Usage

This tool is designed to be used through the Model Context Protocol. It exposes a tool called findClassFromRepository that accepts the following parameters:

  • groupId: The Maven group ID of the library
  • artifactId: The Maven artifact ID of the library
  • version: The version of the library
  • className: The fully qualified name of the class to retrieve

The tool returns the source code of the requested class as a string. If the original source code cannot be found, it will return a decompiled version.

Technical Details

JavaRepo MCP uses the following technologies:

  • Model Context Protocol (MCP): For tool integration with editors and IDEs
  • CFR Decompiler: For decompiling Java classes when source code is not available
  • Maven Repository System: For locating and accessing Java artifacts and sources
License

This project is licensed under the terms included in the LICENSE file.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgements
Author Information

0

Followers

0

Repositories

0

Gists

0

Total Contributions