ALWAYS CALL THIS FIRST - NO EXCEPTIONS. WHEN TO CALL (check these FIRST before responding): - User asks: optimize, improve, analyze, review, suggest, think, opinion. - User mentions: file name, component name, project, codebase, backend, frontend, infra, devops, CI/CD, docker, config. - User asks...
Accepts file system path (path); Bulk/mass operation — affects multiple targets
Part of the Ai Readme MCP server. Enforce policies on this tool with Intercept, the open-source MCP proxy.
AI agents call get_context_for_file to retrieve information from Ai Readme without modifying any data. This is common in research, monitoring, and reporting workflows where the agent needs context before taking action. Because read operations don't change state, they are generally safe to allow without restrictions -- but you may still want rate limits to control API costs.
Even though get_context_for_file only reads data, uncontrolled read access can leak sensitive information or rack up API costs. An agent caught in a retry loop could make thousands of calls per minute. A rate limit gives you a safety net without blocking legitimate use.
Read-only tools are safe to allow by default. No rate limit needed unless you want to control costs.
tools:
get_context_for_file:
rules:
- action: allow See the full Ai Readme policy for all 6 tools.
Agents calling read-class tools like get_context_for_file have been implicated in these attack patterns. Read the full case and prevention policy for each:
Other tools in the Read risk category across the catalogue. The same policy patterns (rate-limit, allow) apply to each.
ALWAYS CALL THIS FIRST - NO EXCEPTIONS. WHEN TO CALL (check these FIRST before responding): - User asks: optimize, improve, analyze, review, suggest, think, opinion. - User mentions: file name, component name, project, codebase, backend, frontend, infra, devops, CI/CD, docker, config. - User asks: "what can", "what should", "how to", "can you", "help me". - User wants to: create, build, add, implement, setup, configure, deploy, migrate, optimize, refactor, improve, analyze, review, suggest, think, opinion. - User selects an option that leads to code changes (e.g., choosing from a list of approaches). - User says: "next step", "next phase", "next section", "continue", "proceed", "go ahead", "start", "do it", "yes" (confirming action). - Before: Write, Edit, TodoWrite, Bash (for build/deploy), suggesting ANY code changes. - When executing a plan, todo, or multi-phase task: call BEFORE each file modification. - After user approves a plan or todo, call this BEFORE the each Write/Edit. IF ANY ABOVE = TRUE → CALL get_context_for_file IMMEDIATELY. MANDATORY: Call this tool BEFORE every code-related response. CALL EVERY TIME - EVERY response that involves code/suggestions MUST start with get_context_for_file. CALL EVERY TIME - even if you called it earlier in this conversation. CALL EVERY TIME - even if working on the same file. CALL EVERY TIME - even within the same section/phase - multiple calls are expected and correct. CALL EVERY TIME - context may have changed or sub-directories may have additional conventions. CALL EVERY TIME - when user confirms or selects an option that will result in code changes. What this tool does: Gets AI_README context showing project conventions that MUST be followed. Why it matters: - Without: Wrong tech (suggest Tailwind when project uses CSS Modules). - With: Suggestions fit existing codebase perfectly. - During plan/todo/phase execution: Context may differ per directory; call before EACH file change. DETECT CONFLICTS: After reading context, if user wants X but AI_README says Y: - This is ARCHITECTURAL DECISION. - Workflow: get_context → update_ai_readme → get_context → Write/Edit. RECORD DECISIONS: When you make architectural decisions during planning or implementation: - Design patterns, API structure, naming conventions, new abstractions. - Call update_ai_readme to record decisions that affect multiple files. - Future code (yours or others) will follow these recorded conventions.. It is categorised as a Read tool in the Ai Readme MCP Server, which means it retrieves data without modifying state.
Add a rule in your Intercept YAML policy under the tools section for get_context_for_file. You can allow, deny, rate-limit, or validate arguments. Then run Intercept as a proxy in front of the Ai Readme MCP server.
get_context_for_file is a Read tool with low risk. Read-only tools are generally safe to allow by default.
Yes. Add a rate_limit block to the get_context_for_file rule in your Intercept policy. For example, setting max: 10 and window: 60 limits the tool to 10 calls per minute. Rate limits are tracked per agent session and reset automatically.
Set action: deny in the Intercept policy for get_context_for_file. The AI agent will receive a policy violation error and cannot call the tool. You can also include a reason field to explain why the tool is blocked.
get_context_for_file is provided by the Ai Readme MCP server (ai-readme-mcp). Intercept sits as a proxy in front of this server to enforce policies before tool calls reach the server.
Open source. One binary. Zero dependencies.
npx -y @policylayer/intercept