Skip to main content
Glama

Search coding-standard rules by keyword

search_rules
Read-onlyIdempotent

Finds 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

NameRequiredDescriptionDefault
langNoRestrict to C (c) or C++ (cpp) rules.any
limitNoMaximum results.
queryYesKeywords separated by spaces; title hits weigh 8x body hits.
standardNoRule 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

NameRequiredDescriptionDefault
queryYesThe query as received.
resultsYesBest match first. Same summary fields as list_rules (without coverage) plus `score`.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.4.1

TDQS

A4.6/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly/idempotent/non-destructive/closed-world, and the description adds real behavioral context beyond them: keyword term-counting rather than semantic search, 1-character tokens ignored, empty-token queries return an empty list, and bundled-data-only with fast reads. It also discloses that MISRA/AUTOSAR coverage is limited to one-line summaries, section names and facts unless licensed texts are loaded — a material expectation-setting detail. A minor gap remains around result ordering/pagination, which keeps it from a 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose, then usage, then caveats — a sensible ordering with no filler sentences. The standard/coverage sentence is dense and long, packing default, alternatives and licensing into one clause, which costs a bit of readability but every clause carries information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return values need not be explained; the description instead covers what would otherwise be unknown — default corpus, cross-standard coverage limits, matching algorithm, degenerate-query behavior, and data locality. For a 4-parameter search tool this is fully sufficient to call correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description earns above that by clarifying the default standard (CERT) and the accepted query forms (rule IDs in any accepted form across EXP34-C, misra-c2012-10.4, A5-2-2), which reinforces the query and standard enum values. It does not discuss `lang` or `limit`, but those are fully documented in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource — rank rules by keyword relevance for a free-text query — and gives concrete query categories (API names like strcpy, concepts like integer overflow, rule IDs like EXP34-C). It also names the default corpus (SEI CERT C/C++) so the agent knows exactly what is being searched without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit routing is provided both ways: 'Use when you know what the code does but not which rule applies' plus two exclusions pointing to named alternatives ('Do not use for structured filters (use list_rules) or to read a rule (use get_rule)'). The selected alternative is named for each excluded case, leaving nothing to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.