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 main execution logic for the get_frappe_usage_info tool, fetching DocType schema, required fields, and workflow details from the Frappe API.@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/tools/schema.py:206-216 (schema)Input schema defined by type hints and docstring: doctype (optional str), workflow (optional str). Returns formatted string with usage info.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) """
- src/server.py:41-41 (registration)Registers the schema module's tools, including get_frappe_usage_info, by calling schema.register_tools(mcp) during server initialization.schema.register_tools(mcp)