Building an MCP Server for Java Performance Profiling

I built javaperf – an MCP (Model Context Protocol) server that lets AI assistants profile Java applications without touching the command line.

If you’ve ever debugged Java performance issues, you know the drill: jps, jcmd, jfr… memorizing flags, parsing output. What if your AI assistant could do this for you?

What is MCP?

Model Context Protocol (MCP) is a standard for connecting AI assistants to external tools. Instead of AI just generating code suggestions, it can actually:

  • Run diagnostics on your running Java apps
  • Analyze thread dumps
  • Inspect JFR recordings
  • All through natural conversation

javaperf Features

  • Process Discovery: Auto-detect running Java processes via jps
  • Thread Analysis: Dump and analyze threads (jcmd Thread.print)
  • VM Flags: Inspect JVM configuration
  • JFR Support: Record and analyze Java Flight Recorder data
  • Performance Counters: Access low-level JVM metrics

Installation

npm install -g javaperf

Or use directly via npx (no install needed):

npx javaperf

Connecting to Claude Desktop

Add to your claude_desktop_config.json:

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

Example Usage

Once connected, you can ask Claude things like:

  • “Show me all running Java processes”
  • “Analyze thread dump for process 1234”
  • “Start a 60-second JFR recording”
  • “Why is my app using so much memory?”

The AI handles the jcmd, jfr, and jps commands behind the scenes.

Why This Matters

Before MCP: You Google the right flags, copy-paste commands, manually parse output.

After MCP: “Hey Claude, why is my Spring Boot app slow?” → AI investigates → Finds thread contention → Suggests fixes.

Try It Out

If you’re working with Java and using Claude Desktop or Cursor IDE, give it a spin. Would love feedback on what other profiling features would be useful!

Built with TypeScript, powered by JDK tools you already have.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

Before quantum computing arrives, this startup wants enterprises already running on it

Next Post

Spotlight on the ASQ Fellows Innovation Think Tank

Related Posts
arkui-x平台差异化

ArkUI-X平台差异化

跨平台使用场景是一套ArkTS代码运行在多个终端设备上,如Android、iOS、OpenHarmony(含基于OpenHarmony发行的商业版,如HarmonyOS Next)。当不同平台业务逻辑不同,或使用了不支持跨平台的API,就需要根据平台不同进行一定代码差异化适配。当前仅支持在代码运行态进行差异化,接下来详细介绍场景及如何差异化适配。 使用场景 平台差异化适用于以下两种典型场景: 1.自身业务逻辑不同平台本来就有差异; 2.在OpenHarmony上调用了不支持跨平台的API,这就需要在OpenHarmony上仍然调用对应API,其他平台通过Bridge桥接机制进行差异化处理; 判断平台类型 可以通过let osName: string = deviceInfo.osFullName;获取对应OS名字,该接口已支持跨平台,不同平台上其返回值如下: OpenHarmony上,osName等于OpenHarmony-XXX Android上,osName等于Android XXX iOS上,osName等于iOS XXX 示例如下:…
Read More