get_frappe_usage_info
Retrieve schema metadata and usage guidance for Frappe Framework DocTypes or workflows to understand structure and implementation details.
Instructions
Get combined information about a DocType or workflow, including schema metadata and usage guidance.
Args:
doctype: DocType name (optional if workflow is provided)
workflow: Workflow name (optional if doctype is provided)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doctype | No | ||
| workflow | No |
Implementation Reference
- src/tools/schema.py:205-274 (handler)The core handler function for the 'get_frappe_usage_info' tool. It fetches and formats DocType schema and workflow information from the Frappe API, handling both parameters optionally. Includes input validation, API calls, data extraction for required fields, submittable status, etc., and error handling.@mcp.tool() async def get_frappe_usage_info( doctype: Optional[str] = None, workflow: Optional[str] = None ) -> str: """ Get combined information about a DocType or workflow, including schema metadata and usage guidance. Args: doctype: DocType name (optional if workflow is provided) workflow: Workflow name (optional if doctype is provided) """ try: if not doctype and not workflow: return "Please provide either a doctype or workflow parameter" client = get_client() info_parts = [] if doctype: # Get DocType schema information schema_response = await client.get(f"api/resource/DocType/{doctype}") if "data" in schema_response: schema_data = schema_response["data"] # Extract key information info = { "doctype": doctype, "module": schema_data.get("module"), "description": schema_data.get("description"), "is_submittable": schema_data.get("is_submittable", 0) == 1, "is_tree": schema_data.get("is_tree", 0) == 1, "naming_rule": schema_data.get("autoname"), "required_fields": [] } # Get required fields for field in schema_data.get("fields", []): if field.get("reqd", 0) == 1: info["required_fields"].append({ "fieldname": field.get("fieldname"), "label": field.get("label"), "fieldtype": field.get("fieldtype"), "options": field.get("options") }) info_parts.append(f"DocType Information:\n{json.dumps(info, indent=2)}") if workflow: # Get workflow information try: workflow_response = await client.get(f"api/resource/Workflow/{workflow}") if "data" in workflow_response: workflow_data = workflow_response["data"] workflow_info = { "workflow": workflow, "document_type": workflow_data.get("document_type"), "is_active": workflow_data.get("is_active", 0) == 1, "workflow_states": workflow_data.get("states", []), "transitions": workflow_data.get("transitions", []) } info_parts.append(f"Workflow Information:\n{json.dumps(workflow_info, indent=2)}") except: info_parts.append(f"Could not retrieve workflow information for: {workflow}") return "\n\n".join(info_parts) if info_parts else "No information found" except Exception as error: return _format_error_response(error, "get_frappe_usage_info")
- src/server.py:39-42 (registration)Registration of all tool modules in the main server setup, including schema.register_tools(mcp) which registers the get_frappe_usage_info tool via its @mcp.tool() decorator.helpers.register_tools(mcp) documents.register_tools(mcp) schema.register_tools(mcp) reports.register_tools(mcp)
- src/tools/schema.py:207-216 (schema)Input schema defined via type hints and docstring: optional doctype (str) and workflow (str), returns formatted string with usage info.doctype: Optional[str] = None, workflow: Optional[str] = None ) -> str: """ Get combined information about a DocType or workflow, including schema metadata and usage guidance. Args: doctype: DocType name (optional if workflow is provided) workflow: Workflow name (optional if doctype is provided) """