Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { |
| 2 | defineConfig, |
| 3 | defineDocs, |
| 4 | defineCollections, |
| 5 | frontmatterSchema, |
| 6 | metaSchema, |
| 7 | applyMdxPreset, |
| 8 | } from 'fumadocs-mdx/config'; |
| 9 | import { transformerTwoslash } from '@shikijs/twoslash'; |
| 10 | import { createFileSystemTypesCache } from '@shikijs/vitepress-twoslash/cache-fs'; |
| 11 | import { remarkMdxMermaid } from 'fumadocs-core/mdx-plugins'; |
| 12 | import { z } from 'zod'; |
| 13 | import { resolveToolkitCount } from './lib/toolkit-count'; |
| 14 | |
| 15 | // You can customise Zod schemas for frontmatter and `meta.json` here |
| 16 | // see https://fumadocs.dev/docs/mdx/collections |
| 17 | |
| 18 | // Extended schema with keywords for search |
| 19 | const docsSchema = frontmatterSchema.extend({ |
| 20 | title: z.string().transform(resolveToolkitCount), |
| 21 | description: z.string().transform(resolveToolkitCount).optional(), |
| 22 | keywords: z.array(z.string()).optional(), |
| 23 | productAreas: z |
| 24 | .array( |
| 25 | z.enum([ |
| 26 | 'authentication-and-connected-accounts', |
| 27 | 'tools-actions-and-execution', |
| 28 | 'triggers-and-workflows', |
| 29 | 'sdk-api-and-mcp', |
| 30 | 'account-billing-and-security', |
| 31 | ]), |
| 32 | ) |
| 33 | .optional(), |
| 34 | toolkitSlugs: z.array(z.string()).optional(), |
| 35 | intents: z |
| 36 | .array( |
| 37 | z.enum([ |
| 38 | 'setup', |
| 39 | 'how-to', |
| 40 | 'troubleshooting', |
| 41 | 'limits-policy', |
| 42 | 'known-issue', |
| 43 | 'reference', |
| 44 | ]), |
| 45 | ) |
| 46 | .optional(), |
| 47 | /** When true, the page shows an "Experimental" badge in the sidebar. */ |
| 48 | experimental: z.boolean().optional(), |
| 49 | /** When true, the page shows a "New" badge in the sidebar. */ |
| 50 | isNew: z.boolean().optional(), |
| 51 | /** When true, the page shows a "Legacy" badge at the top of the page. */ |
| 52 | legacy: z.boolean().optional(), |
| 53 | /** Human-readable date the page/guide was written (e.g. "December 2025"). |
| 54 | * Renders a "Written <date>" stamp at the top of the page, independent of the |
| 55 | * `legacy` flag, so time-sensitive guides carry their own date whether or not |
| 56 | * they're legacy. */ |
| 57 | written: z.string().optional(), |
| 58 | /** Controls which LLM guardrail set is appended to the .md output. |
| 59 | * - undefined / omitted → default session-based guardrails |
| 60 | * - "direct-execution" → softer guardrails acknowledging this is the low-level API |
| 61 | * - "none" → no guardrails appended */ |
| 62 | llmGuardrails: z.enum(['direct-execution', 'none']).optional(), |
| 63 | /** Links rendered in the right-hand "Related" rail under the table of contents. */ |
| 64 | related: z |
| 65 | .array( |
| 66 | z.object({ |
| 67 | title: z.string(), |
| 68 | href: z.string(), |
| 69 | description: z.string().optional(), |
| 70 | }), |
| 71 | ) |
| 72 | .optional(), |
| 73 | /** Presentation metadata for the /examples featured gallery. The card's |
| 74 | * title and description come from `title`/`description`; this controls the |
| 75 | * category lane, toolkit logos, and whether it surfaces in "Featured". */ |
| 76 | gallery: z |
| 77 | .object({ |
| 78 | /** Category lanes this example belongs to (can be more than one). */ |
| 79 | categories: z |
| 80 | .array( |
| 81 | z.enum(['General agents', 'Background agents', 'Coding agents']), |
| 82 | ) |
| 83 | .min(1), |
| 84 | /** Toolkit logo slugs (logos.composio.dev/api/<slug>) shown on the card. */ |
| 85 | logos: z.array(z.string()).default([]), |
| 86 | /** Surface in the default "Featured" view. */ |
| 87 | featured: z.boolean().optional(), |
| 88 | /** Sort order within the grid (lower first). */ |
| 89 | order: z.number().optional(), |
| 90 | }) |
| 91 | .optional(), |
| 92 | }); |
| 93 | |
| 94 | const knowledgeBaseSchema = docsSchema.extend({ |
| 95 | sources: z |
| 96 | .array( |
| 97 | z.object({ |
| 98 | sourcePath: z.string(), |
| 99 | sourceHeading: z.string().nullable(), |
| 100 | }), |
| 101 | ) |
| 102 | .optional(), |
| 103 | lastVerifiedAt: z.string().optional(), |
| 104 | reviewAfter: z.string().optional(), |
| 105 | freshness: z.enum(['evergreen', 'time-sensitive']).optional(), |
| 106 | topics: z.array(z.string()).optional(), |
| 107 | aliases: z.array(z.string()).optional(), |
| 108 | }); |
| 109 | |
| 110 | export const docs = defineDocs({ |
| 111 | dir: 'content/docs', |
| 112 | docs: { |
| 113 | schema: docsSchema, |
| 114 | postprocess: { |
| 115 | includeProcessedMarkdown: true, |
| 116 | }, |
| 117 | }, |
| 118 | meta: { |
| 119 | schema: metaSchema, |
| 120 | }, |
| 121 | }); |
| 122 | |
| 123 | // No twoslash for generated SDK reference docs and changelog entries: a release's changelog can |
| 124 | // describe APIs newer than the SDK versions the docs pin until the docs pin PR merges. |
| 125 | const historicalMdxOptions = applyMdxPreset({ |
| 126 | // Match the global remark plugins so mermaid diagrams in merged |
| 127 | // api-overviews render (applyMdxPreset replaces, not merges). |
| 128 | remarkPlugins: [remarkMdxMermaid], |
| 129 | rehypeCodeOptions: { |
| 130 | themes: { |
| 131 | light: 'github-light', |
| 132 | dark: 'github-dark', |
| 133 | }, |
| 134 | }, |
| 135 | }); |
| 136 | |
| 137 | export const reference = defineDocs({ |
| 138 | dir: 'content/reference', |
| 139 | docs: { |
| 140 | schema: docsSchema, |
| 141 | postprocess: { |
| 142 | includeProcessedMarkdown: true, |
| 143 | }, |
| 144 | mdxOptions: historicalMdxOptions, |
| 145 | }, |
| 146 | meta: { |
| 147 | schema: metaSchema, |
| 148 | }, |
| 149 | }); |
| 150 | |
| 151 | export const examples = defineDocs({ |
| 152 | dir: 'content/examples', |
| 153 | docs: { |
| 154 | schema: docsSchema, |
| 155 | postprocess: { |
| 156 | includeProcessedMarkdown: true, |
| 157 | }, |
| 158 | }, |
| 159 | meta: { |
| 160 | schema: metaSchema, |
| 161 | }, |
| 162 | }); |
| 163 | |
| 164 | export const toolkits = defineDocs({ |
| 165 | dir: 'content/toolkits', |
| 166 | docs: { |
| 167 | schema: docsSchema, |
| 168 | files: ['**/*', '!faq/**'], |
| 169 | postprocess: { |
| 170 | includeProcessedMarkdown: true, |
| 171 | }, |
| 172 | }, |
| 173 | meta: { |
| 174 | schema: metaSchema, |
| 175 | }, |
| 176 | }); |
| 177 | |
| 178 | export const knowledgeBase = defineDocs({ |
| 179 | dir: 'content/kb', |
| 180 | docs: { |
| 181 | schema: knowledgeBaseSchema, |
| 182 | postprocess: { |
| 183 | includeProcessedMarkdown: true, |
| 184 | }, |
| 185 | }, |
| 186 | meta: { |
| 187 | schema: metaSchema, |
| 188 | }, |
| 189 | }); |
| 190 | |
| 191 | export const changelog = defineCollections({ |
| 192 | type: 'doc', |
| 193 | dir: 'content/changelog', |
| 194 | mdxOptions: historicalMdxOptions, |
| 195 | postprocess: { |
| 196 | includeProcessedMarkdown: true, |
| 197 | }, |
| 198 | schema: frontmatterSchema.extend({ |
| 199 | sdkRelease: z.string().optional(), |
| 200 | sdkReleaseTargets: z.record(z.string(), z.string()).optional(), |
| 201 | date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, { |
| 202 | message: 'Date must be in YYYY-MM-DD format (e.g., "2025-12-29")', |
| 203 | }), |
| 204 | }), |
| 205 | }); |
| 206 | |
| 207 | export default defineConfig({ |
| 208 | plugins: [ |
| 209 | { |
| 210 | name: 'toolkit-count', |
| 211 | doc: { |
| 212 | vfile(file) { |
| 213 | file.value = resolveToolkitCount(String(file.value)); |
| 214 | }, |
| 215 | }, |
| 216 | }, |
| 217 | ], |
| 218 | mdxOptions: { |
| 219 | remarkPlugins: [remarkMdxMermaid], |
| 220 | rehypeCodeOptions: { |
| 221 | themes: { |
| 222 | light: 'github-light', |
| 223 | dark: 'github-dark', |
| 224 | }, |
| 225 | // Twoslash for type checking only - no hover UI |
| 226 | transformers: |
| 227 | process.env.NODE_ENV === 'production' |
| 228 | ? [ |
| 229 | transformerTwoslash({ |
| 230 | explicitTrigger: false, |
| 231 | twoslashOptions: { |
| 232 | compilerOptions: { |
| 233 | jsx: 4, // JsxEmit.ReactJSX |
| 234 | jsxImportSource: 'react', |
| 235 | // Twoslash type-checks code blocks in its own virtual TS |
| 236 | // environment, which carries a `baseUrl` default that TS 6 |
| 237 | // flags as deprecated (TS5101). Silence it here, mirroring |
| 238 | // the root tsconfig.json, so production builds don't fail. |
| 239 | ignoreDeprecations: '6.0', |
| 240 | // TS 6 no longer auto-includes `@types/node` ambiently the |
| 241 | // way 5.9 did, so code blocks using Node globals (`crypto`, |
| 242 | // `process`, `Buffer`) fail to resolve them (TS2591). Pull |
| 243 | // node types in explicitly to restore that. |
| 244 | types: ['node'], |
| 245 | }, |
| 246 | }, |
| 247 | typesCache: createFileSystemTypesCache({ |
| 248 | dir: '.next/cache/twoslash', |
| 249 | }), |
| 250 | renderer: { |
| 251 | // Empty renderer - type checks but renders nothing |
| 252 | nodeStaticInfo: () => ({}), |
| 253 | nodeError: () => ({}), |
| 254 | nodeQuery: () => ({}), |
| 255 | nodeCompletion: () => ({}), |
| 256 | }, |
| 257 | }), |
| 258 | ] |
| 259 | : [], |
| 260 | }, |
| 261 | }, |
| 262 | }); |