search_cves
Search CVE descriptions by keyword to identify security vulnerabilities and exposures in software or systems.
Instructions
Search CVEs by keyword in description
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keyword | Yes | Search term to look for in CVE descriptions | |
| limit | No | Maximum number of results (default: 10, max: 50) |
Implementation Reference
- src/mcp_server/tools.py:41-65 (handler)The handler function that implements the core logic for the 'search_cves' tool: connects to DB, searches, formats results into JSON with truncated descriptions.def tool_search_cves(keyword: str, limit: int = 10) -> str: # TODO: switch to FTS5 for better search performance conn = get_connection() limit = min(max(1, limit), 50) results = search_cves(conn, keyword.strip(), limit) # tried to sort by CVSS score but too slow on large datasets # results.sort(key=lambda x: x.get('cvss_score') or 0, reverse=True) formatted = [] for cve in results: desc = cve['description'] if len(desc) > 300: desc = desc[:300] + "..." formatted.append({ "cve_id": cve['cve_id'], "severity": cve['severity'], "cvss_score": cve['cvss_score'], "description": desc, "published_date": cve['published_date'] }) return json.dumps({"query": keyword, "count": len(formatted), "results": formatted}, indent=2)
- src/mcp_server/server.py:36-54 (schema)The input schema definition for the 'search_cves' tool, defining parameters keyword (required string) and limit (optional integer).Tool( name="search_cves", description="Search CVEs by keyword in description", inputSchema={ "type": "object", "properties": { "keyword": { "type": "string", "description": "Search term to look for in CVE descriptions" }, "limit": { "type": "integer", "description": "Maximum number of results (default: 10, max: 50)", "default": 10 } }, "required": ["keyword"] } ),
- src/mcp_server/server.py:73-77 (registration)The dispatch/registration logic in call_tool handler that maps 'search_cves' tool name to the tool_search_cves function call.elif name == "search_cves": result = tool_search_cves( arguments.get("keyword", ""), arguments.get("limit", 10) )
- src/database/db.py:71-76 (helper)Database helper function that performs the SQL query to search CVEs by keyword in description using LIKE.def search_cves(conn: sqlite3.Connection, keyword: str, limit: int = 10) -> list[dict]: cursor = conn.execute( "SELECT * FROM cves WHERE description LIKE ? LIMIT ?", (f"%{keyword}%", limit) ) return [dict(row) for row in cursor.fetchall()]