Skip to main content
Glama
JVM MCP Server
by xzq-xu

Servidor MCP de JVM

Inglés | Chino

Una implementación de servidor MCP de monitoreo de JVM basada en Arthas, que proporciona una interfaz Python simple y fácil de usar para monitorear y analizar procesos Java.

Características

  • Descarga y gestión automática de herramientas de Arthas

  • Soporte para la monitorización de procesos Java locales y remotos

  • Consulta de lista de procesos de Java

  • Información de subprocesos de JVM en tiempo real

  • Monitoreo del uso de memoria de JVM

  • Información de seguimiento de la pila de subprocesos

  • Consulta de información de carga de clases

  • Soporte para la descompilación de clases y métodos

  • Monitoreo de llamadas de método

  • Ajuste dinámico del nivel de registro

  • Análisis del rendimiento de JVM impulsado por IA

Related MCP server: Arthas MCP Server

Requisitos del sistema

  • Python 3.10+

  • Entorno de ejecución de Java (JRE) 8+

  • Conexión de red (para descargar Arthas)

  • Acceso SSH al servidor de destino (si se utiliza el modo remoto)

Instalación y configuración del entorno

1. Instalar la herramienta UV

## 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. Clonar el proyecto

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

3. Inicializar el entorno del proyecto usando uv

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

4. Configurar variables de entorno (opcional, para conexiones remotas)

Cree un archivo .env y agregue las siguientes configuraciones:

# 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

Inicio rápido

  1. Inicie el servidor usando 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. Uso en código Python:

from jvm_mcp_server import JvmMcpServer

server = JvmMcpServer()
server.run()
  1. Usando herramientas MCP:

Usando el archivo de configuración:

{
    "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"
        ]
      }
    }
}

Sin usar el archivo de configuración, leerá las variables de entorno del sistema, si no están presentes, monitoreará los subprocesos locales:

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

Herramientas disponibles

Lista de herramientas disponibles

Notas importantes

  1. Asegúrese de que Java esté instalado en el entorno de ejecución

  2. La herramienta Arthas se descargará automáticamente en la primera ejecución (arthas se descargará al directorio de inicio, puede descargarse con anticipación y nombrarse como arthas-boot.jar)

  3. Requiere permisos de acceso al proceso Java de destino

  4. El modo remoto requiere acceso SSH y permisos de usuario adecuados

  5. Recomendado para uso en entornos de desarrollo, el uso en producción debe evaluarse cuidadosamente.

Comentario

Si encuentra algún problema, envíe un problema o una solicitud de extracción.

Licencia

Licencia MIT

Available Tools

16 tools
decompile_classB

反编译指定类的源码

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")
            class_pattern (str): 类名表达式匹配
            method_pattern (Optional[str]): 可选的方法名表达式

        Returns:
            Dict: 包含反编译源码的字典(暂未实现)
        

Inputs: pid, class_pattern, method_pattern.

get_class_infoB

获取类信息 - 使用jmap -histo和javap命令获取完整的类信息

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")
            class_pattern (str): 类名表达式匹配
            show_detail (bool): 是否显示详细信息,默认false
            show_field (bool): 是否显示成员变量信息(需要show_detail=True),默认false
            use_regex (bool): 是否使用正则表达式匹配,默认false
            depth (str): 属性遍历深度(暂未使用)
            classloader_hash (Optional[str]): 指定class的ClassLoader的hashcode(暂未使用)
            classloader_class (Optional[str]): 指定执行表达式的ClassLoader的class name(暂未使用)
            max_matches (str): 匹配类的最大数量,使用字符串形式(如:"50")

        Returns:
            Dict: 包含类信息的字典
        

Inputs: pid, class_pattern, show_detail, show_field, +5 more.

get_dashboardC

获取系统实时数据面板

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")

        Returns:
            Dict: 包含系统实时数据的字典(暂未实现)
        

Inputs: pid.

get_jcmd_outputB

执行 jcmd 子命令

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")
            subcommand (Optional[str]): jcmd子命令,如果不指定则执行help命令

        Returns:
            Dict: 包含jcmd执行结果的字典,包含以下字段:
                - raw_output (str): 原始输出
                - timestamp (float): 时间戳
                - success (bool): 是否成功
                - error (Optional[str]): 错误信息
        

Inputs: pid, subcommand.

get_jstat_outputA

执行 jstat 监控命令

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")
            option (Optional[str]): jstat选项,如gc、class、compiler等
            interval (str): 采样间隔(毫秒),使用字符串形式(如:"1000"表示1秒)
            count (str): 采样次数,使用字符串形式(如:"10")

        Returns:
            Dict: 包含jstat执行结果的字典,包含以下字段:
                - raw_output (str): 原始输出
                - timestamp (float): 时间戳
                - success (bool): 是否成功
                - error (Optional[str]): 错误信息
        

Inputs: pid, option, interval, count.

get_jvm_infoA

获取JVM基础信息

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")。
                支持十进制和十六进制格式。
                空字符串将返回错误信息。

        Returns:
            Dict: 包含JVM信息的字典,包含以下字段:
                - raw_output (str): 原始输出
                - timestamp (float): 时间戳
                - success (bool): 是否成功
                - error (Optional[str]): 错误信息
        

Inputs: pid.

get_jvm_statusB

获取JVM整体状态报告

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")。
                如果不指定则自动选择第一个Java进程
        
        Returns:
            Dict: 包含JVM状态信息的字典(暂未实现)
        

Inputs: pid.

get_logger_infoC

获取logger信息

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")
            name (Optional[str]): logger名称,如果不指定则获取所有logger信息

        Returns:
            Dict: 包含logger信息的字典(暂未实现)
        

Inputs: pid, name.

get_memory_infoA

获取内存使用情况

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")。
                支持十进制和十六进制格式。
                空字符串将返回错误信息。

        Returns:
            Dict: 包含内存信息的字典,包含以下字段:
                - raw_output (str): 原始输出
                - timestamp (float): 时间戳
                - success (bool): 是否成功
                - error (Optional[str]): 错误信息
        

Inputs: pid.

get_stack_traceA

获取线程堆栈信息

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")
            thread_id (str): 线程ID,使用字符串形式。支持十六进制(如:"0x2c03")
            top_n (str): 显示前N个线程,使用字符串形式(如:"5"),默认值为"5"
            find_blocking (bool): 是否只查找阻塞线程(BLOCKED状态或等待锁的线程)
            interval (str): 采样间隔,使用字符串形式(如:"1000"表示1秒)
            show_all (bool): 是否显示所有信息

        Returns:
            Dict: 包含线程堆栈信息的字典,包含以下字段:
                - threads (List[Dict]): 线程信息列表
                - thread_count (int): 线程数量
                - raw_output (str): 原始输出
                - timestamp (float): 时间戳
                - success (bool): 是否成功
                - error (Optional[str]): 错误信息
        

Inputs: pid, thread_id, top_n, find_blocking, +2 more.

get_stack_trace_by_methodB

获取方法的调用路径

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")
            class_pattern (str): 类名表达式匹配
            method_pattern (str): 方法名表达式匹配
            condition (Optional[str]): 条件表达式,例如:'params[0]<0' 或 '#cost>10'
            use_regex (bool): 是否开启正则表达式匹配,默认为通配符匹配
            max_matches (str): Class最大匹配数量,使用字符串形式(如:"50")
            max_times (str): 执行次数限制,使用字符串形式

        Returns:
            Dict: 包含方法调用路径信息的字典(暂未实现)
        

Inputs: pid, class_pattern, method_pattern, condition, +3 more.

get_thread_infoA

获取指定进程的线程信息

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")。
                支持十进制和十六进制格式。
                空字符串将返回错误信息。

        Returns:
            Dict: 包含线程信息的字典,包含以下字段:
                - threads (List[Dict]): 线程信息列表
                - thread_count (int): 线程数量
                - raw_output (str): 原始输出
                - timestamp (float): 时间戳
                - success (bool): 是否成功
                - error (Optional[str]): 错误信息
        

Inputs: pid.

list_java_processesA

列出所有Java进程

        Returns:
            List[Dict[str, str]]: 包含Java进程信息的列表,每个进程包含以下字段:
                - pid (str): 进程ID
                - name (str): 进程名称
                - args (str): 进程参数
        

Inputs: no named parameters.

search_methodC

查看类的方法信息

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")
            class_pattern (str): 类名表达式匹配
            method_pattern (Optional[str]): 可选的方法名表达式
            show_detail (bool): 是否展示每个方法的详细信息
            use_regex (bool): 是否开启正则表达式匹配,默认为通配符匹配
            classloader_hash (Optional[str]): 指定class的ClassLoader的hashcode
            classloader_class (Optional[str]): 指定执行表达式的ClassLoader的class name
            max_matches (str): 匹配类的最大数量,使用字符串形式(如:"100")

        Returns:
            Dict: 包含方法信息的字典(暂未实现)
        

Inputs: pid, class_pattern, method_pattern, show_detail, +4 more.

set_logger_levelC

设置logger级别

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")
            name (str): logger名称
            level (str): 日志级别

        Returns:
            Dict: 设置结果的字典(暂未实现)
        

Inputs: pid, name, level.

watch_methodC

监控方法的调用情况

        Args:
            pid (str): 进程ID,使用字符串形式(如:"12345")
            class_pattern (str): 类名表达式匹配
            method_pattern (str): 方法名表达式匹配
            watch_params (bool): 是否监控方法参数
            watch_return (bool): 是否监控方法返回值
            condition (Optional[str]): 条件表达式
            max_times (str): 最大监控次数,使用字符串形式(如:"10")

        Returns:
            Dict: 包含方法监控信息的字典(暂未实现)
        

Inputs: pid, class_pattern, method_pattern, watch_params, +3 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 16 tools

    Disambiguation4/5

    Most tools have distinct purposes targeting specific JVM diagnostics (e.g., get_memory_info vs. get_thread_info), but some overlap exists: get_class_info and search_method both retrieve class/method details, and get_stack_trace and get_stack_trace_by_method both handle stack traces, which could cause confusion. However, their descriptions clarify the differences.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with snake_case (e.g., get_jvm_info, list_java_processes, set_logger_level). There are no deviations in naming conventions, making the set predictable and easy to parse.

    Tool Count4/5

    With 16 tools, the count is slightly high but reasonable for a JVM diagnostics server covering processes, memory, threads, classes, and logging. It avoids being excessive (under 25) and provides comprehensive coverage, though some tools could potentially be consolidated.

    Completeness4/5

    The toolset covers core JVM diagnostics well: process listing, memory, threads, class inspection, and logging. However, there are notable gaps: several tools are marked as '暂未实现' (not yet implemented), including key ones like decompile_class and get_dashboard, which limits functionality. Additionally, there's no tool for modifying JVM settings beyond logger levels.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables dynamic SSH connection to servers for real-time JVM diagnostics using Arthas, allowing operations like thread dump, heap inspection, and method watching through MCP tools.
      MIT
    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      Java diagnostics MCP server for LLM integration with Alibaba Arthas, enabling analysis and diagnosis of Java applications.
      58
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      MCP 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.
      26
      63 npm
      10
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A Model Context Protocol server that connects AI agents to live Java processes via Alibaba Arthas, enabling real-time diagnostics, debugging, and performance analysis without code changes.
      25
      MIT