#!/usr/bin/env python3
"""Simple test script for the GitHub MCP Server functions."""
import server
import json
def test_basic_functionality():
"""Test basic functionality without MCP decorators."""
print("π§ͺ Testing Basic Functionality")
print("=" * 50)
# Test 1: Check if styles are available
print("β
Available styles:")
for style in server.ACCEPTED_STYLES:
print(f" - {style}")
# Test 2: Test style validation
print(f"\nβ
Total styles: {len(server.ACCEPTED_STYLES)}")
# Test 3: Test URL parsing
test_url = "https://raw.githubusercontent.com/microsoft/vscode/main/README.md"
parsed = server.parse_github_url(test_url)
print(f"\nβ
URL parsing test:")
print(f" URL: {test_url}")
if parsed:
print(f" Owner: {parsed['owner']}")
print(f" Repo: {parsed['repo']}")
print(f" Branch: {parsed['branch']}")
print(f" File: {parsed['file_path']}")
else:
print(" β Failed to parse URL")
# Test 4: Test review generation
sample_code = "def hello():\n print('Hello, World!')"
review = server.generate_style_review(sample_code, "pirate")
print(f"\nβ
Review generation test (pirate style):")
print(f" Preview: {review[:100]}...")
print("\n" + "=" * 50)
print("π Basic functionality tests passed!")
def test_mcp_server_start():
"""Test if the MCP server can start."""
print("\nπ§ͺ Testing MCP Server Start")
print("=" * 50)
try:
# Check if app is properly initialized
print(f"β
App name: {server.app.name}")
print(f"β
App description: {server.app.instructions}")
# Check if tools are registered
tools = getattr(server.app, '_tools', {})
print(f"β
Registered tools: {len(tools)}")
for tool_name in tools:
print(f" - {tool_name}")
print("\nβ
MCP server is properly initialized!")
except Exception as e:
print(f"β MCP server initialization failed: {e}")
print("\n" + "=" * 50)
def main():
"""Run simple tests."""
print("π Simple GitHub MCP Server Test")
print("=" * 60)
try:
test_basic_functionality()
test_mcp_server_start()
print("\nπ All tests completed!")
print("\nπ Ready for Cursor integration!")
print("π‘ To test in Cursor:")
print(" 1. Restart Cursor")
print(" 2. Try: 'Download and review these files in pirate style: https://raw.githubusercontent.com/microsoft/vscode/main/README.md'")
except Exception as e:
print(f"β Test failed: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
main()