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

JVM MCP 서버

영어 | 중국어

Arthas를 기반으로 한 JVM 모니터링 MCP 서버 구현으로, Java 프로세스를 모니터링하고 분석하기 위한 간단하고 사용하기 쉬운 Python 인터페이스를 제공합니다.

특징

  • Arthas 도구의 자동 다운로드 및 관리

  • 로컬 및 원격 Java 프로세스 모니터링 지원

  • Java 프로세스 목록 쿼리

  • 실시간 JVM 스레드 정보

  • JVM 메모리 사용량 모니터링

  • 스레드 스택 추적 정보

  • 클래스 로딩 정보 쿼리

  • 클래스 및 메서드 디컴파일 지원

  • 메서드 호출 모니터링

  • 동적 로그 레벨 조정

  • AI 기반 JVM 성능 분석

Related MCP server: Arthas MCP Server

시스템 요구 사항

  • 파이썬 3.10+

  • 자바 런타임 환경(JRE) 8+

  • 네트워크 연결(아서스 다운로드용)

  • 대상 서버에 대한 SSH 액세스(원격 모드를 사용하는 경우)

설치 및 환경 설정

1. UV 도구 설치

지엑스피1

2. 프로젝트 복제

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

3. uv를 사용하여 프로젝트 환경 초기화

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

4. 환경 변수 구성(선택 사항, 원격 연결의 경우)

.env 파일을 만들고 다음 구성을 추가합니다.

# 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

빠른 시작

  1. 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. Python 코드에서 사용:

from jvm_mcp_server import JvmMcpServer

server = JvmMcpServer()
server.run()
  1. MCP 도구 사용:

구성 파일 사용:

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

구성 파일을 사용하지 않고 시스템 환경 변수를 읽고, 해당 변수가 없으면 로컬 스레드를 모니터링합니다.

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

사용 가능한 도구

사용 가능한 도구 목록

중요 참고 사항

  1. 런타임 환경에 Java가 설치되어 있는지 확인하세요.

  2. Arthas 도구는 첫 번째 실행 시 자동으로 다운로드됩니다(arthas는 홈 디렉토리에 다운로드되며, 미리 다운로드하여 arthas-boot.jar라는 이름으로 지정할 수 있음)

  3. 대상 Java 프로세스에 대한 액세스 권한이 필요합니다.

  4. 원격 모드에는 SSH 액세스 및 적절한 사용자 권한이 필요합니다.

  5. 개발 환경에서의 사용을 권장하며, 실제 운영 환경에서의 사용은 신중하게 평가되어야 합니다.

피드백

문제가 발생하면 이슈나 풀 리퀘스트를 제출해 주세요.

특허

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