Skip to main content
Glama

search_sections

Search section bodies in a Markdown file for lines matching a regex query, returning line numbers and matching text. Excludes headings and child sections to avoid duplicates.

Instructions

Search all section bodies for lines matching query (regex).

Returns a list of match objects — one per section that contains at least one hit — in file order:

[
  {
    "path": "Root.Child",
    "matches": [
      {"line": 12, "text": "...the matching line text..."},
      ...
    ]
  },
  ...
]

line is the 1-based line number within the file. Only each section's own body is searched (not its children), so results are never duplicated across parent and child sections. Note: heading text is not searched — only section bodies. If the term you are looking for may appear in a heading, call get_index first and scan the returned paths. query is a Python regex; raises an error string if the pattern is invalid.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
file_pathYes
case_sensitiveNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

With no annotations, the description fully discloses behavior: return format (match objects with path, line number, text), line numbering (1-based), scope (only section bodies, not children or headings), error handling (raises error string on invalid regex). No contradictions with annotations since none exist.

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 concise and well-structured, starting with the main action, then providing a clear example of the return format, followed by important notes. Every sentence adds value, and the structure aids readability.

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?

Given the tool's complexity and presence of an output schema (though not shown), the description covers all necessary aspects: return value format, scope, line numbering, error behavior, and reference to alternative. It is complete for a search operation.

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 0%, so description must compensate. It explains `query` is a Python regex, and `file_path` is implied as the file to search. However, the third parameter `case_sensitive` is not mentioned at all, leaving its semantics unclear from the description alone. Partial compensation but incomplete.

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 explicitly states 'Search all section bodies for lines matching `query` (regex)', providing a specific verb and resource. It distinguishes from sibling tools like add_section, delete_section, get_index, etc., none of which are search functions.

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?

The description provides explicit guidance: 'Note: heading text is not searched — only section bodies. If the term you are looking for may appear in a heading, call `get_index` first and scan the returned paths.' This tells when not to use the tool and suggests an alternative. Also notes that only section bodies are searched, not children, avoiding confusion.

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/afriemann/md-mcp'

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