JVM Source Lens

io.github.Sintexer由 GitHub 帳號 Sintexer 發布v1.16.0更新於 Oct 24, 2026

Gradle-accurate JVM classpath; fetch Java source, signatures, and class structure for agents.

發布方自己的服務:Source

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

本機 MCP 伺服器,為編碼助理提供與 Gradle 一致的 JVM 類別路徑查詢:依專案實際相依版本搜尋類別、檢視結構、簽章與原始碼

可以做什麼
以簡單名稱或萬用字元搜尋已解析相依中的類別,回傳完整限定名稱與所屬函式庫,並分析專案實際使用的相依圖與各模組版本。取得類別概觀或已宣告簽章,並取得方法的真實多載、參數名稱與泛型資訊。在已解析的類別內做正規表示式或子字串搜尋,或在單一相依 JAR 的所有類別中檢索文字。作為最後手段讀取方法主體或行範圍原始碼,並標示是真实原始碼或 CFR 反編譯結果。
適用情境
適用於以 Gradle 建置的 Java 與 Spring Boot 專案,尤其是第三方或內部函式庫沒有公開 Javadoc、助理容易猜錯版本或翻找 Gradle 快取的情況。它回傳簽章與結構而非整份檔案,有助於控制上下文長度。
執行需求
透過 npx 以 stdio 在本機執行。需要 Node.js 20 或更新版本,以及 PATH 中的 Java(供 CFR 反編譯器與 javap 使用)。專案必須是 Gradle 建置(不支援 Maven 與 Bazel);對專案的首次呼叫會執行 Gradle,耗時數秒。選用環境變數可限定允許的專案根目錄、快取與日誌目錄、自訂 CFR JAR、Gradle 逾時與原始碼輸出上限。
安裝前請注意
它會對你的專案執行 Gradle 子程序並讀取相依 JAR,因此只應指向可信專案;可用 JVMSRC_ALLOWED_ROOTS 限制可解析的根目錄。若 Gradle 建置需要私有儲存庫憑證,這些變數必須設在 MCP 程序本身,該程序可讀取它們。它聲明不上傳遙測,快取與日誌保留在本機,且不會寫入專案根目錄。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 JVM Source Lens,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

jvmsrc — Give your coding agent a Java IDE

[CI] [npm version] [License: MIT] [Node]

An MCP server and CLI that gives your coding agent the one thing it's missing on JVM codebases: the actual classpath.


The Problem

You use an IDE to write Java. Your coding agent doesn't have one.

When your agent hits an unfamiliar library type — say, a superclass from a proprietary internal library — it spends 25+ turns walking ~/.gradle/caches, opening JARs by hand with jar tf, picking one by guesswork, and trying to answer a question your IDE would answer in one keystroke: does this superclass have a public utility method called X?

The Solution

jvmsrc queries your build tool (Gradle) for this project's resolved classpath, then hands your agent real source, real signatures, and real structure — for the exact version your build actually uses.

  • As an MCP server – Connect to Claude Code, Cursor, Windsurf, or any other MCP host and equip your agent with six purpose-built classpath tools.
  • As the jvmsrc CLI – Same engine, scriptable, pipe-friendly, and useful on its own when you just want to read a class.

[jvmsrc resolving a Spring class in Claude Code]
Claude Code resolving HandlerInterceptor signatures via jvmsrc — 3 calls, correct answer, no cache walking.


What it saves, daily

On JVM projects with private libraries and no public Javadocs, jvmsrc is a force multiplier:

  • ~50K tokens saved per "what's on this external class" investigation — roughly 70% reduction in cost.
  • 15+ agent panic loops avoided daily — no grinding through Gradle caches, opening wrong JARs, or giving up.
  • Unlock delegation for complex tasks touching internal SDKs that you previously had to do yourself.

The Difference in Action

Without jvmsrc (The 25-turn blind grind)

User: Override the audit hook from AbstractTradingService — is there a public utility method on it we should reuse?

Agent:

  1. Searches workspace for AbstractTradingService.java ➔ 0 hits
  2. Runs: find ~/.gradle -name "trading-core*"
  3. Finds 4 versions: 2.1.0, 2.3.0, 2.4.1, 3.0.0-SNAPSHOT
  4. Guesses: Picks trading-core-2.4.1.jar (the project actually uses 3.0.0-SNAPSHOT!)
  5. Runs: jar tf and javap -p on the wrong JAR
  6. [22 turns later] "I don't see a utility method, you'll have to implement it yourself."

Reality: 3.0.0-SNAPSHOT added maskSensitiveFields() as a protected helper exactly for this case. The agent didn't hallucinate — it was just blind.

With jvmsrc (The 3-turn instant resolution)

User: Override the audit hook from AbstractTradingService — is there a public utility method on it we should reuse?

Agent:

  1. search_classes("AbstractTradingService") ➔ Finds FQN & exact resolved library.
  2. get_class_structure(scope: "overview") ➔ Discovers maskSensitiveFields() in 3.0.0-SNAPSHOT.
  3. get_method_signature("maskSensitiveFields") ➔ Gets accurate signature and generics.

Result: Writes the override correctly on the first try. No cache walking, no guessing, no wrong version.


How It Works

  1. Build Tool Inquiry: jvmsrc queries your active build tool (e.g., Gradle) for the exact resolved classpath configuration.
  2. Intelligent Caching: It caches the resolved classpath, tracking changes to build files to stay current.
  3. Precision AI Tools: Instead of full-code dumping, it exposes precise, high-granularity tools (signatures, structure, search) to keep context windows small and token usage ultra-low.

Installation & Quick Start

1. Install CLI

bash
npm install -g jvmsrc

Or use it directly via npx:

bash
npx jvmsrc mcp

[!IMPORTANT]
Requires Node ≥ 20 and Java on PATH (for CFR decompiler + javap).

2. Add the MCP server

Paste this into your AI assistant config (Cursor, Claude Code, Windsurf, etc.), then restart the host:

json
{  "mcpServers": {    "jvmsrc": {      "command": "jvmsrc",      "args": ["mcp"]    }  }}

Optional: jvmsrc config (or jvmsrc config --project /path/to/gradle-project) prints a paste-ready block plus environment hints. Most users can skip it and copy the snippet above.


MCP Server Reference

The MCP server runs over stdio via jvmsrc mcp. The default config needs no environment variables:

json
{  "mcpServers": {    "jvmsrc": {      "command": "jvmsrc",      "args": ["mcp"]    }  }}

Private repository credentials (optional)

Only needed when your Gradle build requires credential env vars for a private Maven/Artifactory/Nexus-style repo. MCP hosts often do not inherit your interactive shell, so those vars must be set on the jvmsrc MCP process (then restart the server).

REPO_USER / REPO_PASS below are sample names only — they are not required by jvmsrc. Use whatever variable names your project’s Gradle scripts document:

json
{  "mcpServers": {    "jvmsrc": {      "command": "jvmsrc",      "args": ["mcp"],      "env": {        "REPO_USER": "your-username",        "REPO_PASS": "your-password"      }    }  }}

Omit the env block entirely when the project does not need them.

Tools your agent gets

ToolWhat it does
search_classesFind a class by simple name or glob; returns compact FQN + lib name lists
get_class_structureRetrieves class overview (purpose + method names) or declared signatures
get_method_signatureFetches real overloads for a method, with parameter names and generics
find_in_class_sourcePerforms regex or substring searches inside a resolved class
get_class_sourceRetrieves method bodies or line ranges (used as a last resort)
search_in_artifactGreps text across all classes in one resolved dependency JAR
resolve_dependenciesAnalyzes the actual dependency graph this project uses

[!TIP]
Every source response includes sourceAvailable: true for real sources (Javadoc, parameter names, generics), false for CFR decompilation (structure reliable, names may be synthetic).

[!NOTE]
Multimodule: omit modulePath and jvmsrc auto-picks the unique owning module; on a miss it lists candidate modulePaths. Methods: search_classes matches declared method names when the index has source enrichment; for body text in a known JAR use search_in_artifact. get_class_source methodNames also walks superclasses for unmatched names.

Make your agent use it

Tool descriptions help, but a built-in Bash tool the agent already trusts will often win. Two small additions make jvmsrc the default for dependency questions.

1. Add a rule to your agent's instructions (CLAUDE.md, AGENTS.md, Cursor rules) — many clients do not show MCP server instructions at all:

markdown
## Dependencies (jvmsrc)For any question about a third-party library class, method or version, use the jvmsrc MCP tools(search_classes → get_class_structure → get_class_source with methodNames; resolve_dependencies for versions).When working inside one module, pass modulePath (':app' or the file you are editing) to get that module's versions.Never use javap, unzip/jar on JARs, or ~/.gradle/caches. Code under this repo's src/ → grep/read as usual.

2. (Claude Code) Block the shell fallbacks with a hook. docs/hooks/block-jvm-fallbacks.mjs denies javap, unzip/jar on JARs, and ~/.gradle/caches / ~/.m2 access, and tells the agent to use jvmsrc instead, so it redirects instead of silently reading the wrong version. Save the script somewhere stable and add to .claude/settings.json (project) or ~/.claude/settings.json (all projects):

json
{  "hooks": {    "PreToolUse": [      {        "matcher": "Bash",        "hooks": [{ "type": "command", "command": "node /absolute/path/to/block-jvm-fallbacks.mjs" }]      }    ]  }}

Set JVMSRC_HOOK_DISABLE=1 to switch it off temporarily. Other clients have their own hook mechanisms; check their current docs before porting.

Check that your client shows the server instructions: ask the agent "What instructions does the jvmsrc MCP server give?". If it cannot answer, rely on the rule in step 1.

[!NOTE] Inputs are forgiving. projectRoot can be omitted (the workspace is used, or set JVMSRC_PROJECT_ROOT); modulePath accepts app, /app, :app, or a file/directory inside the module (omit it, or pass "*", to search all modules); className accepts a simple name, Outer.Inner, or a trailing .class/.java. The first call on a project runs Gradle (typically 5–10s); later calls use the cache. Pass forceRefresh: true only after something changed that the build files do not show, such as a SNAPSHOT republish.


How It Compares

ToolApproachGap
Cache Indexers / ~/.gradle grepScan global cachesNo per-project resolved version
Static Parsers (e.g., build.gradle parser)Parse declarations onlyMisses transitive dependencies, BOMs, dynamic versions
mcp-javadoc / path-only CFRUser supplies manual JAR pathsNo automatic build/classpath resolution
Gradle MCP (Tooling API)Task/build focusedNot optimized for classpath-accurate FQN source lookup
jvmsrcQueries actual build tool & cachesVersion-correct sources and signatures for agents

Target Audience

Primarily Java + Spring Boot projects on Gradle. Other JVM languages (Kotlin, Scala) and Android work today on a best-effort basis and are on the roadmap as first-class targets — see ROADMAP.md.

If you're on Maven or Bazel, it's planned but not shipping yet. Star the repo or open an issue and I'll prioritize accordingly.


Detailed Reference

Requirements & Compatibility

Runtime: Node.js ≥ 20, Java on PATH.

Project types: JVM codebases (Java, Kotlin, Scala, Groovy). jvmsrc calls the build tool, not your editor.

Build systemStatus
GradleSupported — multimodule included
Maven, BazelPlanned (SPEC.md)

Point -p / projectRoot at the Gradle root (settings.gradle(.kts) or root build.gradle(.kts)). Uses ./gradlew when present, else gradle on PATH. Maven-only trees get an explicit unsupported error.

Known Limitations

Early software; the supported path is narrow:

AreaToday
Build toolGradle only
IntegrationGroovy init script (--init-script) — not a Gradle Portal plugin
ClasspathsStandard JVM + Kotlin MPP jvm* configurations when Gradle exposes them
OutputJava-shaped .java text (sources JAR, inter-project src, or CFR)

Composite builds, Android-only layouts, and exotic configurations are not fully validated. See ROADMAP.md.

Security & Privacy
  • No telemetry.
  • Local only — caches and diagnostics stay on disk; never writes under your project root.
  • Subprocesses via argv only (no shell interpolation) — see SECURITY.md.
  • Optional JVMSRC_ALLOWED_ROOTS to lock down which projects jvmsrc may resolve.
CLI Command Reference
bash
jvmsrc com.example.MyClass -p /path/to/gradle-project          # shorthand for getjvmsrc get com.example.MyClass -p /path/to/project -q > MyClass.javajvmsrc resolve -p /path/to/project --force-refreshjvmsrc config jdk-roots add /path/to/jdks                      # one-time JDK roots setupjvmsrc doctor java -p /path/to/project                         # check JDK requirement + selectionjvmsrc diagnostics last                                         # latest failure messagejvmsrc mcp                                                     # run as MCP server

Useful flags: -p / --project, --module (:core:api), --configuration, --include-test, --force-refresh, --verbose (Gradle stderr only), --method, --start-line / --end-line.

Repo fixture for testing: test/fixtures/gradle-smoke — jvmsrc get com.smoke.Core -p test/fixtures/gradle-smoke --module :core.

Troubleshooting
  • Resolution failures: Run jvmsrc diagnostics last (or jvmsrc diagnostics last 5)
  • Custom JDK install roots: Add once with jvmsrc config jdk-roots add /path/to/jdks
  • JDK mismatch debugging: Run jvmsrc doctor java -p /path/to/project
  • After upgrading jvmsrc: Restart your MCP host
  • Stale classpath: Run jvmsrc resolve --force-refresh
Environment Variables
VariablePurpose
JVMSRC_JAVA_HOMEForce JDK home for Gradle/CFR child processes
JVMSRC_CONFIG_DIRGlobal jvmsrc config directory (absolute)
JVMSRC_CACHE_ROOTCache root (absolute)
JVMSRC_LOG_DIRDiagnostic logs (absolute)
JVMSRC_CALL_LOG1 = append one line per MCP tool call to calls.log (opt-in; see SPEC §6.3)
JVMSRC_ALLOWED_ROOTSAllowed projectRoot prefixes
JVMSRC_PROJECT_ROOTDefault project root for MCP tools when projectRoot is omitted and the client sends no workspace roots (falls back to the working directory)
JVMSRC_MAX_SOURCE_OUTPUT_CHARSMax source body size (default 524288)
JVMSRC_GRADLE_TIMEOUT_MSGradle timeout
JVMSRC_CFR_PATHCustom CFR JAR

Defaults follow env-paths conventions per OS. Full layout: SPEC.md §6.

When JVMSRC_JAVA_HOME is not set, jvmsrc auto-discovers local JDKs from common paths such as ~/.jdks (IntelliJ), ~/.gradle/jdks, SDKMan, jenv, asdf, and OS-specific system install directories, plus your global configured JDK roots from jvmsrc config jdk-roots ....

AI Agent Reviews

Finally, an MCP That Doesn't Make Me Decompile JARs

"This tool is a revelation for anyone tired of LLMs hallucinating non-existent Spring APIs. It actually reads bytecode, providing accurate class definitions and source lookups without the usual 'vibes-based' guesswork. The search_classes functionality is incredibly precise, and the thoughtful implementation of javap fallback and granular scope controls (overview/declared/effective) makes navigating complex JARs painless. It’s fast, honest when it can't find a class, and handles cache management perfectly. A must-have for any dev struggling with dependency hell — it’s like having a senior engineer who actually enjoys reading documentation." — Claude (AI Reviewer)


Project Documentation

DocumentContents
SPEC.mdSchemas, contracts, CLI/MCP details
CONTRIBUTING.mdBuild, test, PR notes
RELEASING.mdBranching, semver, npm releases
CHANGELOG.mdVersion history
ROADMAP.mdStatus and planned work
SECURITY.mdVulnerability reporting

Building from Source

bash
git clone https://github.com/Sintexer/jvm-source-lens.gitcd jvm-source-lensbun install && bun run setup:cfr && bun run buildnode dist/cli.js --version

Full contributor workflow: CONTRIBUTING.md.


I built jvmsrc because I kept running into the same wall: agents that are great at writing Java but blind to the actual classpath. If it saves you the same 25-turn grind it saved me, that's exactly why this exists. Found a bug, have an idea, or just want to say it helped? Open an issue or a PR — I read everything.

License

MIT — see LICENSE.

來源:README.md,提交 56c4bf0

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.16.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Source 整合