Skip to main content
Glama

watch_method

Monitor Java method calls in real-time by tracking execution parameters, return values, and invocation frequency for debugging and performance analysis.

Instructions

监控方法的调用情况

        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: 包含方法监控信息的字典(暂未实现)
        

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidNo
class_patternNo
method_patternNo
watch_paramsNo
watch_returnNo
conditionNo
max_timesNo10

Implementation Reference

  • The watch_method tool is registered via @self.mcp.tool() decorator and implemented as a handler function. The function signature and docstring define the input schema. Currently a stub implementation returning 'not implemented' error.
    @self.mcp.tool()
    def watch_method(pid: str = "", 
                    class_pattern: str = "", 
                    method_pattern: str = "", watch_params: bool = True, 
                    watch_return: bool = True, condition: Optional[str] = None, 
                    max_times: str = "10") -> Dict:
        """监控方法的调用情况
    
        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: 包含方法监控信息的字典(暂未实现)
        """
        return {"success": False, "error": "未实现/不支持"}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions monitoring method calls and what gets monitored (parameters, return values), but lacks critical behavioral details: whether this is a blocking/long-running operation, if it requires specific permissions, potential performance impacts, or how monitoring is stopped. The note '暂未实现' (not yet implemented) for returns adds uncertainty about current functionality.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with a clear purpose statement followed by structured parameter documentation. However, it's not optimally front-loaded—the critical '暂未实现' (not yet implemented) warning about returns is buried at the end rather than highlighted upfront. The formatting with indentation is consistent but could be more streamlined.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex monitoring tool with 7 parameters, no annotations, and no output schema, the description is incomplete. It documents parameters adequately but fails to address behavioral aspects (execution model, side effects, termination), doesn't explain the monitoring output format despite the return note, and provides no error handling or prerequisite information. The '暂未实现' warning creates ambiguity about current capabilities.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage for 7 parameters, the description compensates well by explaining each parameter's purpose in Chinese: process ID, class pattern matching, method pattern matching, monitoring options for parameters and returns, condition expression, and maximum monitoring count. It provides format examples for pid and max_times. This adds substantial meaning beyond the bare schema, though some nuances (like pattern syntax) remain unspecified.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as '监控方法的调用情况' (monitoring method invocation), which is a specific verb+resource combination. It distinguishes itself from siblings like 'search_method' or 'get_stack_trace_by_method' by focusing on real-time monitoring rather than searching or retrieving static information. However, it doesn't explicitly contrast with these alternatives in the description text itself.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_method' or 'get_stack_trace_by_method'. It doesn't mention prerequisites (e.g., needing a running Java process), appropriate contexts, or exclusions. The agent must infer usage from the purpose alone without explicit direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xzq-xu/jvm-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server