| |
| """Validate that the MVP system is working correctly""" |
|
|
| import requests |
| import time |
| import json |
| import sys |
|
|
| MCP_URL = "http://localhost:8000/mcp" |
| API_KEY = "dev-key-123" |
|
|
| def call_mcp(tool, params=None): |
| response = requests.post( |
| MCP_URL, |
| headers={"X-API-Key": API_KEY, "Content-Type": "application/json"}, |
| json={"tool": tool, "params": params or {}} |
| ) |
| return response.json() |
|
|
| def validate_step(step_name, validation_func): |
| """Run a validation step and report results""" |
| print(f"Validating: {step_name}...", end=" ") |
| try: |
| result = validation_func() |
| if result: |
| print("✅ PASSED") |
| return True |
| else: |
| print("❌ FAILED") |
| return False |
| except Exception as e: |
| print(f"❌ ERROR: {e}") |
| return False |
|
|
| def check_neo4j(): |
| """Check Neo4j is accessible via MCP""" |
| result = call_mcp("get_schema") |
| return "labels" in result |
|
|
| def check_postgres(): |
| """Check PostgreSQL has sample data""" |
| result = call_mcp("query_postgres", {"query": "SELECT COUNT(*) as count FROM customers"}) |
| return result.get("data", [{}])[0].get("count", 0) > 0 |
|
|
| def check_schema_discovery(): |
| """Check schema can be discovered""" |
| result = call_mcp("discover_postgres_schema") |
| schema = result.get("schema", {}) |
| return "customers" in schema and "orders" in schema |
|
|
| def create_test_workflow(): |
| """Create a test workflow""" |
| |
| workflow = call_mcp("write_graph", { |
| "action": "create_node", |
| "label": "Workflow", |
| "properties": { |
| "id": "validation-workflow", |
| "name": "Validation Test", |
| "status": "active" |
| } |
| }) |
| |
| |
| instruction = call_mcp("write_graph", { |
| "action": "create_node", |
| "label": "Instruction", |
| "properties": { |
| "id": "validation-inst-1", |
| "type": "generate_sql", |
| "sequence": 1, |
| "status": "pending", |
| "pause_duration": 5, |
| "parameters": json.dumps({"question": "Count all customers"}) |
| } |
| }) |
| |
| |
| call_mcp("query_graph", { |
| "query": """ |
| MATCH (w:Workflow {id: 'validation-workflow'}), |
| (i:Instruction {id: 'validation-inst-1'}) |
| CREATE (w)-[:HAS_INSTRUCTION]->(i) |
| """ |
| }) |
| |
| return workflow.get("created") is not None |
|
|
| def check_instruction_execution(): |
| """Check if instruction gets executed""" |
| |
| for _ in range(12): |
| result = call_mcp("query_graph", { |
| "query": """ |
| MATCH (i:Instruction {id: 'validation-inst-1'}) |
| RETURN i.status as status |
| """ |
| }) |
| |
| status = result["data"][0]["status"] if result.get("data") else "unknown" |
| |
| if status in ["executing", "complete"]: |
| return True |
| |
| time.sleep(5) |
| |
| return False |
|
|
| def check_execution_logged(): |
| """Check if execution was logged""" |
| result = call_mcp("query_graph", { |
| "query": """ |
| MATCH (i:Instruction {id: 'validation-inst-1'})-[:EXECUTED_AS]->(e:Execution) |
| RETURN e |
| """ |
| }) |
| |
| return len(result.get("data", [])) > 0 |
|
|
| def check_frontend(): |
| """Check if frontend is accessible""" |
| try: |
| response = requests.get("http://localhost:3000") |
| return response.status_code == 200 |
| except: |
| return False |
|
|
| def main(): |
| print("=" * 50) |
| print("MVP SYSTEM VALIDATION") |
| print("=" * 50) |
| print() |
| |
| |
| all_passed = True |
| |
| |
| all_passed &= validate_step("Neo4j accessible via MCP", check_neo4j) |
| all_passed &= validate_step("PostgreSQL has sample data", check_postgres) |
| all_passed &= validate_step("Frontend is accessible", check_frontend) |
| |
| |
| all_passed &= validate_step("Schema discovery works", check_schema_discovery) |
| all_passed &= validate_step("Workflow creation works", create_test_workflow) |
| |
| print() |
| print("Waiting for agent to process instruction...") |
| all_passed &= validate_step("Instruction gets executed", check_instruction_execution) |
| all_passed &= validate_step("Execution is logged", check_execution_logged) |
| |
| |
| print() |
| print("=" * 50) |
| if all_passed: |
| print("✅ ALL VALIDATIONS PASSED!") |
| print("The MVP system is working correctly.") |
| |
| |
| result = call_mcp("query_graph", { |
| "query": """ |
| MATCH (n) |
| RETURN labels(n)[0] as label, count(n) as count |
| ORDER BY count DESC |
| """ |
| }) |
| |
| print() |
| print("Graph Statistics:") |
| for item in result.get("data", []): |
| print(f" - {item['label']}: {item['count']} nodes") |
| |
| else: |
| print("❌ SOME VALIDATIONS FAILED") |
| print("Please check the logs and fix issues.") |
| sys.exit(1) |
| |
| print("=" * 50) |
|
|
| if __name__ == "__main__": |
| main() |
|
|