Skip to main content
Glama
ast-grep

ast-grep MCP Server

by ast-grep

test_match_code_rule

Test code against ast-grep YAML rules to verify pattern matching before applying to projects. Validate rule accuracy by scanning code samples.

Instructions

Test a code against an ast-grep YAML rule. This is useful to test a rule before using it in a project.

Internally calls: ast-grep scan --inline-rules --json --stdin

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe code to test against the rule
yamlYesThe ast-grep YAML rule to search. It must have id, language, rule fields.
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds useful context by mentioning the internal call ('Internally calls: ast-grep scan --inline-rules <yaml> --json --stdin'), which hints at the tool's execution method and output format (JSON). However, it doesn't cover aspects like error handling, performance implications, or side effects, leaving gaps in behavioral understanding.

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?

The description is appropriately sized and front-loaded: the first sentence states the core purpose, the second adds usage context, and the third provides internal implementation details. Every sentence earns its place by adding value without redundancy, making it efficient and well-structured for quick comprehension.

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

Completeness3/5

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

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is somewhat complete but has gaps. It explains the purpose and internal call but lacks details on output values, error cases, or integration with sibling tools. Without an output schema, the description should ideally hint at return types, but it only mentions JSON format indirectly, leaving room for improvement in completeness.

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?

The input schema has 100% description coverage, with clear documentation for both parameters ('code' and 'yaml'). The description doesn't add any parameter-specific semantics beyond what the schema provides, such as format details or examples. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate or enhance parameter understanding.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Test a code against an ast-grep YAML rule.' It specifies the verb ('test') and resources ('code' and 'ast-grep YAML rule'), making the action clear. However, it doesn't explicitly differentiate from sibling tools like 'find_code_by_rule', which might have overlapping functionality, preventing a perfect score.

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

Usage Guidelines3/5

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

The description provides some usage context: 'This is useful to test a rule before using it in a project.' This implies when to use the tool (for testing rules pre-deployment) but doesn't specify when not to use it or mention alternatives like sibling tools. The guidance is implied rather than explicit, lacking detailed comparisons or exclusions.

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/ast-grep/ast-grep-mcp'

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