search_cves
Search Common Vulnerabilities and Exposures (CVEs) by keyword in their descriptions to identify relevant security vulnerabilities.
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-66 (handler)The main handler function for the 'search_cves' tool. It connects to the database, calls the search_cves helper, formats the results, and returns JSON.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, registered in list_tools().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-78 (registration)Tool dispatch/registration in the call_tool handler, which invokes tool_search_cves.elif name == "search_cves": result = tool_search_cves( arguments.get("keyword", ""), arguments.get("limit", 10) )
- src/database/db.py:71-77 (helper)Database helper function that performs the SQL query to search CVEs by keyword in description.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()]