grep_controls_in_markdown
Search markdown files for FedRAMP security control identifiers to locate compliance documentation and guidance within FedRAMP documentation.
Instructions
Search markdown files for occurrences of a control identifier.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| control | Yes | ||
| with_enhancements | No |
Implementation Reference
- The execute handler for the 'grep_controls_in_markdown' tool. It receives input and calls the core grepControlsInMarkdown function with the control and enhancements flag.execute: async (input) => { const matches = grepControlsInMarkdown( input.control, input.with_enhancements ?? true, ); return { matches }; },
- Zod input schema defining 'control' (string) and 'with_enhancements' (boolean, default true).const schema = z.object({ control: z.string(), with_enhancements: z.boolean().default(true), });
- src/search.ts:76-100 (helper)Core helper function that implements the grep logic: searches indexed markdown documents for control occurrences using regex, with optional enhancement matching (e.g., with params).export function grepControlsInMarkdown( control: string, withEnhancements: boolean, ): Array<{ path: string; line: number; snippet: string }> { const docs = getIndexState().markdownDocs; const escaped = escapeStringRegexp(control); const controlRegex = withEnhancements ? new RegExp(`${escaped}(\\([^)]+\\))?`, "g") : new RegExp(`${escaped}(?!\\()`, "g"); const matches: Array<{ path: string; line: number; snippet: string }> = []; for (const doc of docs.values()) { doc.lines.forEach((line, idx) => { if (controlRegex.test(line)) { matches.push({ path: doc.path, line: idx + 1, snippet: line.trim().slice(0, 240), }); } controlRegex.lastIndex = 0; }); } return matches; }
- src/tools/register.ts:14-14 (registration)Import of the grepControlsTool for registration.import { grepControlsTool } from "./grep_controls_in_markdown.js";
- src/tools/register.ts:47-47 (registration)Registration of grepControlsTool in the tools array passed to registerToolDefs.grepControlsTool,