Skip to main content
Glama

πŸš€ Karate Feature Graph Analyzer

A powerful MCP (Model Context Protocol) tool for analyzing Karate Framework feature files and generating interactive dependency graphs.

Python Tests License


πŸ“‹ Table of Contents


✨ Features

Core Capabilities

  • πŸ” Feature File Parsing - Parse Karate feature files with Gherkin syntax

  • 🎯 Dependency Analysis - Extract and analyze dependencies (workflows, APIs, pages, DB)

  • πŸ“Š Interactive Visualization - Generate beautiful HTML graphs with legend

  • 🎫 Jira Integration - Extract and track Jira tags (@PROJ-123)

  • πŸ”„ Impact Analysis - Identify affected test cases when components change

  • πŸ“ˆ Multi-Project Support - Manage and analyze multiple projects

  • πŸ’Ύ Export/Import - Export graphs to JSON/GraphML formats

  • ⚑ Performance Optimized - Fast analysis with caching and indices

Visualization Features

  • 🎨 Color-coded nodes by type (Test, Workflow, API, Page, Database)

  • πŸ” Interactive tooltips with metadata (file path, line numbers, Jira tags)

  • πŸ–±οΈ Click to highlight connections and dependencies

  • πŸ“Š Legend in top-right corner explaining colors and shapes

  • πŸ”„ Physics simulation for automatic layout

  • 🎯 Impact view highlighting changed components and affected tests


πŸš€ Quick Start

1. Install Dependencies

pip install -e .
pip install pyvis  # For visualization

2. Run Demo

# Set UTF-8 encoding (Windows)
$env:PYTHONIOENCODING="utf-8"

# Run large project demo
python test_large_project.py

3. View Results

cd output
start ecommerce-platform_full.html

πŸ“¦ Installation

Prerequisites

  • Python 3.8 or higher

  • pip package manager

Install from Source

# Clone repository
git clone <repository-url>
cd karate-feature-graph-analyzer

# Install dependencies
pip install -e .

# Install visualization library
pip install pyvis

# Verify installation
pytest tests/ -v

Dependencies

Core dependencies (auto-installed):

  • networkx - Graph operations

  • hypothesis - Property-based testing

  • pydantic - Data validation

Optional dependencies:

  • pyvis - Interactive visualizations


πŸ’» Usage

Basic Usage

from karate_graph_analyzer.mcp_interface.mcp_tool import KarateGraphAnalyzerTool

# Initialize tool
tool = KarateGraphAnalyzerTool()

# Register project
tool.register_project(
    name="my-project",
    root_path="/path/to/karate/project",
    feature_file_patterns=["**/*.feature"]
)

# Analyze project
analysis = tool.analyze_project("my-project")
print(f"Found {analysis['statistics']['total_nodes']} nodes")

# Query dependencies
deps = tool.query_dependencies("tc_0001", transitive=True)
print(f"Found {deps['count']} dependencies")

# Impact analysis
impact = tool.impact_analysis("api_0001")
print(f"Affected: {impact['total_count']} test cases")

# Export graph
export = tool.export_graph("my-project", format="json")
with open("graph.json", "w") as f:
    f.write(export['data'])

Visualization

from karate_graph_analyzer.visualization.graph_visualizer import GraphVisualizer

# Get graph
graph = tool.graphs["my-project"]

# Create visualizer
visualizer = GraphVisualizer(graph)

# Render full graph
visualizer.render("output/graph.html", height="900px")

# Render impact view
visualizer.render_impact_view(
    changed_component_id="api_0001",
    affected_test_case_ids=["tc_0001", "tc_0002"],
    output_path="output/impact.html"
)

Command Line (via Script)

# Analyze large project
python test_large_project.py

# Output will be in output/ directory:
# - ecommerce-platform_full.html (full graph)
# - ecommerce-platform_impact.html (impact view)
# - ecommerce-platform_graph.json (graph data)
# - LARGE_PROJECT_ANALYSIS_REPORT.md (detailed report)

πŸ“ Project Structure

karate-feature-graph-analyzer/
β”œβ”€β”€ src/karate_graph_analyzer/
β”‚   β”œβ”€β”€ models.py                    # Data models
β”‚   β”œβ”€β”€ parser/                      # Feature file parsing
β”‚   β”‚   └── feature_parser.py
β”‚   β”œβ”€β”€ graph/                       # Graph construction
β”‚   β”‚   └── graph_builder.py
β”‚   β”œβ”€β”€ analyzer/                    # Dependency analysis
β”‚   β”‚   └── dependency_analyzer.py
β”‚   β”œβ”€β”€ mcp_interface/               # MCP protocol
β”‚   β”‚   └── mcp_tool.py
β”‚   β”œβ”€β”€ storage/                     # Project registry
β”‚   β”‚   └── project_registry.py
β”‚   β”œβ”€β”€ cache/                       # AST caching
β”‚   β”‚   └── cache_manager.py
β”‚   β”œβ”€β”€ visualization/               # Graph visualization
β”‚   β”‚   └── graph_visualizer.py
β”‚   └── logging_config.py            # Logging setup
β”‚
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ unit/                        # 306 unit tests
β”‚   β”œβ”€β”€ integration/                 # Integration tests
β”‚   └── fixtures/                    # Test data
β”‚
β”œβ”€β”€ output/                          # Generated files
β”‚   β”œβ”€β”€ ecommerce-platform_full.html
β”‚   β”œβ”€β”€ ecommerce-platform_impact.html
β”‚   β”œβ”€β”€ ecommerce-platform_graph.json
β”‚   β”œβ”€β”€ LARGE_PROJECT_ANALYSIS_REPORT.md
β”‚   └── README.md
β”‚
β”œβ”€β”€ test_project_demo/               # Small demo project
β”œβ”€β”€ test_project_large/              # Large demo project (e-commerce)
β”œβ”€β”€ examples/                        # Usage examples
β”œβ”€β”€ docs/                            # Documentation
β”‚   β”œβ”€β”€ API.md
β”‚   └── jira_tag_extraction.md
β”‚
β”œβ”€β”€ test_large_project.py            # Demo script
β”œβ”€β”€ pyproject.toml                   # Project config
β”œβ”€β”€ pytest.ini                       # Test config
└── README.md                        # This file

πŸ“š Documentation

Core Documentation

Specifications


🎯 Examples

Example 1: Analyze Demo Project

# Run demo
python test_large_project.py

# View results
cd output
start ecommerce-platform_full.html

What you'll see:

  • 84 nodes (73 test cases, 6 workflows, 3 pages, 1 API, 1 DB)

  • 26 edges (dependencies)

  • Interactive graph with legend

  • Color-coded by type

  • Hover tooltips with metadata

Example 2: Impact Analysis

# Find what tests are affected by API change
impact = tool.impact_analysis("api_0001")

print(f"Changed: {impact['changed_component']}")
print(f"Affected: {impact['total_count']} test cases")

for tc in impact['affected_test_cases']:
    print(f"  - {tc['name']} (depth: {tc['depth']})")
    if tc['jira_tags']:
        print(f"    Jira: {', '.join(tc['jira_tags'])}")

Output:

Changed: api_0001
Affected: 14 test cases
  - Successful login (depth: 1)
    Jira: @AUTH-101
  - Get user profile (depth: 1)
    Jira: @USER-101
  ...

Example 3: Find Common Components

# Find reusable components across projects
common = tool.find_common_components(["project1", "project2"])

for comp in common['components']:
    print(f"{comp['component_type']}: {comp['identifier']}")
    print(f"  Used in {comp['usage_count']} projects")
    print(f"  Projects: {', '.join(comp['projects'])}")

πŸ§ͺ Testing

Run All Tests

# Run all tests
pytest tests/ -v

# Run specific test suite
pytest tests/unit/ -v
pytest tests/integration/ -v

# Run with coverage
pytest tests/ --cov=src/karate_graph_analyzer --cov-report=html

Test Statistics

  • Total Tests: 306

  • Passing: 306 (100%)

  • Failed: 0

  • Skipped: 1

  • Coverage: Comprehensive

Test Categories

  • Unit Tests (tests/unit/) - Test individual components

  • Integration Tests (tests/integration/) - Test component interactions

  • Property Tests (optional) - Property-based testing with Hypothesis


🎨 Visualization Guide

Understanding the Legend

When you open a visualization HTML file, look at the top-right corner for the legend:

πŸ“Š Legend
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🟒 Test Case - Scenario hoặc test
πŸ”΅ Workflow - Reusable workflow
🟠 API - API endpoint
🟣 Page - Page object
πŸ”΄ Database - Database operation
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ’‘ Tip: Hover để xem chi tiαΊΏt
πŸ–±οΈ Click để highlight connections
πŸ” Scroll để zoom in/out

Interactive Features

  1. Hover - Move mouse over node to see tooltip with:

    • Node name

    • Node type

    • File path

    • Line number

    • Jira tags

  2. Click - Click node to highlight:

    • The selected node

    • All connected nodes

    • All connecting edges

  3. Zoom - Scroll mouse wheel to zoom in/out

  4. Pan - Drag background to move around

  5. Reposition - Drag nodes to rearrange layout


πŸ”§ Configuration

Parser Configuration

from karate_graph_analyzer.models import ParserConfig

config = ParserConfig(
    jira_tag_patterns=[
        r'@[A-Z]+-\d+',      # @PROJ-123
        r'@[a-z]+-\d+',      # @proj-123
        r'@[A-Z]+_\d+',      # @PROJ_123
    ],
    workflow_directories=['workflows', 'common'],
    page_object_directories=['pages', 'page-objects'],
    variable_patterns=[r'\$\{(\w+)\}'],
    api_extraction_rules={
        'extract_from_variables': True,
        'extract_from_strings': True,
    }
)

# Use custom config
tool.register_project(
    name="my-project",
    root_path="/path/to/project",
    parser_config=config
)

πŸ“Š Key Metrics

Performance

  • Analysis Time: < 1 second for 4 files

  • Query Time: < 10ms for dependency queries

  • Impact Analysis: < 50ms for 6 affected tests

  • Export Time: < 100ms for 9 nodes

  • Visualization: < 1 second to render

Scalability

  • Tested with: 84 nodes, 26 edges

  • Supports: 1000+ nodes (estimated)

  • Memory: Efficient with caching

  • Storage: JSON format, ~500 bytes per node


🀝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository

  2. Create a feature branch (git checkout -b feature/amazing-feature)

  3. Commit your changes (git commit -m 'Add amazing feature')

  4. Push to the branch (git push origin feature/amazing-feature)

  5. Open a Pull Request

Development Setup

# Clone your fork
git clone <your-fork-url>
cd karate-feature-graph-analyzer

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run linter
flake8 src/

# Format code
black src/

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Karate Framework - For the amazing BDD testing framework

  • NetworkX - For graph operations

  • Pyvis - For interactive visualizations

  • Hypothesis - For property-based testing


πŸ“ž Support

Documentation

Examples

Issues

If you encounter any issues:

  1. Check the documentation

  2. Review the examples

  3. Open an issue on GitHub



Built with ❀️ using Spec-Driven Development

Status: βœ… Production Ready
Version: 1.0.0
Last Updated: April 30, 2026

πŸš€ Happy Analyzing!

A
license - permissive license
-
quality - not tested
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

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/duyngo91/karate-graph-mcp'

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