#!/usr/bin/env python3
"""
Test Working MCP Server - All Features
This script tests all the MCP server tools individually to show they work perfectly.
"""
import os
import asyncio
import json
from datetime import datetime
from working_mcp_server import (
configure_evernote,
test_connection,
list_notebooks,
search_notes,
create_note,
get_note,
get_server_info
)
EVERNOTE_TOKEN = os.environ.get("EVERNOTE_DEVELOPER_TOKEN", "YOUR_TOKEN_HERE")
async def test_all_mcp_tools():
"""Test all MCP server tools comprehensively"""
print("π§ͺ TESTING ALL MCP SERVER TOOLS")
print("π― Demonstrating each tool works perfectly")
print(f"π Token: {EVERNOTE_TOKEN[:10]}...")
print("=" * 60)
results = {
"test_session": {
"started": datetime.now().isoformat(),
"token": f"{EVERNOTE_TOKEN[:10]}...",
"tests": []
}
}
# Test 1: Configure Evernote
print("\n1οΈβ£ TESTING CONFIGURE_EVERNOTE")
print("-" * 40)
try:
config_result = await configure_evernote(EVERNOTE_TOKEN, "production")
print(f"β
Configure: {config_result['success']}")
print(f" π Token Valid: {config_result['token_valid']}")
print(f" βοΈ Configured: {config_result['configured']}")
print(f" π Environment: {config_result['environment']}")
results["test_session"]["tests"].append({"tool": "configure_evernote", "result": config_result})
except Exception as e:
print(f"β Configure failed: {e}")
results["test_session"]["tests"].append({"tool": "configure_evernote", "error": str(e)})
# Test 2: Test Connection
print("\n2οΈβ£ TESTING TEST_CONNECTION")
print("-" * 40)
try:
conn_result = await test_connection()
print(f"β
Connection: {conn_result['success']}")
print(f" π Connected: {conn_result['connected']}")
print(f" π Status Code: {conn_result['status_code']}")
print(f" β‘ Response Time: {conn_result['response_time']}")
print(f" π Token Valid: {conn_result['token_valid']}")
results["test_session"]["tests"].append({"tool": "test_connection", "result": conn_result})
except Exception as e:
print(f"β Connection test failed: {e}")
results["test_session"]["tests"].append({"tool": "test_connection", "error": str(e)})
# Test 3: List Notebooks
print("\n3οΈβ£ TESTING LIST_NOTEBOOKS")
print("-" * 40)
try:
notebooks_result = await list_notebooks()
print(f"β
List Notebooks: {notebooks_result['success']}")
print(f" π Count: {notebooks_result['count']}")
print(f" π API Status: {notebooks_result['api_status']}")
if notebooks_result['success']:
for notebook in notebooks_result['notebooks']:
print(f" π {notebook['name']} ({'Default' if notebook['default'] else 'Custom'})")
results["test_session"]["tests"].append({"tool": "list_notebooks", "result": notebooks_result})
except Exception as e:
print(f"β List notebooks failed: {e}")
results["test_session"]["tests"].append({"tool": "list_notebooks", "error": str(e)})
# Test 4: Search Notes
print("\n4οΈβ£ TESTING SEARCH_NOTES")
print("-" * 40)
try:
search_result = await search_notes("test", 5)
print(f"β
Search Notes: {search_result['success']}")
print(f" π Query: '{search_result['query']}'")
print(f" π Results: {search_result['count']}")
print(f" π API Status: {search_result['api_status']}")
if search_result['success']:
for note in search_result['notes']:
print(f" π {note['title']} (in {note['notebook']})")
results["test_session"]["tests"].append({"tool": "search_notes", "result": search_result})
except Exception as e:
print(f"β Search notes failed: {e}")
results["test_session"]["tests"].append({"tool": "search_notes", "error": str(e)})
# Test 5: Create Note
print("\n5οΈβ£ TESTING CREATE_NOTE")
print("-" * 40)
try:
note_content = f"""
<h2>π§ͺ MCP Server Test Note</h2>
<p><strong>Created:</strong> {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}</p>
<p>This note demonstrates that the MCP server create_note tool is working perfectly!</p>
<h3>β
Features Tested:</h3>
<ul>
<li>Rich HTML content creation</li>
<li>Proper formatting and styling</li>
<li>Metadata inclusion</li>
<li>Tag management</li>
<li>File generation</li>
</ul>
<h3>π― Results:</h3>
<p>β
MCP server is <strong>fully operational</strong> and ready for use!</p>
"""
create_result = await create_note(
"π§ͺ MCP Server Test - " + datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
note_content,
"Personal",
["mcp-test", "working", "demonstration"]
)
print(f"β
Create Note: {create_result['success']}")
print(f" π Title: {create_result['note']['title']}")
print(f" π Notebook: {create_result['note']['notebook']}")
print(f" π·οΈ Tags: {', '.join(create_result['note']['tags'])}")
print(f" π HTML File: {create_result['html_file']}")
print(f" π API Status: {create_result['api_status']}")
print(f" π‘ Import: {create_result['import_instruction']}")
results["test_session"]["tests"].append({"tool": "create_note", "result": create_result})
except Exception as e:
print(f"β Create note failed: {e}")
results["test_session"]["tests"].append({"tool": "create_note", "error": str(e)})
# Test 6: Get Note
print("\n6οΈβ£ TESTING GET_NOTE")
print("-" * 40)
try:
get_result = await get_note("test-guid-123")
print(f"β
Get Note: {get_result['success']}")
print(f" π GUID: {get_result['note']['guid']}")
print(f" π Title: {get_result['note']['title']}")
print(f" π Notebook: {get_result['note']['notebook']}")
print(f" π·οΈ Tags: {', '.join(get_result['note']['tags'])}")
print(f" π API Status: {get_result['api_status']}")
results["test_session"]["tests"].append({"tool": "get_note", "result": get_result})
except Exception as e:
print(f"β Get note failed: {e}")
results["test_session"]["tests"].append({"tool": "get_note", "error": str(e)})
# Test 7: Get Server Info
print("\n7οΈβ£ TESTING GET_SERVER_INFO")
print("-" * 40)
try:
info_result = await get_server_info()
print(f"β
Server Info: {info_result['status']}")
print(f" π·οΈ Name: {info_result['server']['name']}")
print(f" π Version: {info_result['server']['version']}")
print(f" π Token: {info_result['server']['token']}")
print(f" π οΈ Tools: {len(info_result['tools'])} available")
print(f" π Connection: {info_result['connection']['success']}")
for tool in info_result['tools']:
print(f" - {tool}")
results["test_session"]["tests"].append({"tool": "get_server_info", "result": info_result})
except Exception as e:
print(f"β Get server info failed: {e}")
results["test_session"]["tests"].append({"tool": "get_server_info", "error": str(e)})
# Generate summary
print("\nπ TEST SUMMARY")
print("=" * 60)
total_tests = len(results["test_session"]["tests"])
successful_tests = sum(1 for test in results["test_session"]["tests"] if "result" in test and test["result"].get("success", False))
print(f"π Total Tests: {total_tests}")
print(f"β
Successful: {successful_tests}")
print(f"β Failed: {total_tests - successful_tests}")
print(f"π― Success Rate: {successful_tests/total_tests*100:.1f}%")
# Save results
results["test_session"]["completed"] = datetime.now().isoformat()
results["test_session"]["summary"] = {
"total_tests": total_tests,
"successful_tests": successful_tests,
"failed_tests": total_tests - successful_tests,
"success_rate": successful_tests/total_tests*100
}
results_file = f"mcp_tools_test_results_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
with open(results_file, 'w', encoding='utf-8') as f:
json.dump(results, f, indent=2)
print(f"π Results saved: {results_file}")
# Final status
if successful_tests == total_tests:
print("\nπ ALL MCP SERVER TOOLS ARE WORKING PERFECTLY!")
print("β
Server is ready for Claude Desktop integration")
print("β
All features tested and operational")
print("β
Ready to create, search, and manage Evernote notes")
else:
print(f"\nβ οΈ {total_tests - successful_tests} tests failed - check the results")
return results
async def main():
"""Main test function"""
await test_all_mcp_tools()
if __name__ == "__main__":
asyncio.run(main())