MDX.org.ai
Executable Code

Executable Code

Functions, agents, workflows, and execution runtimes

The Executable Code layer brings MDX documents to life with TypeScript functions, AI agents, event-driven workflows, and multiple execution runtimes.

Core Concepts

Function

AI function definitions with four variants:

  • CodeFunction - Deterministic TypeScript
  • GenerativeFunction - LLM-generated responses
  • AgenticFunction - Multi-step AI reasoning
  • HumanFunction - Human-in-the-loop approval

See the Function overview.

Agent

Autonomous AI entities with roles, goals, and team coordination.

const writer = await createAgent({
  name: 'ContentWriter',
  role: writerRole,
  mode: 'supervised',
  goals: [dailyPostsGoal],
})

See the Agent overview.

Workflow

Event-driven business logic using the $ context:

$.on.Order.placed(async (order) => {
  await $.do('processPayment', { orderId: order.id })
  $.send('Shipment.create', { order })
})
 
$.every.day.at('9:00')(async () => {
  await $.do('sendDailyDigest')
})

See the Workflow overview.

Packages

mdxe

Execute MDX in various runtimes:

  • @mdxe/workers - Cloudflare Workers (and local dev under Miniflare)
  • @mdxe/hono - Hono web framework
  • @mdxe/ink - Terminal UI

See the mdxe overview.

mdxai

AI integrations:

  • @mdxai/claude - Claude AI with MCP tools
  • @mdxai/mastra - Mastra agent framework
  • @mdxai/vapi - Voice AI

See the mdxai overview.

On this page