Compilation Targets

All 10 Anvil compilation targets — MCP, OpenAPI, docs, agent schema, eval, SDK, CLI, Anthropic, OpenAI, Vercel AI.

Available Targets

| Target | Package | Output | |--------|---------|--------| | MCP Server | @anvil-tools/target-mcp | TypeScript MCP server | | OpenAPI | @anvil-tools/target-openapi | OpenAPI 3.1 spec | | Documentation | @anvil-tools/target-docs | Markdown docs | | Agent Schema | @anvil-tools/target-agent-schema | LLM-optimized JSON | | Eval Harness | @anvil-tools/target-eval | Vitest/Jest test suite | | TypeScript SDK | @anvil-tools/target-sdk-ts | Typed client | | CLI | @anvil-tools/target-cli-gen | Commander CLI | | Anthropic | @anvil-tools/target-anthropic | Claude API tools | | OpenAI | @anvil-tools/target-openai | GPT function calling | | Vercel AI | @anvil-tools/target-vercel-ai | AI SDK tools |

Zero-Config Usage

All targets are built into the CLI — no config file or extra installs needed:

anvil compile --target mcp                # one target
anvil compile --target mcp,docs,openapi   # multiple targets
anvil compile --all                       # all 10 targets

Advanced Configuration

For custom options, use anvil.config.ts:

import { defineConfig } from '@anvil-tools/compiler';
import { mcp } from '@anvil-tools/target-mcp';
import { openapi } from '@anvil-tools/target-openapi';
import { docs } from '@anvil-tools/target-docs';

export default defineConfig({
  tools: './**/*.anvil.yaml',
  targets: [
    mcp({ transport: 'stdio' }),
    openapi({ format: 'json' }),
    docs({ singleFile: true }),
  ],
  outDir: './dist',
});

MCP Server Target

Generates a production-ready MCP server using @modelcontextprotocol/sdk.

mcp({
  transport: 'stdio',  // 'stdio' | 'http'
  port: 3000,          // for HTTP transport
})

The generated server includes:

  • Tool registration with full JSON Schema input validation
  • MCP annotations (readOnlyHint, destructiveHint, idempotentHint)
  • Handler stubs for implementation
  • Package.json and tsconfig.json

Writing Custom Targets

Implement the AnvilTarget interface:

import type { AnvilTarget } from '@anvil-tools/compiler';
import type { AnvilIR } from '@anvil-tools/schema';

const myTarget: AnvilTarget = {
  name: 'my-target',
  description: 'My custom target',

  async generate(ir: AnvilIR) {
    return {
      target: 'my-target',
      files: [{
        path: 'output.json',
        content: JSON.stringify(ir, null, 2),
        type: 'schema',
      }],
    };
  },
};