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