Documentation

Anthropic

Connect Milkey to Anthropic Messages with the hosted MCP beta path or the inline tool path.

Overview

Anthropic is best documented through the hosted path first because the SDK can generate the MCP beta config and the required beta header for you.

Inline mode remains available when your app needs direct tool orchestration, but hosted is the best-path default for Messages.

Recommended

Recommended default: hosted

Supported modes

hosted, inline, auto

Helpers

  • milkey.anthropic.tools(...)
  • milkey.anthropic.config(...)
  • milkey.anthropic.messages(...)
  • milkey.anthropic.resolveMode(...)
  • milkey.anthropic.mcpBeta

Examples

Full GitHub example
Use the complete provider example in the SDK repo when you want the full runnable file with imports, env handling, and a realistic integration shape. Open the GitHub example.
import Anthropic from "@anthropic-ai/sdk"import { milkey } from "@milkeyskills/sdk" const anthropic = new Anthropic({  apiKey: process.env.ANTHROPIC_API_KEY!,}) const milkeyClient = milkey.createClient({  baseUrl: process.env.MILKEY_BASE_URL!,  apiKey: process.env.MILKEY_API_KEY!,}) const response = await anthropic.beta.messages.create({  model: process.env.ANTHROPIC_MODEL ?? "claude-sonnet-4-20250514",  max_tokens: 800,  messages: [    {      role: "user",      content: "Find the best Milkey skill for PostgreSQL query optimization.",    },  ],  ...milkey.anthropic.config({    client: milkeyClient,    mode: "auto",  }),})

Hosted Messages API

examples/anthropic-hosted.ts

Inline follow-up

Edge cases and production notes

  • Prefer `milkey.anthropic.config(...)` over hand-assembling the MCP beta pieces. It adds the required beta automatically on hosted paths.
  • Inline follow-up results must be passed back as `tool_result` blocks.
Watch for these edges
  • Hosted Anthropic depends on the Messages beta MCP surface.
  • If your environment strips beta headers or beta config, hosted Anthropic will fail before the tool loop starts.

© 2026 Milkey MCP