npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@morris131/jdtls-mcp-server

v1.3.1

Published

MCP server for Eclipse JDT.LS (Java Language Server), providing Java IDE features as MCP tools

Readme

JDTLS MCP Server

基于模型上下文协议(MCP)的 Eclipse JDT.LS Java 语言服务桥接服务器,提供诊断、导航、重构、代码操作等 Java IDE 能力。

特性

  • 代码诊断 - 获取 Java 源文件的错误、警告和提示
  • 跳转到定义 - 跳转到符号定义位置(LSP 精度获取符号名和类型)
  • 查找引用 - 查找工作空间中符号的所有引用
  • 查找实现 - 查找接口的实现或抽象类的子类
  • 工作空间符号 - 搜索整个工作空间中的符号
  • 文档符号 - 列出 Java 文件中的所有符号(分层结构)
  • 类型层次 - 获取类型的超类/接口和子类/实现
  • 重命名 - 跨工作空间重命名符号(返回编辑,不直接写盘)
  • 组织导入 - 移除未使用的导入并排序(支持单文件和目录递归)
  • 格式化代码 - 格式化 Java 文件(支持单文件和目录递归)
  • 跨平台 - 支持 Windows、Linux 和 macOS
  • 快速启动 - 自动启动 JDT.LS,支持预热

前提条件

  • Node.js >= 18
  • Java >= 17

配置

| 环境变量 | 说明 | 默认值 | | :--- | :--- | :--- | | JDTLS_TOOLS | 逗号分隔的工具名称,只启用指定工具(可选) | 全部工具 |

可用的工具名称:get_diagnosticsgoto_definitionfind_referencesworkspace_symbolsfind_implementationsget_document_symbolsget_type_hierarchyrename_symbolorganize_importsformat_code

使用方式

OpenCode 配置

{
  "mcp": {
    "jdtls": {
      "type": "local",
      "command": ["npx", "-y", "@morris131/jdtls-mcp-server"]
    }
  }
}

Claude Code 配置

运行以下命令添加 MCP 服务器:

claude mcp add jdtls -- npx -y @morris131/jdtls-mcp-server

可用工具

get_diagnostics

获取 Java 源文件或整个工作空间的错误、警告和提示。

参数:

  • filePath(可选)- 文件路径或目录路径;不传时默认检查当前工作空间
  • severity(可选)- 按严重级别过滤:errorwarningall(默认)
  • maxResults(可选)- 返回的最大诊断条数(默认 100,需为大于等于 0 的整数)

返回字段(structuredContent):

  • diagnostics - 诊断数组,每项包含 messageseverityfilePathcategorycodesourcerange
  • errorCount / warningCount - 按严重级别统计数
  • totalDiagnostics - 总诊断数
  • truncated - 当命中诊断数超过 maxResults 时为 true

示例:

{
  "filePath": "src/main/java/com/example/App.java",
  "severity": "error",
  "maxResults": 50
}

检查整个工作空间示例:

{
  "severity": "error",
  "maxResults": 200
}

goto_definition

跳转到符号定义位置。返回符号名、种类和定义位置。

参数:

  • filePath(必填)- 包含符号的源文件
  • line(必填)- 基于 0 的行号
  • column(必填)- 基于 0 的列号

返回字段(structuredContent):

  • symbol - 符号名称(来自 LSP documentSymbol)
  • kind - 符号类型(class/method/interface/field 等)
  • location - 定义位置(filePath/line/column

find_references

查找工作空间中符号的所有引用。返回符号信息和引用位置列表。

参数:

  • filePath(必填)- 包含符号的源文件
  • line(必填)- 基于 0 的行号
  • column(必填)- 基于 0 的列号
  • maxResults(可选)- 最大返回数(默认 100

返回字段(structuredContent):

  • symbol - 符号名称(来自 LSP documentSymbol)
  • symbolKind - 符号类型(class/method/interface/field 等)
  • totalCount - 引用总数
  • locations - 引用位置数组(filePath/line/column
  • truncated - 当结果数超过 maxResults 时为 true

workspace_symbols

搜索整个工作空间中的符号。支持通配符模式。

参数:

  • query(必填)- 符号查询文本
  • maxResults(可选)- 最大返回数(默认 100

返回字段(structuredContent):

  • symbols - 符号数组,每项包含 namekind(LSP SymbolKind 数值)、containerNamefilePathlinecolumn
  • totalSymbols - 匹配到的符号总数(用于判断是否被截断)
  • truncated - 当结果数超过 maxResults 时为 true

find_implementations

查找接口的实现或抽象类的子类。将光标定位在类型或方法名上。

参数:

  • filePath(必填)- 源文件路径
  • line(必填)- 基于 0 的行号
  • column(必填)- 基于 0 的列号
  • maxResults(可选)- 最大返回数(默认 100

返回字段(structuredContent):

  • symbol - 符号名称
  • isInterface - 是否为接口
  • symbolKind - 符号类型(class/interface/method 等)
  • totalImplementations - 实现总数
  • implementations - 实现位置数组(filePath/line/column
  • truncated - 当结果数超过 maxResults 时为 true

get_document_symbols

列出 Java 文件中的所有符号,返回分层结构(类型 > 方法/字段 > 内部类等)。

参数:

  • filePath(必填)- 文件路径
  • maxResults(可选)- 最大返回数(默认 100

返回字段(structuredContent):

  • symbols - 分层符号数组,每项包含 namekinddetaillinecolumnchildren(嵌套子符号)
  • totalSymbols - 符号总数
  • truncated - 当结果数超过 maxResults 时为 true

get_type_hierarchy

获取类型在指定位置上的超类/接口(supertypes)和子类/实现(subtypes)。

参数:

  • filePath(必填)- 源文件路径
  • line(必填)- 基于 0 的行号
  • column(必填)- 基于 0 的列号
  • direction(可选)- 层次方向:supertypessubtypesboth(默认)

返回字段(structuredContent):

  • symbol - 类型名称
  • kind - 类型种类(class/interface 等)
  • filePath/line/column - 类型位置
  • supertypes - 超类/接口数组
  • subtypes - 子类/实现数组

rename_symbol

跨工作空间重命名符号。返回所有出现位置的文本编辑,由调用方自行应用(不直接写盘)。

参数:

  • filePath(必填)- 源文件路径
  • line(必填)- 基于 0 的行号
  • column(必填)- 基于 0 的列号
  • newName(必填)- 新符号名称

返回字段(structuredContent):

  • oldName - 原符号名
  • newName - 新符号名
  • symbolKind - 符号类型(Type/Method/Symbol)
  • totalEdits - 编辑总数
  • filesAffected - 涉及文件数
  • editsByFile - 按文件分组的编辑(line/column/endColumn/oldText/newText/startOffset/endOffset
  • note - 特殊提示(如重命名类型需要重命名文件)

organize_imports

组织导入:移除未使用的导入、添加缺少的导入并重新排序。单文件和目录均直接写入磁盘。

参数:

  • filePath(必填)- 文件路径或目录路径(目录时自动递归)

单文件响应字段:

  • filePath - 文件路径
  • totalImports - 文件中总导入数
  • usedImports - 保留的常规导入数
  • unusedImports - 被移除的导入全限定名列表
  • organizedImportBlock - 组织后的导入块文本
  • hasChanges - 是否发生变化
  • importRange - 导入块在原文件中的范围(startLine/endLine/startOffset/endOffset
  • textEdit - 文本编辑内容(startLine/endLine/newText

目录响应字段:

  • filePath - 目录路径
  • totalFiles - 找到的 Java 文件数
  • changed - 已修改文件数
  • unchanged - 无需修改文件数
  • failed - 失败文件列表

format_code

格式化 Java 源文件。目录时自动递归,直接写入磁盘(使用 LSP 服务端默认缩进设置)。

参数:

  • filePath(必填)- 文件路径或目录路径(目录时自动递归)

返回字段(structuredContent):

  • filePath - 文件路径
  • hasChanges - 是否发生变化
  • editsApplied - 应用的编辑数
  • totalFiles - 目录模式下找到的文件数
  • changed/unchanged/failed - 目录模式统计