Skip to main content
Glama

Query lessons for diff context

query_lessons
Read-onlyIdempotent

Find coding rules most relevant to your code diff or PR, ranked by severity, to guide fixes before opening a PR. Paste your diff and set a token budget to get concise, actionable lessons.

Instructions

Retrieve the learning rules ("lessons") most relevant to a given code diff or PR context, packed within a token budget. Uses bi-encoder retrieval + severity-weighted scoring; pass the diff/description as diffText and a maxTokens budget (default 3000). Returns ranked { lessons: [{ title, rule, severity }] }. Read-only. Use before writing a fix or opening a PR; use list_lessons to browse all lessons unfiltered.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topKNoMax number of lessons to return (default 15, max 50). (`top_k` is accepted too.)
diffTextYesThe PR diff, code snippet, or description of the change being made. (`diff_text` is accepted too.)
maxTokensNoMaximum tokens for returned lessons context (default 3000, max 8000). (`max_tokens` is accepted too.)
projectIdNoProject UUID. Defaults to configured project. (`project_id` is accepted too.)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed9 schema fields changedv0.1.12
    • addedInput schema / properties / diffText
      Added value: +{
      +  "description": "The PR diff, code snippet, or description of the change being made. (`diff_text` is accepted too.)",
      +  "type": "string"
      +}
    • removedInput schema / properties / diff_text
      Removed value: -{
      -  "description": "The PR diff, code snippet, or description of the change being made.",
      -  "type": "string"
      -}
    • addedInput schema / properties / maxTokens
      Added value: +{
      +  "description": "Maximum tokens for returned lessons context (default 3000, max 8000). (`max_tokens` is accepted too.)",
      +  "type": "number"
      +}
    • removedInput schema / properties / max_tokens
      Removed value: -{
      -  "description": "Maximum tokens for returned lessons context (default 3000, max 8000).",
      -  "type": "number"
      -}
    • addedInput schema / properties / projectId
      Added value: +{
      +  "description": "Project UUID. Defaults to configured project. (`project_id` is accepted too.)",
      +  "type": "string"
      +}
    • removedInput schema / properties / project_id
      Removed value: -{
      -  "description": "Project UUID. Defaults to configured project.",
      -  "type": "string"
      -}
    • addedInput schema / properties / topK
      Added value: +{
      +  "description": "Max number of lessons to return (default 15, max 50). (`top_k` is accepted too.)",
      +  "type": "number"
      +}
    • removedInput schema / properties / top_k
      Removed value: -{
      -  "description": "Max number of lessons to return (default 15, max 50).",
      -  "type": "number"
      -}
    • changedInput schema / required
      Previous value: -[
      -  "diff_text"
      -]New value: +[
      +  "diffText"
      +]
  2. Changed1 schema field changedv0.1.10
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
  3. First observedv0.1.0

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, openWorldHint, and idempotentHint, so the safety profile is well covered. The description adds non-obvious behavior: bi-encoder retrieval, severity-weighted scoring, and token-budget packing, which are valuable beyond annotation hints.

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

Conciseness5/5

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

Three dense sentences front-load purpose, then mechanics, then usage guidance. Every sentence earns its place with no redundancy or filler.

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?

The description is complete for a read-only retrieval tool: it states the return shape ({ lessons: [...] }), usage context, and distinguishes from sibling list_lessons. With full schema coverage and safety annotations, no critical information is missing.

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

Parameters3/5

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

Schema coverage is 100%, so baseline is 3. The description mentions diffText and maxTokens defaults but those details already exist in the schema; no new parameter meaning is added beyond what the schema descriptors provide.

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?

States a specific verb ('retrieve'), resource ('learning rules/lessons'), and context ('code diff or PR'). The description explicitly contrasts with list_lessons, naming what it is not and making sibling differentiation immediate.

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?

Gives explicit when-to-use guidance: 'Use before writing a fix or opening a PR'. It also names the alternative list_lessons for browsing all lessons unfiltered, providing a clear decision boundary.

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