Developer Guide
Everything you need to build ANML-powered services and agents. Choose your language, install the SDK, and start publishing or consuming duckuments in minutes.
Choose your role
đ¤ Building an Agent (Client)
Your agent needs to discover, fetch, and act on ANML duckuments from services on the web.
You need a client SDK:
- âĸ Discover services via well-known URIs
- âĸ Parse XML/JSON duckuments
- âĸ Evaluate disclosure constraints
- âĸ Execute actions on behalf of users
- âĸ Navigate multi-step flows
đī¸ Building a Service (Server)
Your service needs to publish ANML duckuments so agents can understand and interact with it.
You need a server SDK:
- âĸ Build duckuments with type-safe builders
- âĸ Serialize to XML or JSON automatically
- âĸ Serve discovery endpoints
- âĸ Validate documents against the spec
- âĸ Handle content negotiation
Install
Python
pip install anml-clientpip install anml-serverNode.js / TypeScript
npm install @anml-foundation/clientnpm install @anml-foundation/serverRust
cargo add anml-clientcargo add anml-serverClient Quick Start
Fetch an ANML duckument, read its knowledge, and execute an action.
Python
import asyncio
from anml_client import AnmlClient, AllowListTrustPolicy
async def main():
client = (
AnmlClient.builder()
.base_url("https://shop.example.com")
.trust_policy(AllowListTrustPolicy(["https://shop.example.com"]))
.build()
)
# Fetch the service's ANML duckument
doc = await client.fetch("/.well-known/anml")
# Read what the service wants to tell us
for inform in doc.knowledge.inform if doc.knowledge else []:
print(f"âšī¸ {inform.content}")
# Check what data the service needs
for ask in doc.knowledge.ask if doc.knowledge else []:
print(f"â Needs: {ask.field} (purpose: {ask.purpose})")
# Execute an action (after getting user consent for disclosed fields)
response = await client.execute_action(doc, "checkout", {
"email": "user@example.com",
"shipping_address": "123 Main St",
})
print(f"â
{response.status_code}")
asyncio.run(main())Node.js / TypeScript
import { AnmlClient, AllowListTrustPolicy } from '@anml-foundation/client';
const client = AnmlClient.builder()
.baseUrl('https://shop.example.com')
.trustPolicy(new AllowListTrustPolicy(['https://shop.example.com']))
.build();
// Fetch the service's ANML duckument
const doc = await client.fetch('/.well-known/anml');
// Read knowledge the service shares
for (const inform of doc.knowledge?.inform ?? []) {
console.log(`âšī¸ ${inform.content}`);
}
// Execute an action
const response = await client.executeAction(doc, 'checkout', {
email: 'user@example.com',
shippingAddress: '123 Main St',
});
console.log(`â
${response.status}`);Server Quick Start
Build an ANML duckument that describes your service to agents. The SDK handles serialization, validation, and discovery â you provide the business logic.
Python (FastAPI)
from fastapi import FastAPI, Request
from anml_server import AnmlDocument, negotiate_content_type
app = FastAPI()
@app.get("/.well-known/anml")
async def serve_anml(request: Request):
doc = (
AnmlDocument.builder()
.title("Acme Electronics â Checkout")
.ttl(300)
# Brand & persona
.persona(
tone="helpful",
instructions="Show itemized totals. Confirm before payment.",
brand_color="#4F46E5",
logo_url="https://acme.example.com/logo.png",
)
# Privacy constraints
.disclosure("payment-credential", requires="explicit-consent")
.disclosure("shipping-address", requires="explicit-consent")
.disclosure("email", requires="legitimate-interest")
# Workflow state
.flow([
Step("browse", label="Browse", status="completed"),
Step("checkout", label="Checkout", status="current", action="submit-order"),
Step("confirm", label="Confirmed", status="pending"),
])
# Actions the agent can take
.action(
"submit-order",
method="POST",
endpoint="/api/orders",
auth="required",
confirm=True,
)
# Knowledge exchange
.inform("Free shipping on orders over $75. 30-day returns.", ttl=3600)
.inform("Holiday sale: 20% off all monitors through Dec 31.", ttl=86400)
.ask("email", action="submit-order", required=True, purpose="receipt")
.ask("shipping-address", action="submit-order", required=True, purpose="delivery")
# Usage rights
.rights("cache")
# Content
.body("4K Monitor x1 â $599.00 | USB-C Cable x2 â $29.98 | Subtotal: $628.98")
.build()
)
content_type = negotiate_content_type(request.headers.get("accept", ""))
return doc.to_response(content_type=content_type)Node.js (Express)
import express from 'express';
import { AnmlDocument, negotiateContentType } from '@anml-foundation/server';
const app = express();
app.get('/.well-known/anml', (req, res) => {
const doc = AnmlDocument.builder()
.title('Acme Electronics â Checkout')
.ttl(300)
.persona({
tone: 'helpful',
instructions: 'Show itemized totals. Confirm before payment.',
brandColor: '#4F46E5',
logoUrl: 'https://acme.example.com/logo.png',
})
.disclosure('payment-credential', { requires: 'explicit-consent' })
.disclosure('shipping-address', { requires: 'explicit-consent' })
.flow([
{ id: 'browse', label: 'Browse', status: 'completed' },
{ id: 'checkout', label: 'Checkout', status: 'current', action: 'submit-order' },
{ id: 'confirm', label: 'Confirmed', status: 'pending' },
])
.action('submit-order', {
method: 'POST',
endpoint: '/api/orders',
auth: 'required',
confirm: true,
})
.inform('Free shipping on orders over $75. 30-day returns.', { ttl: 3600 })
.ask('email', { action: 'submit-order', required: true, purpose: 'receipt' })
.ask('shipping-address', { action: 'submit-order', required: true, purpose: 'delivery' })
.rights('cache')
.body('4K Monitor x1 â $599.00 | USB-C Cable x2 â $29.98 | Subtotal: $628.98')
.build();
const contentType = negotiateContentType(req.headers.accept);
res.type(contentType).send(doc.serialize(contentType));
});
app.listen(3000);Key Concepts
Discovery
Agents find your ANML duckument via /.well-known/anml, Link headers, or HTML <link> tags. The server SDK sets these up automatically. The client SDK checks all three.
Disclosure & Consent
Before sharing user data, agents must evaluate your disclosure constraints. Fields marked 'explicit-consent' require the user to actively agree. The client SDK enforces this â it won't send data that violates constraints.
Knowledge Exchange
Use 'inform' to proactively tell agents things (policies, deals, availability). Use 'ask' to request data from agents (with a stated purpose). Agents decide whether to comply based on their trust policy and user preferences.
Flow State
Multi-step workflows (browse â checkout â payment â confirm) are explicit in the duckument. Agents always know where the user is and what comes next. No inference required.
Persona & Branding
Tell agents how to represent your service: tone, language, brand colors, logo, and specific instructions. The agent adapts its presentation to match your brand identity.
Content Negotiation
Agents request XML or JSON via the Accept header. Your server SDK handles serialization automatically. Both formats are normative and semantically identical.
Trust & Rights
Usage rights (none < display < cache < store < train) tell agents what they can do with your content. Trust delegation via DNS lets you verify third-party serving domains.
Package Registries
All SDKs are published to their language's standard package registry and versioned with semantic versioning.
| Package | Registry | Install |
|---|---|---|
| anml-client (Python) | PyPI | pip install anml-client |
| anml-server (Python) | PyPI | pip install anml-server |
| @anml-foundation/client | npm | npm install @anml-foundation/client |
| @anml-foundation/server | npm | npm install @anml-foundation/server |
| anml-client (Rust) | crates.io | cargo add anml-client |
| anml-server (Rust) | crates.io | cargo add anml-server |
Resources
RFC Specification
The full ANML 1.0 Internet-Draft
Documentation
Complete protocol documentation
Implementations
All official SDKs with capability matrix
GitHub
Source code for all ANML Foundation projects
Integrations
How ANML works with MCP, A2A, UCP, and OpenAPI
Why ANML?
Protocol comparison and positioning
Need help getting started?
We're building the foundation for the agentic web and want to help early adopters succeed. Reach out for integration support, architecture guidance, or to discuss your use case.