javaperf

编码与调试

by thesharque

基于 jcmd、jfr、jps 的 Java profiling MCP 工具,可诊断性能问题、分析线程并检查 JFR 录制数据。

什么是 javaperf

基于 jcmd、jfr、jps 的 Java profiling MCP 工具,可诊断性能问题、分析线程并检查 JFR 录制数据。

README

javaperf

npm version

MCP (Model Context Protocol) server for profiling Java applications via JDK utilities (jcmd, jfr, jps)

Enables AI assistants to diagnose performance, analyze threads, and inspect JFR recordings without manual CLI usage.

📦 Install: npm install -g javaperf or use via npx 🌐 npm: https://www.npmjs.com/package/javaperf

How to connect to Claude Desktop / IDE

Add the server to your MCP config. Example for claude_desktop_config.json:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json

json
{
  "mcpServers": {
    "javaperf": {
      "command": "npx",
      "args": ["-y", "javaperf"]
    }
  }
}

For Cursor IDE: Settings → Features → Model Context Protocol → Edit Config, then add the same block inside mcpServers. See the Integration section for more options (local dev, custom JAVA_HOME, etc.).

Requirements

  • Node.js v18+
  • JDK 8u262+ or 11+ with JFR support

JDK tools (jps, jcmd, jfr) are auto-detected via JAVA_HOME or which java. If not found, set JAVA_HOME to your JDK root.

Quick Start

For Users (using npm package)

bash
# No installation needed - use directly in Cursor/Claude Desktop
# Just configure it as described in Integration section below

For Developers

  1. Clone the repository:
bash
git clone https://github.com/theSharque/mcp-jperf.git
cd mcp-jperf
  1. Install dependencies:
bash
npm install
  1. Build the project:
bash
npm run build

Usage

Development Mode

bash
npm run dev

Production Mode

bash
npm start

MCP Inspector

Debug and test with MCP Inspector:

bash
npx @modelcontextprotocol/inspector node dist/index.js

Integration

Cursor IDE

  1. Open Cursor Settings → Features → Model Context Protocol
  2. Click "Edit Config" button
  3. Add one of the configurations below

Option 1: Via npm (Recommended)

Installs from npm registry automatically:

json
{
  "mcpServers": {
    "javaperf": {
      "command": "npx",
      "args": ["-y", "javaperf"]
    }
  }
}

Option 2: Via npm link (Development)

For local development with live changes:

json
{
  "mcpServers": {
    "javaperf": {
      "command": "javaperf"
    }
  }
}

Requires: cd /path/to/mcp-jperf && npm link -g

Option 3: Direct path

json
{
  "mcpServers": {
    "javaperf": {
      "command": "node",
      "args": ["dist/index.js"],
      "cwd": "${workspaceFolder}",
      "env": {
        "JAVA_HOME": "/path/to/your/jdk"
      }
    }
  }
}

If list_java_processes fails with "jps not found", the MCP server may not inherit your shell's JAVA_HOME. Add the env block above with your JDK root path (e.g. /usr/lib/jvm/java-17 or ~/.sdkman/candidates/java/current).

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

json
{
  "mcpServers": {
    "javaperf": {
      "command": "npx",
      "args": ["-y", "javaperf"]
    }
  }
}

Continue.dev

Edit .continue/config.json:

json
{
  "mcpServers": {
    "javaperf": {
      "command": "npx",
      "args": ["-y", "javaperf"]
    }
  }
}

Tools

ToolDescription
list_java_processesList running Java processes (pid, mainClass, args). Use topN (default 10) to limit.
start_profilingStart JFR recording with settings=profile. Pass pid, duration (seconds). Optional: memorysize (e.g. "20M"), stackdepth (default 128).
list_jfr_recordingsList active JFR recordings for a process. Use before stop_profiling to get recordingId.
stop_profilingStop recording and save to recordings/new_profile.jfr. Requires pid and recordingId.
check_deadlockCheck for Java-level deadlocks. Returns structured JSON with threads, locks, and cycle.
analyze_threadsThread dump (jstack) with deadlock summary. Pass pid, optional topN (default 10).
heap_histogramClass histogram (GC.class_histogram). Pass pid, optional topN (20), all (triggers full GC — may pause app).
heap_dumpCreate .hprof heap dump for MAT/VisualVM. Pass pid. Saved to recordings/heap_dump.hprof.
heap_infoBrief heap summary. Pass pid.
vm_infoJVM info: uptime, version, flags. Pass pid.
trace_methodBuild call tree for a method from .jfr. Pass className, methodName. Optional: filepath (default new_profile), topN.
parse_jfr_summaryParse .jfr into summary: top methods, GC stats, anomalies. Optional: filepath (default new_profile), events, topN.
profile_memoryMemory profile: top allocators, GC, potential leaks. Optional: filepath (default new_profile), topN.
profile_timeCPU bottleneck profile (bottom-up). Optional: filepath (default new_profile), topN.
profile_frequencyCall frequency profile (leaf frames). Optional: filepath (default new_profile), topN.

Example Workflow

  1. List processeslist_java_processes
  2. Start recordingstart_profiling with pid and duration (e.g. 60)
  3. Wait for duration seconds (or let it run)
  4. Check recordings (optional) → list_jfr_recordings to get recordingId
  5. Stop and savestop_profiling with pid and recordingId
  6. Analyze → Use parse_jfr_summary, profile_memory, profile_time, profile_frequency, or trace_method (filepath defaults to new_profile)

Limitations

  • Sampling: JFR samples ~10ms; fast methods may not appear in ExecutionSample
  • Local only: Runs on the machine where MCP is started
  • Permissions: Must run as same user as target JVM for jcmd access

常见问题

javaperf 是什么?

基于 jcmd、jfr、jps 的 Java profiling MCP 工具,可诊断性能问题、分析线程并检查 JFR 录制数据。

相关 Skills

网页构建器

by anthropics

Universal
热门

面向复杂 claude.ai HTML artifact 开发,快速初始化 React + Tailwind CSS + shadcn/ui 项目并打包为单文件 HTML,适合需要状态管理、路由或多组件交互的页面。

在 claude.ai 里做复杂网页 Artifact 很省心,多组件、状态和路由都能顺手搭起来,React、Tailwind 与 shadcn/ui 组合效率高、成品也更精致。

编码与调试
未扫描114.1k

前端设计

by anthropics

Universal
热门

面向组件、页面、海报和 Web 应用开发,按鲜明视觉方向生成可直接落地的前端代码与高质感 UI,适合做 landing page、Dashboard 或美化现有界面,避开千篇一律的 AI 审美。

想把页面做得既能上线又有设计感,就用前端设计:组件到整站都能产出,难得的是能避开千篇一律的 AI 味。

编码与调试
未扫描114.1k

网页应用测试

by anthropics

Universal
热门

用 Playwright 为本地 Web 应用编写自动化测试,支持启动开发服务器、校验前端交互、排查 UI 异常、抓取截图与浏览器日志,适合调试动态页面和回归验证。

借助 Playwright 一站式验证本地 Web 应用前端功能,调 UI 时还能同步查看日志和截图,定位问题更快。

编码与调试
未扫描114.1k

相关 MCP Server

GitHub

编辑精选

by GitHub

热门

GitHub 是 MCP 官方参考服务器,让 Claude 直接读写你的代码仓库和 Issues。

这个参考服务器解决了开发者想让 AI 安全访问 GitHub 数据的问题,适合需要自动化代码审查或 Issue 管理的团队。但注意它只是参考实现,生产环境得自己加固安全。

编码与调试
83.4k

by Context7

热门

Context7 是实时拉取最新文档和代码示例的智能助手,让你告别过时资料。

它能解决开发者查找文档时信息滞后的问题,特别适合快速上手新库或跟进更新。不过,依赖外部源可能导致偶尔的数据延迟,建议结合官方文档使用。

编码与调试
52.2k

by tldraw

热门

tldraw 是让 AI 助手直接在无限画布上绘图和协作的 MCP 服务器。

这解决了 AI 只能输出文本、无法视觉化协作的痛点——想象让 Claude 帮你画流程图或白板讨论。最适合需要快速原型设计或头脑风暴的开发者。不过,目前它只是个基础连接器,你得自己搭建画布应用才能发挥全部潜力。

编码与调试
46.3k

评论