Cursor Mcp For Java

MCP开发工具

提供方 saikaNya · 包名 vscode-as-mcp-server

开发工具 stdio · 本地进程 API Key 社区 / 第三方 Claude DesktopClaudeCursorVS Code
查看接入方式

一个Cursor或VSCode插件,可将您的VSCode或Cursor作为MCP服务器,为MCP客户端(如Cursor、VSCode copilot、Claude Desktop、Cherry studio)提供高级编码辅助功能。如获取项目中的类,与通过全限定名获取类的源代码等(包含项目源代码,以及项目中所有可访问依赖中的类

一句话选型结论

按资料字段整理

Cursor Mcp For Java 属于开发工具类 MCP 服务器,stdio · 本地进程,API Key,可直接接入 Claude Desktop、Claude、Cursor 等,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类开发工具 传输方式stdio · 本地进程 鉴权API Key 部署方式本地部署
GitHub 星标 未标注 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

开发工具
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

vscode cursor java

支持客户端

适用场景

vscodecursorjava

安装与配置

stdio · 本地进程 API Key
客户端在本机拉起子进程,数据不出本机
npx vscode-as-mcp-server

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 Cross-platform,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
代码与仓库操作

在对话里直接查代码、提 issue、走 PR,省掉来回切工具。

本地命令与脚本

把构建、测试、格式化这类重复命令交给模型执行。

接口联调与测试

让模型调你的接口、跑一遍用例,快速定位问题。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 Claude Desktop、Claude、Cursor,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 使用前要准备好API Key对应的凭据,并按最小权限配置。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在开发工具场景里让模型直接调用外部能力的人。
  • 已经在用 Claude Desktop、Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 不方便管理密钥或第三方授权的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
Cursor Mcp For Java当前 未标注 stdio · 本地进程 本地部署 有 未标注
Git 838e2ec1 12 stdio · 本地进程 本地部署 有 2026-05-17
Markitdown MCP 2c653a5f 1 stdio · 本地进程 本地部署 有 2026-05-17
JavaGuide 未标注 stdio · 本地进程 本地部署 有 2026-04-11
awesome-claude-skills 未标注 stdio · 本地进程 本地部署 有 2026-04-26
Context7 831acf40 未标注 stdio · 本地进程 本地部署 有 2026-05-17

服务器档案

开发工具
字段来自项目仓库与公开索引,中文说明由本站标注
提供方saikaNya上游标注的维护方 saikaNya
分类开发工具本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式API Key远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时vscode-as-mcp-server · Cross-platform本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验未标注上游最后核验时间

详细介绍

23.2 KB
来自项目仓库与上游目录的原文,未做删改

中文 | English

MCP Server For Java

> ⚠️ v0.0.3 重要更新
>
> MCP 客户端配置需要从:
>json > { > "command": "npx", > "args": ["vscode-as-mcp-server"] > } >
> 或
>json > { > "url": "http://localhost:60100" > } >
> 修改为:
>json > { > "command": "npx", > "args": ["vscode-to-mcp-server"] > } >
> 如果不修改配置,将无法自动在多工作区间切换,只能获取第一个打开的工作区的类。

简介

Cursor、Github Copilot、Windsurf 等基于 VSCode 开发的 AI Code Agent 在编写 Java 项目时,可以访问项目本身的源代码,但无法获取项目依赖的类定义与源码。

本插件将 VSCode/Cursor 转变为 MCP 服务器,让 AI Agent 能够:
- 搜索 Java 类型:通过名称或部分名称在项目、外部依赖和 JDK 中搜索类 ————对应mcp工具searchJavaTypes
- 获取源代码:通过全限定名获取任意可访问类的源码(包括依赖库和 JDK)————对应mcp工具getSourceCodeByFQN

多工作区支持

  • v0.0.3 之前:通过点击状态栏在多个 VSCode/Cursor 工作区之间切换 MCP 服务器
  • v0.0.3 起:支持同时连接多个工作区,除非用户指定 AI Agent 会自动选择当前活动窗口对应的工作区

首次安装与设置

  1. 安装以下任意一种 Java Language Server 插件,并确保它可以正常运行 Java 项目(建议只启用一种,以免语言功能冲突):

    • Extension Pack for Java:微软插件市场 / Open VSX
    • Java and Kotlin by IntelliJ IDEA:微软插件市场 / Open VSX
  2. 下载安装本插件。

  3. 配置您的MCP客户端,重启并确认mcp工具加载完成:

    • 如Claude Desktop,Curosr,Winsurf,Vsocde,Cherry studio等客户端:添加以下内容到您的配置文件(claude_desktop_config.json)中:json { "mcpServers": { "vscode-java": { "command": "npx", "args": [ "vscode-to-mcp-server" ] } } }
  4. 打开一个 Java 项目,等待项目导入、依赖解析和索引完成,并确认 Java Language Server 已就绪:

    • 使用 Extension Pack for Java 时,状态栏中的 Java 项目加载状态应显示为已完成:

    • 使用 Java and Kotlin by IntelliJ IDEA 时,点击状态栏中的 Java and Kotlin,状态菜单应显示 Running;正式版还应显示许可证已激活:

提高工具调用率(推荐配置)

为了让 AI Agent 更主动地调用本插件提供的工具,建议在系统提示词中添加以下内容(如果你没有更好或者更适合自己应用场景的提示词):```txt
通过项目源代码找不到的类或类的定义或方法具体实现,且有类名或者部分类名时,可以使用工具 searchJavaTypes 与 getSourceCodeByFQN 判断其是否存在,或获取其源代码

> 💡 以 Cursor 为例,可以在 **Settings → General → Rules for AI → User Rules** 中添加

## 插件参数声明

| 参数 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| `mcpServer.maxOutputLength` | number | `70000` | 最大输出 Java 源代码字符数。当要获取的类的源代码超过此限制时会报错。不建议设置过大,过大会导致模型 input token 过大无法请求模型,或无法将类的源代码放入上下文中。 |
| `mcpServer.enableRelayVersionCheck` | boolean | `true` | 是否启用 relay 版本更新检查和通知。设置为 `false` 可禁用版本更新提醒。 |

## 联系
**非常欢迎大家对插件的问题,bug或新功能建议进行反馈!** 🙇

## 更新日志
- **0.0.8** 兼容 Java and Kotlin by IntelliJ IDEA 插件
- **0.0.7** 多根工作区支持
- **0.0.5** 获取源码时,支持按方法名过滤
- **0.0.4** 支持获取工作区中存在的全限定名相同但版本不同的类
- **0.0.3** mcp指令执行在多个工作区自动路由,无需手动切换
- **0.0.2** 修改了查询全限定名有时候会查出不符合条件的结果的bug

## 架构说明

### 整体架构```
┌─────────────────────────────────────────────────────────────────────────────┐
│                              MCP 客户端                                      │
│                  (Claude Desktop / Cursor / Windsurf 等)                     │
└─────────────────────────────────────────────────────────────────────────────┘
                                    │
                                    │ stdio (JSON-RPC)
                                    ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│                          Relay (vscode-to-mcp-server)                        │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │  - 接收 MCP 客户端请求                                                │    │
│  │  - 读取路由表,查找目标 Extension                                      │    │
│  │  - 通过 Socket 转发请求到 Extension                                   │    │
│  │  - 返回响应给 MCP 客户端                                              │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────────────────────┘
                                    │
                   ┌────────────────┼────────────────┐
                   │                │                │
                   ▼                ▼                ▼
          ┌──────────────┐  ┌──────────────┐  ┌──────────────┐
          │   Named Pipe │  │   Named Pipe │  │   Named Pipe │
          │  (Windows)   │  │  (Windows)   │  │  (Windows)   │
          │    或        │  │    或        │  │    或        │
          │ Unix Socket  │  │ Unix Socket  │  │ Unix Socket  │
          │   (其他)     │  │   (其他)     │  │   (其他)     │
          └──────────────┘  └──────────────┘  └──────────────┘
                   │                │                │
                   ▼                ▼                ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│                      VSCode/Cursor Extension 实例                            │
│  ┌─────────────┐   ┌─────────────┐   ┌─────────────┐                        │
│  │ 工作区 A    │   │ 工作区 B    │   │ 工作区 C    │   ...                  │
│  │ PID: 12345  │   │ PID: 23456  │   │ PID: 34567  │                        │
│  └─────────────┘   └─────────────┘   └─────────────┘                        │
│         │                │                │                                  │
│         ▼                ▼                ▼                                  │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │                    Java Language Server (JDT.LS)                     │    │
│  │            搜索类型 / 获取源代码 / 解析 Java 项目                      │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────────────────────┘

核心组件

组件 包名 说明
Extension packages/extension VSCode/Cursor 插件,提供 MCP 服务器功能
Relay packages/relay 命令行中继程序,桥接 MCP 客户端与 Extension

Socket 通信机制

平台差异

平台 通信方式 路径格式
Windows Named Pipe (命名管道) \\.\pipe\vscode-mcp-{pid}
macOS/Linux Unix Domain Socket ~/.vscode-mcp-sockets/{pid}.sock

路由表

路由表文件存储在用户主目录:`~/.vscode-mcp-router-v2.json````json
{
"entries": [
{
"workspaces": ["d:\project\workspace-a"],
"pid": 12345,
"lastUpdated": 1700000000000
}
]
}


#### 通信协议

- **格式**: JSON-RPC 2.0
- **分隔符**: 换行符 `\n`
- **超时**: 连接 5秒 / 请求 30秒

#### 请求头

| Header | 说明 |
|--------|------|
| `X-Relay-Version` | Relay 版本号,用于兼容性检查 |
| `X-MCP-Client` | MCP 客户端标识 |

### 数据流```
1. MCP 客户端调用工具 (如 searchJavaTypes)
                    │
                    ▼
2. Relay 接收 stdio 请求
                    │
                    ▼
3. Relay 读取路由表,根据 workspacePaths 查找目标 PID
                    │
                    ▼
4. Relay 通过 Socket 发送 JSON-RPC 请求到 Extension
                    │
                    ▼
5. Extension 调用 Java Language Server 执行操作
                    │
                    ▼
6. Extension 返回结果给 Relay
                    │
                    ▼
7. Relay 返回结果给 MCP 客户端

关键文件

文件 说明
extension/src/extension.ts 插件入口,初始化 MCP 服务器
extension/src/mcp-server.ts MCP 服务器实现,注册工具
extension/src/sock-transport.ts Socket 服务端传输层
extension/src/utils/router-table.ts 路由表管理(读写)
relay/src/index.ts Relay 入口,请求转发
relay/src/socket-client.ts Socket 客户端
relay/src/router-table.ts 路由表读取(只读)

MCP Server For Java

> ⚠️ v0.0.3 Important Update
>
> MCP client configuration needs to be changed from:
>json > { > "command": "npx", > "args": ["vscode-as-mcp-server"] > } >
> or
>json > { > "url": "http://localhost:60100" > } >
> to:
>json > { > "command": "npx", > "args": ["vscode-to-mcp-server"] > } >
> Without updating the configuration, automatic multi-workspace switching will not work, and only classes from the first opened workspace will be accessible.

Overview

AI Code Agents based on VSCode (such as Cursor, Github Copilot, Windsurf) can access a Java project's own source code, but cannot retrieve class definitions and source code from project dependencies.

This extension turns VSCode/Cursor into an MCP server, enabling AI Agents to:
- Search Java Types: Search for classes by name or partial name across your project, external dependencies, and JDK — corresponding MCP tool searchJavaTypes
- Get Source Code: Retrieve source code of any accessible class by fully qualified name (including dependency libraries and JDK) — corresponding MCP tool getSourceCodeByFQN

Multi-Workspace Support

  • Before v0.0.3: Switch MCP server between multiple VSCode/Cursor workspaces by clicking the status bar
  • From v0.0.3: Supports connecting to multiple workspaces simultaneously. Unless specified by the user, AI Agent will automatically select the workspace corresponding to the currently active window

Installation & Setup

  1. Install either of the following Java Language Server extensions and make sure it can run Java projects normally (enable only one to avoid conflicting language features):

    • Extension Pack for Java: VS Marketplace / Open VSX
    • Java and Kotlin by IntelliJ IDEA: VS Marketplace / Open VSX
  2. Download and install this extension.

  3. Configure your MCP client, restart and confirm MCP tools are loaded:

    • For clients like Claude Desktop, Cursor, Winsurf, VSCode, Cherry studio: Add the following to your configuration file (claude_desktop_config.json):json { "mcpServers": { "vscode-java": { "command": "npx", "args": [ "vscode-to-mcp-server" ] } } }
  4. Open a Java project, wait for project import, dependency resolution, and indexing to finish, and verify that the Java Language Server is ready:

    • With Extension Pack for Java, the Java project loading status in the status bar should show that loading is complete:

    • With Java and Kotlin by IntelliJ IDEA, click Java and Kotlin in the status bar and verify that its status menu displays Running. Stable releases should also show an active license:

Improve Tool Invocation Rate (Recommended Configuration)

To help AI Agents invoke the tools provided by this extension more proactively, it is recommended to add the following content to your system prompt (if you don't have a better or more suitable prompt for your use case):```txt
When you cannot find the class, class definition, or specific implementation of methods through the project source code, and you have the class name or partial class name, you can use the tools searchJavaTypes and getSourceCodeByFQN to check if it exists or get its source code

> 💡 For example, in Cursor, you can add this in **Settings → General → Rules for AI → User Rules**

## Extension Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `mcpServer.maxOutputLength` | number | `70000` | Maximum number of characters for Java source code output. An error will be reported when the source code exceeds this limit. It is not recommended to set it too large, as excessive values may cause the model's input token to be too large or make it impossible to place the class source code in the context. |
| `mcpServer.enableRelayVersionCheck` | boolean | `true` | Whether to enable relay version update check and notification. Set to `false` to disable version update warnings. |

## Contact
**Feedback on issues, bugs, or suggestions for new features is highly welcomed!** 🙇

## Changelog
- **0.0.8** Add compatibility with the Java and Kotlin by IntelliJ IDEA extension
- **0.0.7** Multi-root workspace support
- **0.0.5** Support filtering by method names when retrieving source code
- **0.0.4** Support for retrieving classes with the same fully qualified name from multiple versions
- **0.0.3** MCP commands auto-route to multiple workspaces without manual switching
- **0.0.2** Fixed a bug where querying fully qualified names sometimes returned non-matching results

## Architecture

### Overview```
┌─────────────────────────────────────────────────────────────────────────────┐
│                              MCP Client                                      │
│                  (Claude Desktop / Cursor / Windsurf, etc.)                  │
└─────────────────────────────────────────────────────────────────────────────┘
                                    │
                                    │ stdio (JSON-RPC)
                                    ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│                          Relay (vscode-to-mcp-server)                        │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │  - Receives MCP client requests                                      │    │
│  │  - Reads router table to find target Extension                       │    │
│  │  - Forwards requests to Extension via Socket                         │    │
│  │  - Returns responses to MCP client                                   │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────────────────────┘
                                    │
                   ┌────────────────┼────────────────┐
                   │                │                │
                   ▼                ▼                ▼
          ┌──────────────┐  ┌──────────────┐  ┌──────────────┐
          │   Named Pipe │  │   Named Pipe │  │   Named Pipe │
          │  (Windows)   │  │  (Windows)   │  │  (Windows)   │
          │     or       │  │     or       │  │     or       │
          │ Unix Socket  │  │ Unix Socket  │  │ Unix Socket  │
          │   (Others)   │  │   (Others)   │  │   (Others)   │
          └──────────────┘  └──────────────┘  └──────────────┘
                   │                │                │
                   ▼                ▼                ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│                      VSCode/Cursor Extension Instances                       │
│  ┌─────────────┐   ┌─────────────┐   ┌─────────────┐                        │
│  │ Workspace A │   │ Workspace B │   │ Workspace C │   ...                  │
│  │ PID: 12345  │   │ PID: 23456  │   │ PID: 34567  │                        │
│  └─────────────┘   └─────────────┘   └─────────────┘                        │
│         │                │                │                                  │
│         ▼                ▼                ▼                                  │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │                    Java Language Server (JDT.LS)                     │    │
│  │          Search types / Get source code / Parse Java projects        │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────────────────────┘

Core Components

Component Package Description
Extension packages/extension VSCode/Cursor extension providing MCP server functionality
Relay packages/relay CLI relay program bridging MCP client and Extension

Socket Communication

Platform Differences

Platform Method Path Format
Windows Named Pipe \\.\pipe\vscode-mcp-{pid}
macOS/Linux Unix Domain Socket ~/.vscode-mcp-sockets/{pid}.sock

Router Table

Router table file is stored in user home directory: `~/.vscode-mcp-router-v2.json````json
{
"entries": [
{
"workspaces": ["d:\project\workspace-a"],
"pid": 12345,
"lastUpdated": 1700000000000
}
]
}


#### Communication Protocol

- **Format**: JSON-RPC 2.0
- **Delimiter**: Newline `\n`
- **Timeout**: Connection 5s / Request 30s

#### Request Headers

| Header | Description |
|--------|-------------|
| `X-Relay-Version` | Relay version for compatibility check |
| `X-MCP-Client` | MCP client identifier |

### Data Flow```
1. MCP client calls a tool (e.g., searchJavaTypes)
                    │
                    ▼
2. Relay receives stdio request
                    │
                    ▼
3. Relay reads router table, finds target PID by workspacePaths
                    │
                    ▼
4. Relay sends JSON-RPC request to Extension via Socket
                    │
                    ▼
5. Extension calls Java Language Server to execute operation
                    │
                    ▼
6. Extension returns result to Relay
                    │
                    ▼
7. Relay returns result to MCP client

Key Files

File Description
extension/src/extension.ts Extension entry point, initializes MCP server
extension/src/mcp-server.ts MCP server implementation, registers tools
extension/src/sock-transport.ts Socket server transport layer
extension/src/utils/router-table.ts Router table management (read/write)
relay/src/index.ts Relay entry point, request forwarding
relay/src/socket-client.ts Socket client
relay/src/router-table.ts Router table reading (read-only)

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
Cursor Mcp For Java 怎么安装?

在客户端按下面的安装命令接入:npx vscode-as-mcp-server。对应的包名是 vscode-as-mcp-server。装完在客户端配置里引用同一个包或端点。

Cursor Mcp For Java 怎么在 Claude Desktop、Claude、Cursor 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

Cursor Mcp For Java 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Cursor Mcp For Java 需要 API Key 吗?

资料标注需要API Key认证,使用前准备好对应凭据,并按最小权限配置。

Cursor Mcp For Java 支持哪些客户端?

资料标注支持 Claude Desktop、Claude、Cursor、VS Code、Windsurf、Codex;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

Cursor Mcp For Java 能提供哪些能力?

资料显示能力标签包括 vscode、cursor、java。具体工具清单以官方文档为准。

Cursor Mcp For Java 需要什么运行环境?

运行时为 Cross-platform;属于本地进程,需要在本机装好运行环境。

Cursor Mcp For Java 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 未标注。