Skip to main content
Glama
TESTING.md5.09 kB
# Testing Guide This guide provides step-by-step instructions for testing the CVE MCP Server data loaders and MCP server functionality. ## Testing the Data Loaders ### Option 1: Quick Test with API Loader (Recommended for First Test) ```bash # 1. Ensure you're in the project directory cd /home/dmculver/workspace/projects/cve-mcp-server # 2. Activate virtual environment source venv/bin/activate # 3. Load a small dataset (100 CVEs) to test python -m src.data_ingestion.loader --year 2024 --limit 100 # 4. Verify the database was created ls -lh data/cve.db # 5. Check database contents python -c " from src.database.db import init_db, get_stats conn = init_db() stats = get_stats(conn) print(f'Total CVEs: {stats[\"total_cves\"]}') print(f'Date range: {stats[\"oldest_cve\"]} to {stats[\"newest_cve\"]}') conn.close() " ``` ### Option 2: Full Dataset with Optimized Loader (Takes 6-7 minutes) ```bash # 1. Run the optimized loader (loads all ~240K CVEs) python -m src.data_ingestion.loader_optimized # 2. Check final statistics python -c " from src.database.db import init_db, get_stats conn = init_db() stats = get_stats(conn) print(f'Total CVEs loaded: {stats[\"total_cves\"]}') conn.close() " ``` ## Testing the MCP Server ### Step 1: Run Unit Tests ```bash # Test database operations python tests/test_database.py # Test MCP tool implementations python tests/test_tools.py ``` ### Step 2: Test with MCP Inspector (Interactive UI) **Terminal 1 - Start the MCP Server:** ```bash # Navigate to project directory cd /home/dmculver/workspace/projects/cve-mcp-server # Activate virtual environment source venv/bin/activate # Run the MCP server python -m src.mcp_server ``` **Terminal 2 - Start MCP Inspector:** ```bash # In a NEW terminal npx @modelcontextprotocol/inspector ``` **Configure MCP Inspector:** 1. Open your browser to the URL shown (usually http://localhost:5173) 2. In the connection settings, enter: - **Command**: `python` - **Arguments**: `-m src.mcp_server` - **Environment Variables** (click to expand): - Name: `PYTHONPATH` - Value: `/home/dmculver/workspace/projects/cve-mcp-server` 3. Click **Connect** **Test Each Tool:** 1. **Test get_cve_details:** - Select the `get_cve_details` tool - Input: `{"cve_id": "CVE-2024-0001"}` - Click Execute - Verify you get CVE details back 2. **Test search_cves:** - Select the `search_cves` tool - Input: `{"keyword": "remote code execution", "limit": 5}` - Click Execute - Verify you get search results 3. **Test get_statistics:** - Select the `get_statistics` tool - Input: `{}` - Click Execute - Verify you get database stats ## Testing with Docker (Alternative) ```bash # 1. Build the Docker image docker build -t cve-mcp-server . # 2. Start the container docker compose up -d # 3. Load CVE data into container docker exec cve-mcp-server python -m src.data_ingestion.loader --year 2024 --limit 100 # 4. Test the server with MCP Inspector npx @modelcontextprotocol/inspector # Configure Inspector with: # Command: docker # Arguments: exec -i cve-mcp-server python -m src.mcp_server # Environment: PYTHONPATH=/app # 5. Stop container when done docker compose down ``` ## Testing Custom Configuration ```bash # 1. Create a custom config file cp .env.example .env # 2. Edit .env (optional - customize paths) nano .env # 3. Run loader with custom config python -m src.data_ingestion.loader_optimized # 4. Verify it used your custom paths echo "Check that files were created at your configured paths" ``` ## Quick Verification Commands ```bash # Check if database exists and size ls -lh data/cve.db # Count CVEs in database sqlite3 data/cve.db "SELECT COUNT(*) as total FROM cves;" # View sample CVE sqlite3 data/cve.db "SELECT cve_id, severity, cvss_score FROM cves LIMIT 5;" # Check metadata sqlite3 data/cve.db "SELECT * FROM metadata;" ``` ## Troubleshooting ### Database Not Found If you get "database not found" errors, make sure you've run one of the data loaders first: ```bash python -m src.data_ingestion.loader --year 2024 --limit 10 ``` ### Import Errors Ensure PYTHONPATH is set correctly: ```bash export PYTHONPATH=/home/dmculver/workspace/projects/cve-mcp-server ``` ### MCP Inspector Connection Issues 1. Verify the MCP server is running in Terminal 1 2. Check that PYTHONPATH is set in Inspector environment variables 3. Ensure you're using the correct working directory path ### Docker Container Issues ```bash # Check if container is running docker ps # View container logs docker logs cve-mcp-server # Restart container docker compose restart ``` ## Expected Results ### After Loading 100 CVEs - Database file: `data/cve.db` (~500 KB) - Total CVEs: 100 - Load time: 1-2 minutes ### After Loading Full Dataset - Database file: `data/cve.db` (~190 MB) - Total CVEs: ~240,000 - Load time: 6-7 minutes - Loading speed: ~2,700 CVEs/second ### MCP Tools - `get_cve_details`: Returns JSON with CVE information - `search_cves`: Returns array of matching CVEs - `get_statistics`: Returns database metadata and counts

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/davidculver/cve-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server