Skip to main content
Glama

check_invariant

Check code invariants on the fly using Datalog rules. Returns violations with file and line details for quick audits or pre-commit checks.

Instructions

Check a one-off code invariant using a Datalog rule. Returns violations if broken.

Use this for ad-hoc checks without saving a permanent guarantee. For persistent rules, use create_guarantee + check_guarantees instead.

Use cases:

  • Quick check: "Are there any eval() calls?" — rule: violation(X) :- node(X, "CALL"), attr(X, "name", "eval").

  • Audit: "Functions over 100 lines?" — check for excessive complexity

  • Pre-commit: "Any new SQL injection risks?" — one-time check before pushing

Returns: List of nodes violating the rule, with file and line info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ruleYesDatalog rule defining violation/1
descriptionNoHuman-readable description
limitNoMax violations (default: 10)
offsetNoSkip first N violations (default: 0)
Behavior4/5

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

Describes return format (list of violations with file/line) and implies read-only nature, though could explicitly state non-destructive behavior. No annotations exist, so description carries the burden.

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?

Concise with front-loaded purpose, clear differentiation, use cases, and return info. Every sentence adds value.

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?

Comprehensive for a check tool: explains purpose, when to use vs alternatives, return format, and includes examples. No output schema but return description suffices.

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 covers all 4 parameters, but description adds value by providing a Datalog rule example and explaining the rule's role beyond 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?

Clearly states the tool checks one-off invariants using Datalog rules and returns violations. Distinct from siblings like create_guarantee by specifying ad-hoc vs permanent use.

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?

Explicitly says use for ad-hoc checks and points to create_guarantee + check_guarantees for persistent rules. Provides concrete use cases with examples.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Disentinel/grafema'

If you have feedback or need assistance with the MCP directory API, please join our Discord server