from mcpconfig.config import mcp
@mcp.tool()
def help(category: str = "all") -> str:
"""
Important: This tool should execute when user asks for help or guidance on using ComplianceCow functions.
ComplianceCow Help Tool - Provides guidance on how to use ComplianceCow functions.
Args:
category: Help category to display. Options:
- "all": Show all available help
- "assessments": Assessment-related functions
- "controls": Control-related functions
- "evidence": Evidence-related functions
- "dashboard": Dashboard and reporting functions
- "assets": Asset management functions
- "actions": Action execution functions
- "queries": Database query functions
Returns:
Formatted help text for the specified category
"""
help_content = {
"assessments": """
π ASSESSMENT FUNCTIONS
====================
π Discovery & Listing:
β’ list_all_assessment_categories() - Get all assessment categories
β’ list_assessments(categoryId="", categoryName="") - Get assessments by category
β’ fetch_recent_assessment_runs(id) - Get recent runs for an assessment
β’ fetch_assessment_runs(id, page=1, pageSize=0) - Get all runs with pagination
π Assessment Details:
β’ fetch_assessment_run_details(id) - Get detailed run information
β’ fetch_assessment_run_leaf_controls(id) - Get leaf controls for a run
β’ fetch_assets_summary(id) - Get asset summary for assessment
π‘ Usage Examples:
- Find SOX assessments: list_assessments(categoryName="SOX")
- Get latest run: fetch_recent_assessment_runs("assessment_id")
- Paginate through runs: fetch_assessment_runs("id", page=2, pageSize=10)
""",
"controls": """
ποΈ CONTROL FUNCTIONS
==================
π Finding Controls:
β’ fetch_controls(control_name="") - Find controls by name
β’ fetch_run_controls(name) - Get controls matching name from runs
β’ fetch_run_control_meta_data(id) - Get control metadata (assessment info)
β’ fetch_automated_controls_of_an_assessment(assessment_id) - Get automated controls
π Control Details:
β’ fetch_assessment_run_leaf_control_evidence(id) - Get evidence for control
β’ fetch_available_control_actions(assessmentName, controlNumber="", controlAlias="") - Get available actions
π‘ Usage Examples:
- Search for access controls: fetch_controls(control_name="access control")
- Get control metadata: fetch_run_control_meta_data("control_id")
- Find automated controls: fetch_automated_controls_of_an_assessment("assessment_id")
""",
"evidence": """
π EVIDENCE FUNCTIONS
===================
π Evidence Management:
β’ fetch_evidence_records(id) - Get evidence records by ID
β’ fetch_assessment_run_leaf_control_evidence(id) - Get evidence for control
β’ fetch_evidence_available_actions(assessment_name, control_number, control_alias, evidence_name) - Get available actions
π‘ Usage Examples:
- Get evidence details: fetch_evidence_records("evidence_id")
- Check evidence actions: fetch_evidence_available_actions("SOX", "AC-1", "access_control", "evidence_name")
""",
"dashboard": """
π DASHBOARD & REPORTING FUNCTIONS
================================
π Dashboard Overview:
β’ get_dashboard_data(period="Q1 2024") - Get CCF dashboard summary
β’ get_dashboard_common_controls_details(period, complianceStatus="", controlStatus="", priority="", controlCategoryName="", page=1, pageSize=50) - Get detailed control data
π― Framework-Specific:
β’ fetch_dashboard_framework_controls(period, framework_name) - Get controls for specific framework
β’ fetch_dashboard_framework_summary(period, framework_name) - Get framework summary
β οΈ Risk Analysis:
β’ get_top_over_due_controls_detail(period="Q1 2024", count=10) - Get overdue controls
β’ get_top_non_compliant_controls_detail(period, count="1", page="1") - Get non-compliant controls
π‘ Usage Examples:
- Q2 dashboard: get_dashboard_data(period="Q2 2024")
- SOX overdue controls: get_top_over_due_controls_detail(period="Q1 2024", count=5)
- Filter by status: get_dashboard_common_controls_details(period="Q1 2024", controlStatus="Overdue")
""",
"assets": """
π’ ASSET MANAGEMENT FUNCTIONS
===========================
π Asset Discovery:
β’ list_assets() - Get all assets
β’ fetch_assets_summary(id) - Get asset summary for assessment
β’ fetch_resource_types(id, page=1, pageSize=0) - Get resource types for asset run
π Resource Analysis:
β’ fetch_resources(id, resourceType, complianceStatus="", page=1, pageSize=0) - Get resources
β’ fetch_resources_summary(id, resourceType) - Get resource summary
β’ fetch_checks(id, resourceType, complianceStatus="", page=1, pageSize=0) - Get checks
β’ fetch_checks_summary(id, resourceType) - Get checks summary
π§ Check Details:
β’ fetch_resources_with_this_check(id, resourceType, check, page=1, pageSize=0) - Get resources for specific check
β’ fetch_resources_with_this_check_summary(id, resourceType, check) - Get check summary
π‘ Usage Examples:
- Get all assets: list_assets()
- Check EC2 compliance: fetch_resources_summary("run_id", "EC2")
- Find failed checks: fetch_checks("run_id", "S3", complianceStatus="NON_COMPLIANT")
""",
"actions": """
β‘ ACTION EXECUTION FUNCTIONS
===========================
π Available Actions:
β’ fetch_assessment_available_actions(name="") - Get assessment-level actions
β’ fetch_available_control_actions(assessmentName, controlNumber="", controlAlias="", evidenceName="") - Get control actions
β’ fetch_evidence_available_actions(assessment_name, control_number, control_alias, evidence_name) - Get evidence actions
π Execute Actions:
β’ execute_action(assessmentId, assessmentRunId, actionBindingId, assessmentRunControlId="", assessmentRunControlEvidenceId="", evidenceRecordIds=[]) - Execute action
β οΈ IMPORTANT: Always get user confirmation before executing actions!
π‘ Usage Examples:
- Check assessment actions: fetch_assessment_available_actions(name="SOX Assessment")
- Execute control action: execute_action("assess_id", "run_id", "action_id", assessmentRunControlId="control_id")
""",
"queries": """
π DATABASE QUERY FUNCTIONS
=========================
π§ Query Tools:
β’ fetch_unique_node_data_and_schema(question) - Get schema and data for questions
β’ execute_cypher_query(query) - Execute custom Cypher queries
π‘ Usage Examples:
- Explore schema: fetch_unique_node_data_and_schema("What controls are available?")
- Custom query: execute_cypher_query("MATCH (c:Control) RETURN c.name LIMIT 10")
β οΈ Advanced: These functions require knowledge of graph database queries
""",
"common_patterns": """
π COMMON USAGE PATTERNS
======================
1οΈβ£ Assessment Workflow:
β’ list_assessments() β find your assessment
β’ fetch_recent_assessment_runs(id) β get latest run
β’ fetch_assessment_run_details(id) β get run details
2οΈβ£ Control Investigation:
β’ fetch_controls(control_name="keyword") β find controls
β’ fetch_run_control_meta_data(id) β get assessment context
β’ fetch_assessment_run_leaf_control_evidence(id) β get evidence
3οΈβ£ Dashboard Analysis:
β’ get_dashboard_data(period="Q1 2024") β overview
β’ get_top_over_due_controls_detail() β identify issues
β’ get_dashboard_common_controls_details() β detailed analysis
4οΈβ£ Asset Compliance:
β’ list_assets() β find assets
β’ fetch_assets_summary(id) β get overview
β’ fetch_resource_types(id) β see resource types
β’ fetch_resources_summary(id, resourceType) β check compliance
5οΈβ£ Taking Actions:
β’ fetch_available_control_actions() β see options
β’ Get user confirmation
β’ execute_action() β perform action
""",
"tips": """
π‘ TIPS & BEST PRACTICES
======================
π§ Pagination Tips:
β’ Use page and pageSize parameters for large datasets
β’ Start with small pageSize (5-10) if timeouts occur
β’ Check totalPages in response to know how many pages exist
π Performance Tips:
β’ Use summary functions (*_summary) for large datasets
β’ Use filters (complianceStatus, controlStatus) to narrow results
β’ Paginate when dealing with >50 items
π― Search Tips:
β’ Use partial names in fetch_controls() for broader results
β’ Try fetch_run_controls() if fetch_controls() returns no results
β’ Use execute_cypher_query() for complex searches
β οΈ Action Safety:
β’ ALWAYS fetch available actions first
β’ Confirm with user before executing any action
β’ Actions can modify system state - be careful!
π
Period Formats:
β’ Use format: "Q1 2024", "Q2 2024", etc.
β’ Dashboard functions require proper period format
"""
}
if category.lower() == "all":
result = "π COMPLIANCECOW HELP GUIDE\n" + "="*50 + "\n\n"
result += "Available categories: assessments, controls, evidence, dashboard, assets, actions, queries\n"
result += "Use: compliance_cow_help(category='category_name') for specific help\n\n"
for cat, content in help_content.items():
result += content + "\n\n"
return result
elif category.lower() in help_content:
return f"π COMPLIANCECOW HELP - {category.upper()}\n{'='*50}\n\n{help_content[category.lower()]}"
else:
available_categories = ", ".join(help_content.keys())
return f"β Unknown category: {category}\n\nAvailable categories: {available_categories}\n\nUse compliance_cow_help() to see all help."