Search coding-standard rules by keyword
search_rulesFinds which coding rule applies when you know what the code does but not its ID: ranks SEI CERT, MISRA or AUTOSAR rules by keyword relevance to a free-text query.
Instructions
Rank rules by keyword relevance to a free-text query: API names (strcpy, malloc, pthread_mutex_lock), concepts (integer overflow) or a rule ID in any accepted form (EXP34-C, misra-c2012-10.4, A5-2-2). Searches SEI CERT C/C++ by default; set standard for MISRA or AUTOSAR, where only our one-line summaries, section names and facts are searchable (plus licensed texts when loaded). Use when you know what the code does but not which rule applies. Do not use for structured filters (use list_rules) or to read a rule (use get_rule). Case-insensitive term counting, not semantic search; 1-character tokens are ignored and a query with no usable token returns an empty list. Reads bundled data only; fast.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "<query>"
},
"name": "search_rules"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lang | No | Restrict to C (c) or C++ (cpp) rules. | any |
| limit | No | Maximum results. | |
| query | Yes | Keywords separated by spaces; title hits weigh 8x body hits. | |
| standard | No | Rule set: cert = SEI CERT C and C++ (default; the only standard with full rule text); misra = MISRA C:2012 (with Amendments 1-4, i.e. the MISRA C:2023 set) and MISRA C++:2023; autosar = AUTOSAR C++14; or one standard by name; all = every standard. | cert |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The query as received. | |
| results | Yes | Best match first. Same summary fields as list_rules (without coverage) plus `score`. |