Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

feat(docs): add .md support and Accept header for AI agents

Sushmithamallesh121691e970ee
diff --git a/docs/next.config.mjs b/docs/next.config.mjs
index 1a32badb7..6081edc05 100644
--- a/docs/next.config.mjs
+++ b/docs/next.config.mjs
@@ -13,10 +13,15 @@ const config = {
},
async rewrites() {
return [
+ // Support both .md and .mdx extensions for AI agents
{
source: '/docs/:path*.mdx',
destination: '/llms.mdx/docs/:path*',
},
+ {
+ source: '/docs/:path*.md',
+ destination: '/llms.mdx/docs/:path*',
+ },
];
},
async redirects() {
diff --git a/docs/proxy.ts b/docs/proxy.ts
new file mode 100644
index 000000000..85e6744a5
--- /dev/null
+++ b/docs/proxy.ts
@@ -0,0 +1,34 @@
+import { NextRequest, NextResponse } from 'next/server';
+
+/**
+ * Proxy that serves Markdown content when AI agents request it via Accept header.
+ * This follows Lee Robinson's "Agent-Ready" principle:
+ * "Serve Markdown files when Accept: text/markdown is requested"
+ */
+export function proxy(request: NextRequest) {
+ const acceptHeader = request.headers.get('accept') || '';
+
+ // Check if the request prefers markdown (AI agents)
+ const prefersMarkdown =
+ acceptHeader.includes('text/markdown') ||
+ acceptHeader.includes('text/plain');
+
+ // Only apply to /docs pages (not already .md or .mdx)
+ const pathname = request.nextUrl.pathname;
+ if (
+ prefersMarkdown &&
+ pathname.startsWith('/docs') &&
+ !pathname.endsWith('.md') &&
+ !pathname.endsWith('.mdx')
+ ) {
+ // Rewrite to the markdown endpoint
+ const mdUrl = new URL(`${pathname}.md`, request.nextUrl.origin);
+ return NextResponse.rewrite(mdUrl);
+ }
+
+ return NextResponse.next();
+}
+
+export const config = {
+ matcher: ['/docs/:path*'],
+};