Skip to main content

Documentation Index

Fetch the complete documentation index at: https://motherfuckingsideproject.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

Configuration

Overview of all AgentXP configuration options and how to apply them.
Configure AgentXP by passing an options object directly to withAgentXP() in your middleware.ts. No separate config file is required.
middleware.ts
import { withAgentXP } from '@reaganhsu/agentxp-next'

export default withAgentXP({
  detection: { /* ... */ },
  transform: { /* ... */ },
  permissions: { /* ... */ },
  llmsTxt: { /* ... */ },
  siteHeader: { /* ... */ },
})

export const config = {
  matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
}

Type-safe config with defineConfig()

For projects where you want to define configuration separately and get full TypeScript inference, import defineConfig() from @reaganhsu/agentxp-core:
agentxp.config.ts
import { defineConfig } from '@reaganhsu/agentxp-core'

export default defineConfig({
  detection: { /* ... */ },
  transform: { /* ... */ },
  permissions: { /* ... */ },
})
Then spread it into withAgentXP():
middleware.ts
import { withAgentXP } from '@reaganhsu/agentxp-next'
import agentxpConfig from './agentxp.config'

export default withAgentXP({
  ...agentxpConfig,
  llmsTxt: {
    siteName: 'My App',
  },
})
defineConfig() is a zero-overhead identity function — it exists solely for TypeScript autocompletion and type-checking. It does not load, validate, or transform your config at runtime.

Configuration shape

The object passed to withAgentXP() accepts the following top-level keys:
KeyTypeDescription
detectionobjectControls how AgentXP identifies AI agent requests
transformobjectControls HTML-to-markdown conversion
permissionsobjectSignals what agents are permitted to do with your content
llmsTxtobjectConfigures the auto-generated /llms.txt index
siteHeaderobjectManual navigation context prepended to every markdown response

Complete example

middleware.ts
import { withAgentXP } from '@reaganhsu/agentxp-next'

export default withAgentXP({
  detection: {
    signals: ['accept-header', 'user-agent'],
    customAgents: [
      { name: 'MyBot', pattern: /MyCustomBot\/\d+/i },
    ],
  },

  transform: {
    contentSelector: 'main',
    excludeSelectors: ['.chat-widget', '.cookie-banner', '#intercom-container'],
    maxTokens: 8000,
  },

  permissions: {
    aiTrain: false,
    aiInput: true,
    search: true,
  },

  llmsTxt: {
    siteName: 'My SaaS App',
    description: 'Project management tool for engineering teams',
    pages: [
      { path: '/', title: 'Home', section: 'Product' },
      { path: '/pricing', title: 'Pricing', section: 'Product' },
      { path: '/docs', title: 'Documentation', section: 'Documentation' },
      { path: '/blog', title: 'Blog', section: 'Resources' },
    ],
  },

  siteHeader: {
    name: 'My App',
    links: [
      { text: 'Docs', href: '/docs' },
      { text: 'Pricing', href: '/pricing' },
      { text: 'Blog', href: '/blog' },
    ],
  },
})

export const config = {
  matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
}

Configuration sections

Detection

Configure which signals AgentXP uses to identify AI agents.

Transform

Control how HTML pages are converted to markdown.

Permissions

Signal what agents may do with your content.

llms.txt

Configure the auto-generated site index for AI agents.