Building an MCP Server for Java Performance Profiling

Published: (March 13, 2026 at 02:11 AM EDT)
2 min read
Source: Dev.to

Source: Dev.to

Overview

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. With MCP, your AI assistant can handle all of that through natural conversation.

What is MCP?

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

  • Run diagnostics on your running Java apps
  • Analyze thread dumps
  • Inspect JFR recordings

All through conversational commands.

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

Configuration (Claude Desktop)

Add the server to your claude_desktop_config.json:

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

Usage Examples

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.

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.

  • GitHub:
  • npm:

Requirements

  • Node.js 18+
  • JDK 8u262+ or 11+

Conclusion

If you’re working with Java and using Claude Desktop or Cursor IDE, give javaperf a spin. Feedback on additional profiling features is welcome! Built with TypeScript, powered by the JDK tools you already have.

0 views
Back to Blog

Related posts

Read more »