Skip to main content

基于Arthas的JVM监控MCP服务器实现

Project description

JVM MCP Server

English | 中文

A JVM monitoring MCP server implementation based on Arthas, providing a simple and easy-to-use Python interface for monitoring and analyzing Java processes.

Features

  • Automatic download and management of Arthas tools
  • Support for local and remote Java process monitoring
  • Java process list querying
  • Real-time JVM thread information
  • JVM memory usage monitoring
  • Thread stack trace information
  • Class loading information querying
  • Support for class and method decompilation
  • Method call monitoring
  • Dynamic log level adjustment
  • AI-driven JVM performance analysis

System Requirements

  • Python 3.10+
  • Java Runtime Environment (JRE) 8+
  • Network connection (for downloading Arthas)
  • SSH access to target server (if using remote mode)

Installation and Environment Setup

1. Install uv tool

## linux shell
curl -LsSf https://astral.sh/uv/install.sh | sh
## or install using pip
pip install uv
## or install using pipx (if you have pipx installed)
pipx install uv 
## windows powershell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

2. Clone the project

git clone https://github.com/xzq-xu/jvm-mcp-server.git
cd jvm-mcp-server

3. Initialize project environment using uv

# Create virtual environment
uv venv
# Sync project dependencies
uv sync

4. Configure environment variables (Optional, for remote connections)

Create a .env file and add the following configurations:

# Linux/Mac
ARTHAS_SSH_HOST=user@remote-host
ARTHAS_SSH_PORT=22  # Optional, default is 22
ARTHAS_SSH_PASSWORD=your-password  # If using password authentication

# Windows PowerShell
$env:ARTHAS_SSH_HOST="user@remote-host"
$env:ARTHAS_SSH_PORT="22"  # Optional, default is 22
$env:ARTHAS_SSH_PASSWORD="your-password"  # If using password authentication

Quick Start

  1. Start the server using uv:
# Start in local mode
uv run jvm-mcp-server

# Start with environment file (if remote connection is configured)
uv run --env-file .env jvm-mcp-server

# Start in a specific directory (if needed)
uv --directory /path/to/project run --env-file .env jvm-mcp-server
  1. Use in Python code:
from jvm_mcp_server import JvmMcpServer

server = JvmMcpServer()
server.run()
  1. Using MCP tools:

Using configuration file:

{
    "mcpServers": {
      "jvm-mcp-server": {
        "command": "uv",
        "args": [
          "--directory",
          "/path/to/jvm-mcp-server",
          "run",
          "--env-file",
          "/path/to/jvm-mcp-server/.env",
          "jvm-mcp-server"
        ]
      }
    }
}

Without using configuration file, it will read system environment variables, if not present it will monitor local threads:

{
    "mcpServers": {
      "jvm-mcp-server": {
        "command": "uv",
        "args": [
          "--directory",
          "/path/to/jvm-mcp-server",
          "run",
          "jvm-mcp-server"
        ]
      }
    }
}

Available Tools

Available Tools List

Important Notes

  1. Ensure Java is installed in the runtime environment
  2. Arthas tool will be automatically downloaded on first run (arthas will be downloaded to home directory, can be downloaded in advance and named as arthas-boot.jar)
  3. Requires access permissions to target Java process
  4. Remote mode requires SSH access and appropriate user permissions
  5. Recommended for use in development environment, production use should be carefully evaluated

Feedback

If you encounter any issues, please submit an Issue or Pull Request.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mseep_jvm_mcp_server-0.1.1.tar.gz (53.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mseep_jvm_mcp_server-0.1.1-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file mseep_jvm_mcp_server-0.1.1.tar.gz.

File metadata

  • Download URL: mseep_jvm_mcp_server-0.1.1.tar.gz
  • Upload date:
  • Size: 53.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for mseep_jvm_mcp_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2e2ba08a012f78e92c4ad908f69c30050165ffee4edee81edc86be6cb6b3e0e1
MD5 bf45e197e4b5df5e57f0957bd565c8c5
BLAKE2b-256 b0e4b549a1feb5dd8cb742aaefd746981b39dd44960f4bc5ce73face2891bcb8

See more details on using hashes here.

File details

Details for the file mseep_jvm_mcp_server-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mseep_jvm_mcp_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ade8f5b948962f693b480f22b644bd112ae88e85ebaea36b3862a41b9b93e550
MD5 9e046763826c9ff4f54e34d292ec81f2
BLAKE2b-256 c57c42229bd935d224edd87403d57edd1cdd1dd84e49a4616dbf28af2d70dc01

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page