Skip to main content
Glama

MCP Claude Code

by SDGLBL

grep_ast

Search source code files and view matching lines with AST (Abstract Syntax Tree) context. Understand code structure by identifying how matches fit into functions, classes, and blocks.

Instructions

Search through source code files and see matching lines with useful AST (Abstract Syntax Tree) context. This tool helps you understand code structure by showing how matched lines fit into functions, classes, and other code blocks.

Unlike traditional search tools like search_content that only show matching lines, grep_ast leverages the AST to reveal the structural context around matches, making it easier to understand the code organization.

When to use this tool:

  1. When you need to understand where a pattern appears within larger code structures
  2. When searching for function or class definitions that match a pattern
  3. When you want to see not just the matching line but its surrounding context in the code
  4. When exploring unfamiliar codebases and need structural context
  5. When examining how a specific pattern is used across different parts of the codebase

This tool is superior to regular grep/search_content when you need to understand code structure, not just find text matches.

Example usage:

grep_ast(pattern="function_name", path="/path/to/file.py", ignore_case=False, line_number=True)

Input Schema

NameRequiredDescriptionDefault
ignore_caseNoWhether to ignore case when matching
line_numberNoWhether to display line numbers
pathYesThe path to search in (file or directory)
patternYesThe regex pattern to search for in source code files

Input Schema (JSON Schema)

{ "properties": { "ignore_case": { "default": false, "description": "Whether to ignore case when matching", "title": "Ignore Case", "type": "boolean" }, "line_number": { "default": false, "description": "Whether to display line numbers", "title": "Line Number", "type": "boolean" }, "path": { "description": "The path to search in (file or directory)", "minLength": 1, "title": "Path", "type": "string" }, "pattern": { "description": "The regex pattern to search for in source code files", "minLength": 1, "title": "Pattern", "type": "string" } }, "required": [ "pattern", "path" ], "type": "object" }

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/SDGLBL/mcp-claude-code'

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