validate_auth
Verify API credentials and check authentication status for secure access to Frappe Framework sites and document operations.
Instructions
Validate API credentials and return authentication status.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/helpers.py:27-30 (handler)The handler function for the 'validate_auth' MCP tool. It invokes the underlying validate_api_credentials() helper to perform the actual validation.@mcp.tool() def validate_auth() -> Dict[str, Any]: """Validate API credentials and return authentication status.""" return validate_api_credentials()
- src/auth.py:12-61 (helper)Core helper function that checks for FRAPPE_API_KEY and FRAPPE_API_SECRET environment variables and returns a dictionary with validation status, message, and details.def validate_api_credentials() -> Dict[str, Any]: """ Validate that required API credentials are available. Returns: Dict containing validation status and details """ api_key = os.getenv("FRAPPE_API_KEY") api_secret = os.getenv("FRAPPE_API_SECRET") if not api_key and not api_secret: return { "valid": False, "message": "Both API key and API secret are missing", "details": { "api_key_available": False, "api_secret_available": False, "auth_method": "API key/secret (token)" } } elif not api_key: return { "valid": False, "message": "API key is missing", "details": { "api_key_available": False, "api_secret_available": True, "auth_method": "API key/secret (token)" } } elif not api_secret: return { "valid": False, "message": "API secret is missing", "details": { "api_key_available": True, "api_secret_available": False, "auth_method": "API key/secret (token)" } } return { "valid": True, "message": "API credentials are properly configured", "details": { "api_key_available": True, "api_secret_available": True, "auth_method": "API key/secret (token)" } }
- src/server.py:38-42 (registration)Registration block in the MCP server setup where helpers.register_tools(mcp) is called, which registers the validate_auth tool among others.# Register all tool modules helpers.register_tools(mcp) documents.register_tools(mcp) schema.register_tools(mcp) reports.register_tools(mcp)
- src/tools/helpers.py:14-30 (registration)The register_tools function in helpers.py that defines and registers the validate_auth tool using the @mcp.tool() decorator.def register_tools(mcp: Any) -> None: """Register helper tools with the MCP server.""" @mcp.tool() def ping() -> str: """A simple tool to check if the server is responding.""" return "pong" @mcp.tool() def version() -> str: """Get version information for the Frappe MCP server.""" return f"Frappe MCP Server version {__version__}" @mcp.tool() def validate_auth() -> Dict[str, Any]: """Validate API credentials and return authentication status.""" return validate_api_credentials()