← Tools

Markdown For Agents Generator

The Agent Runtime Readiness audit warns when your host returns HTML to Accept: text/markdown instead of a clean markdown twin. Pick your platform and pattern, get the paste-ready code that fixes it.

Why this matters → · Run the audit first →

1. Configure

Match your template's primary content container. Without this, nav and footer leak into the markdown output.
How long the markdown response stays in CDN cache. 300s is a sensible default.

What this fixes

The Agent Runtime Readiness audit's third check sends a request with Accept: text/markdown. If your origin returns HTML instead of a markdown body with Content-Type: text/markdown; charset=utf-8, the check warns. AI runtimes (OpenAI Agents SDK, Cloudflare Project Think, MCP-style fetchers) increasingly send this header to retrieve a clean text twin, smaller than the HTML and easier to feed into a context window.

This generator emits the implementation that makes that response correct. Pair with the Cloudflare AI Cache Rule Generator for the eligibility side (avoiding 499 timeouts).

Pattern guidance

When to pick Companion .md files

Your source is already markdown (Eleventy, Hugo, Astro, Next.js MDX, Jekyll). The pattern serves the existing source files when negotiated. Lower CPU per request, easier to debug, but requires that you publish a .md companion alongside every URL.

When to pick Runtime conversion

Your source is HTML, a CMS, a SPA, or anything that doesn't have markdown sitting on disk. The pattern converts the rendered HTML to markdown at request time using turndown (JS) or league/html-to-markdown (PHP). Higher CPU per cache miss but works on any source.

Vary: Accept is mandatory

Every output emitted by this tool sets Vary: Accept on the response. Without it, your CDN or browser cache will collapse the HTML and markdown responses into one entry and serve the wrong shape to the wrong client. Don't strip this header.

Disclaimer

Generated code is a starting point. Test on a non-production hostname or path first. Real-world templates vary; the main selector and any custom CSP / WAF rules at your origin can change what your edge layer sees.