Skip to main content
Glama

call_method

Execute whitelisted Frappe Framework methods by specifying the method name and optional parameters to interact with Frappe sites programmatically.

Instructions

    Execute a whitelisted Frappe method.
    
    Args:
        method: Method name to call (whitelisted)
        params: Parameters to pass to the method (optional)
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodYes
paramsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'call_method' tool. It is decorated with @mcp.tool() for automatic registration and implements calling whitelisted Frappe methods via the /api/method endpoint, with proper error handling using a shared helper.
    @mcp.tool()
    async def call_method(
        method: str,
        params: Optional[Dict[str, Any]] = None
    ) -> str:
        """
        Execute a whitelisted Frappe method.
        
        Args:
            method: Method name to call (whitelisted)
            params: Parameters to pass to the method (optional)
        """
        try:
            client = get_client()
            
            # Prepare request data
            request_data = {"cmd": method}
            if params:
                request_data.update(params)
            
            # Make API request to call method
            response = await client.post("api/method", json_data=request_data)
            
            if "message" in response:
                return json.dumps(response["message"], indent=2)
            else:
                return json.dumps(response, indent=2)
                
        except Exception as error:
            return _format_error_response(error, "call_method")
  • src/server.py:40-40 (registration)
    Invocation of documents.register_tools(mcp) in the main server setup, which triggers the registration of the 'call_method' tool (and other document tools) with the MCP server instance.
    documents.register_tools(mcp)
  • Helper function used by call_method (and other tools) to format detailed error responses, including credential checks and Frappe-specific error handling.
    def _format_error_response(error: Exception, operation: str) -> str:
        """Format error response with detailed information."""
        credentials_check = validate_api_credentials()
        
        # Build diagnostic information
        diagnostics = [
            f"Error in {operation}",
            f"Error type: {type(error).__name__}",
            f"Is FrappeApiError: {isinstance(error, FrappeApiError)}",
            f"API Key available: {credentials_check['details']['api_key_available']}",
            f"API Secret available: {credentials_check['details']['api_secret_available']}"
        ]
        
        # Check for missing credentials first
        if not credentials_check["valid"]:
            error_msg = f"Authentication failed: {credentials_check['message']}. "
            error_msg += "API key/secret is the only supported authentication method."
            return error_msg
        
        # Handle FrappeApiError
        if isinstance(error, FrappeApiError):
            error_msg = f"Frappe API error: {error}"
            if error.status_code in (401, 403):
                error_msg += " Please check your API key and secret."
            return error_msg
        
        # Default error handling
        return f"Error in {operation}: {str(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 'whitelisted' which implies security constraints, but doesn't explain what this means in practice, what authentication is required, what happens on failure, or what the output looks like. For a tool that executes arbitrary methods, this lack of behavioral context is a significant gap.

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

Conciseness4/5

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

The description is appropriately concise with a clear purpose statement followed by parameter documentation. The two-sentence structure is efficient, though the Args formatting could be more integrated with the main description. Every sentence serves a purpose with minimal waste.

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

Completeness3/5

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

Given the tool's complexity (executing arbitrary methods), lack of annotations, and presence of an output schema, the description is minimally adequate but incomplete. It covers basic purpose and parameters but misses critical context about security constraints, error handling, and relationship to sibling tools. The output schema existence means return values are documented elsewhere, but the description should still provide more behavioral context.

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

Parameters3/5

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

The description provides basic parameter documentation in the Args section, naming both parameters and indicating that params is optional. However, with 0% schema description coverage and no details about what constitutes valid method names or parameter formats, this adds only marginal value beyond the bare schema. The baseline of 3 is appropriate given the schema does minimal documentation work.

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 action ('Execute') and target ('a whitelisted Frappe method'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from its many siblings (like amend_document, create_document, etc.) that also execute operations, leaving room for confusion about when to use this general-purpose method caller versus more specific document operations.

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. With 22 sibling tools including many document-specific operations (create_document, update_document, etc.), the agent receives no help in choosing between this generic method executor and more specialized tools. There's no mention of prerequisites, constraints, or typical use cases.

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/appliedrelevance/frappe-mcp-server'

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