simple_test.pyโข2.8 kB
#!/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()