#!/usr/bin/env python3
import sys
from pathlib import Path
import json
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
from mcp_server.tools import tool_get_cve_details, tool_search_cves, tool_get_statistics
def test_tools():
print("\nTesting MCP Tools\n")
print("1. get_statistics...")
result = tool_get_statistics()
print(f" Result:\n{result}\n")
print("2. search_cves (keyword: 'remote')...")
result = tool_search_cves("remote", limit=3)
print(f" Result:\n{result}\n")
print("3. get_cve_details...")
search_result = json.loads(tool_search_cves("", limit=1))
if search_result['results']:
cve_id = search_result['results'][0]['cve_id']
print(f" Looking up: {cve_id}")
result = tool_get_cve_details(cve_id)
print(f" Result:\n{result}\n")
else:
print(" No CVEs in database\n")
print("4. get_cve_details (non-existent)...")
result = tool_get_cve_details("CVE-9999-99999")
print(f" Result:\n{result}\n")
print("All tool tests done!")
if __name__ == "__main__":
test_tools()