Skip to content

Method Invocation MCP

The DebugTools IDEA plugin provides five MCP tools in DebugToolsMethodInvocationToolset. They inspect connections, list attachable JVMs, attach to a JVM, generate method argument templates, and invoke Java methods.

This page is a tool reference and covers only each tool's purpose, input parameters, and return values. The Method Invocation Skill defines when an AI should use each tool, how to combine them, and how to recover from failures.

Tool Overview

ToolPurpose
list_debug_tools_connectionsLists established DebugTools connections for the current IDEA project.
list_attachable_jvmsLists local JVMs that the current IDEA project can attach to.
attach_local_jvmLoads the DebugTools agent into a specified local JVM and can wait for a connection.
generate_method_args_templateGenerates a DebugTools argsJson template from a Java method signature in the IDEA project.
invoke_java_methodInvokes a Java method in the target JVM through a specified DebugTools connection.

Common Conventions

All five tools support an optional projectPath parameter:

ParameterRequiredTypeDescription
projectPathNostringAn IDEA project directory or a file path inside the project. Use it to identify the target when the MCP context is ambiguous or IDEA has multiple projects open.

When projectPath is omitted, the plugin resolves the target from the IDEA MCP call context and open projects. If it cannot identify a project, the tool returns an MCP error.

Normal results are returned as JSON text. Missing parameters, nonexistent projects, or unexpected execution failures may return an MCP error directly. Some tools represent expected business failures with success=false and an error field in an otherwise valid JSON result.

1. List DebugTools Connections

Tool name: list_debug_tools_connections

Purpose

Reads a snapshot of DebugTools connections for the current IDEA project. It only queries connections and does not attach to a JVM, switch connections, or invoke a method.

Parameters

There are no tool-specific required parameters. Only the common optional projectPath parameter is supported.

Return Value

FieldTypeDescription
countintegerNumber of connections in the current project.
connectionsarrayDebugTools connections.
connections[].connectionIdstringUnique connection ID. Pass it to invoke_java_method.connectionId.
connections[].applicationNamestringTarget application name.
connections[].pidstring | nullTarget JVM process ID; may be null for remote connections.
connections[].sourcestringConnection source, currently LOCAL or REMOTE.
connections[].hoststringHost running the DebugTools agent.
connections[].portintegerDebugTools socket port.
connections[].httpPortinteger | nullDebugTools HTTP port; null when HTTP capabilities are unavailable.
connections[].remarkstring | nullConnection remark.
connections[].statestringCurrent state, such as CONNECTING, CONNECTED, RECONNECTING, or DISCONNECTED.
connections[].activebooleanWhether the connection is active and available.
connections[].defaultClassLoaderobject | nullDefault ClassLoader selected for the connection.
connections[].defaultClassLoader.namestringDefault ClassLoader name.
connections[].defaultClassLoader.identitystringDefault ClassLoader identity.
connections[].headersobjectHeaders stored by the current connection.
connections[].printSqlTypestring | nullSQL printing mode for the current connection.

Response example:

json
{
  "count": 1,
  "connections": [
    {
      "connectionId": "demo-connection",
      "applicationName": "DemoApplication",
      "pid": "42135",
      "source": "LOCAL",
      "host": "127.0.0.1",
      "port": 12345,
      "httpPort": 22222,
      "remark": null,
      "state": "CONNECTED",
      "active": true,
      "defaultClassLoader": {
        "name": "org.springframework.boot.loader.launch.LaunchedClassLoader",
        "identity": "12345678"
      },
      "headers": {},
      "printSqlType": null
    }
  ]
}

2. List Attachable JVMs

Tool name: list_attachable_jvms

Purpose

Reuses the JVM discovery logic from the DebugTools IDEA attach dialog to list local Java processes that the current project can attach to. It only returns candidate JVMs and does not attach to them.

Parameters

There are no tool-specific required parameters. Only the common optional projectPath parameter is supported.

Return Value

FieldTypeDescription
countintegerNumber of attachable JVMs.
jvmsarrayAttachable JVMs.
jvms[].pidstringJVM process ID.
jvms[].displayNamestringName used to display and identify the process.
jvms[].attachNamestringApplication name used by DebugTools when attaching.
jvms[].configurationNamestring | nullAssociated IDEA run configuration name.
jvms[].moduleNamestring | nullAssociated IDEA module name.
jvms[].projectNamestring | nullAssociated IDEA project name.

Response example:

json
{
  "count": 1,
  "jvms": [
    {
      "pid": "42135",
      "displayName": "com.example.DemoApplication",
      "attachName": "DemoApplication",
      "configurationName": "DemoApplication",
      "moduleName": "demo-service",
      "projectName": "demo"
    }
  ]
}

3. Attach to a Local JVM

Tool name: attach_local_jvm

Purpose

Loads the DebugTools agent into a specified local JVM using the same local attach flow as the IDEA plugin. The tool can either submit the attach request only or wait for a DebugTools connection for a specified duration.

Parameters

ParameterRequiredTypeDescription
pidYesstringTarget JVM process ID.
projectPathNostringTarget IDEA project path; see Common Conventions.
attachNameNostringApplication name used for attachment. When omitted, the plugin resolves it by pid from the current attachable JVM list.
waitForConnectionMillisNointegerMaximum time to wait for a connection after attachment, in milliseconds. Values greater than 0 poll every 100 milliseconds.

Return Value

FieldTypeDescription
successbooleanWhether the attach flow was triggered successfully.
pidstringJVM process ID used for attachment.
attachNamestring | nullApplication name used for attachment.
messagestringResult message, such as Attach requested or Attach requested and connection established.
connectionIdstring | nullDebugTools connection ID established during the wait. Null when no wait was requested or no connection appeared in time.
hoststring | nullHost of the new connection.
portinteger | nullDebugTools socket port of the new connection.
httpPortinteger | nullDebugTools HTTP port of the new connection.

WARNING

success=true guarantees only that the attach flow was triggered successfully. A returned connectionId is required to confirm that a DebugTools connection was detected within waitForConnectionMillis.

Request example:

json
{
  "pid": "42135",
  "waitForConnectionMillis": 10000
}

Response example:

json
{
  "success": true,
  "pid": "42135",
  "attachName": "DemoApplication",
  "message": "Attach requested and connection established",
  "connectionId": "demo-connection",
  "host": "127.0.0.1",
  "port": 12345,
  "httpPort": 22222
}

4. Generate a Method Argument Template

Tool name: generate_method_args_template

Purpose

Reads Java PSI from the IDEA project and generates an argsJson template from the target method signature using the same logic as the DebugTools method invocation page. It only reads project source and generates JSON. It does not connect to a JVM or invoke the target method.

Parameters

ParameterRequiredTypeDescription
classNameYesstringFully qualified name of the Java class that declares the target method.
methodNameYesstringTarget method name.
projectPathNostringTarget IDEA project path; see Common Conventions.
parameterTypesNostring[]Parameter types in declaration order. Use them to select an exact signature when overloads exist; fully qualified names are recommended.
genParamTypeNostringArgument template expansion mode: SIMPLE, CURRENT, or ALL. When omitted, uses the DebugTools global default.

genParamType values:

ValueDescription
SIMPLEGenerates only the outer object for an object argument without expanding fields.
CURRENTExpands fields declared directly by the current class.
ALLExpands fields declared by the current class and inherited fields.

Return Value

FieldTypeDescription
successbooleanWhether the method was found and the template was generated.
classNamestring | nullRequested target class name.
methodNamestring | nullRequested target method name.
parameterNamesstring[]Parameter names read from the Java declaration, in declaration order.
parameterTypesstring[]Parameter types of the selected method, in declaration order.
argsJsonstringGenerated DebugTools argument JSON string. {} on failure.
genParamTypestring | nullTemplate expansion mode that was used.
errorMessagestring | nullFailure reason; null on success.

Request example:

json
{
  "className": "com.example.UserService",
  "methodName": "findUser",
  "parameterTypes": ["java.lang.Long"],
  "genParamType": "CURRENT"
}

Response example:

json
{
  "success": true,
  "className": "com.example.UserService",
  "methodName": "findUser",
  "parameterNames": ["id"],
  "parameterTypes": ["java.lang.Long"],
  "argsJson": "{\"id\":{\"type\":\"simple\",\"content\":\"\"}}",
  "genParamType": "CURRENT",
  "errorMessage": null
}

If a class has multiple methods with the same name and parameterTypes is omitted, the tool returns success=false and asks for an overload signature in errorMessage.

5. Invoke a Java Method

Tool name: invoke_java_method

Purpose

Converts MCP parameters into the existing DebugTools RunDTO request, sends it to the target JVM through an established DebugTools socket connection, and waits for the method result.

Parameters

ParameterRequiredTypeDescription
classNameYesstringFully qualified target class name.
methodNameYesstringTarget method name.
projectPathNostringTarget IDEA project path; see Common Conventions.
connectionIdNostringTarget DebugTools connection ID. When omitted, the current project must have exactly one active connection.
parameterTypesNostring[]Target method parameter types in declaration order, used to identify an overload.
argsJsonNostringDebugTools method argument JSON string. Omit it or pass {} for a no-argument method.
headersNoobjectHeaders for this invocation. Keys and values are treated as strings. These take priority over connection and global headers.
xxlJobParamNostringXXL-JOB parameter injected into the target invocation context.
traceMethodDTONoobjectTrace settings for method calls, MyBatis, and SQL.
methodAroundContentNostringMethod Around Java source executed before and after the target method.
methodAroundContentIdentityNostringMethod Around content identity. If content is provided without an identity, the plugin uses the content MD5.
classLoaderIdentityNostringTarget ClassLoader identity. When omitted, uses the connection's currently selected default ClassLoader.
timeoutMillisNointegerTime to wait for the target JVM response, in milliseconds. Defaults to 30000; values below 1 are treated as 1.

If connectionId is omitted and the project has no active connection, the tool returns No active DebugTools connection found. If multiple active connections exist, it returns an error listing the available connectionId values.

Fields supported by traceMethodDTO:

FieldTypeDescription
traceMethodbooleanWhether to enable method call tracing.
traceMaxDepthintegerMaximum trace depth.
traceMyBatisbooleanWhether to trace MyBatis calls.
traceSQLbooleanWhether to trace SQL.
traceSkipStartGetSetCheckBoxbooleanWhether to skip getter- and setter-style methods.
traceBusinessPackageRegexpstringBusiness package prefix or regular expression to trace.
traceIgnorePackageRegexpstringPackage prefix or regular expression to ignore.

argsJson Format

argsJson is a JSON string. In the parsed root object, each field represents one Java method argument and its value uses the DebugTools RunContentDTO structure.

json
{
  "id": {
    "type": "simple",
    "content": "10001"
  },
  "query": {
    "type": "json_entity",
    "content": "{\"keyword\":\"debug-tools\"}"
  }
}

Argument fields should remain in Java method declaration order. Use real parameter names when available. Otherwise, use ordered fallback names such as arg0 and arg1. Common supported type values include simple, json_entity, enum, bean, lambda, request, response, file, and class.

Return Value

FieldTypeDescription
successbooleanWhether the method completed successfully. False when the target method throws or the plugin-side invocation fails.
applicationNamestring | nullTarget application name returned with the result.
classNamestring | nullTarget class that was actually invoked.
methodNamestring | nullTarget method that was actually invoked.
parameterTypesstring[]Parameter types of the invoked method.
resultClassTypestring | nullResult category. Common values are VOID, NULL, SIMPLE, and OBJECT.
resultstring | nullToString representation of the target method's return value.
throwablestring | nullTarget method exception or plugin-side failure reason.
offsetPathstring | nullOffset path of the regular result in DebugTools result storage.
traceOffsetPathstring | nullOffset path of the Trace result in DebugTools result storage.
durationMillisinteger | nullTarget method execution time in milliseconds.

Request example:

json
{
  "connectionId": "demo-connection",
  "className": "com.example.UserService",
  "methodName": "findUser",
  "parameterTypes": ["java.lang.Long"],
  "argsJson": "{\"id\":{\"type\":\"simple\",\"content\":\"10001\"}}",
  "timeoutMillis": 30000
}

Successful response example:

json
{
  "success": true,
  "applicationName": "DemoApplication",
  "className": "com.example.UserService",
  "methodName": "findUser",
  "parameterTypes": ["java.lang.Long"],
  "resultClassType": "OBJECT",
  "result": "User(id=10001, name=DebugTools)",
  "throwable": null,
  "offsetPath": "123456789012345",
  "traceOffsetPath": null,
  "durationMillis": 18
}

Failure response example:

json
{
  "success": false,
  "applicationName": "DemoApplication",
  "className": "com.example.UserService",
  "methodName": "findUser",
  "parameterTypes": ["java.lang.Long"],
  "resultClassType": "OBJECT",
  "result": null,
  "throwable": "java.lang.IllegalArgumentException: user not found",
  "offsetPath": "987654321098765",
  "traceOffsetPath": null,
  "durationMillis": 3
}