AI Coding Agents & MCP Architecture: AGENTS.md Specs, Tool Sandboxing & Context Engineering
Move beyond ad-hoc prompting into reliable agentic engineering: structure deterministic repository AGENTS.md contracts, design safe Model Context Protocol (MCP) tool schemas, defend against indirect prompt injection, and apply least-privilege sandboxing.
1. Context Engineering: Structuring AGENTS.md & Repository Guardrails
AGENTS.md file acts as a deterministic engineering contractโspecifying exact lint/typecheck/build verification gates, canonical data sources of truth, forbidden anti-patterns, and architectural boundaries so agents self-verify before finishing.| AGENTS.md Section | Concrete Content to Include | Measurable Agent Benefit | Copy |
|---|---|---|---|
| Verification Gates | Exact lint, typecheck, build & audit scripts | Prevents broken commits reaching CI | |
| Single Sources of Truth | Canonical file paths for registries & schemas | Stops duplicated hardcoded lookup maps | |
| Forbidden Anti-Patterns | No unescaped HTML, no silent try/catch swallows | Enforces senior code review standards | |
| Read Budget Rules | Search with ripgrep first, read targeted slices | Preserves finite context window recall |
2. Model Context Protocol (MCP): Strict Schemas & Tool Blast Radius
{
"mcpServers": {
"postgres-readonly": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"POSTGRES_URL": "postgres://readonly_role@127.0.0.1:5432/analytics"
}
}
}
}Enforces read-only database roles at the DBMS engine layer rather than trusting model prompt instructions.
3. Defending Against Indirect Prompt Injection in Untrusted Issues & Web Pages
| Threat Vector | Real Attack Scenario | Hardened Defense Control | Copy |
|---|---|---|---|
| Poisoned GitHub Issue / PR | Hidden HTML comment tricks agent into exfiltration | No outbound curl + read-only credentials | |
| Over-Privileged Secret Env | Prod AWS/Stripe tokens in local dev shell env | Scoped dev .env + secret manager isolation | |
| Bypassed Test Assertions | Agent edits test file to relax failing check | Immutable CI checks + diff review gate |
4. Ground-Truth Verification Loop: Never Trust Unverified Self-Reports
Related Free Online Tools
Put these techniques into practice immediately with our privacy-first browser utilities:
Synthesize strict JSON Schema definitions for Model Context Protocol (MCP) tool parameters.
Audit and restructure MCP server environment variables cleanly without leaking secrets.
Preview structured AGENTS.md and architectural prompt specs cleanly offline.
Independent software developer focused on client-side architectures, local-first computing, WebAssembly, and privacy-first web systems.