llms.txt
Trails provides anllms.txt file for AI-friendly documentation discovery. This file follows the llms.txt standard and provides structured context about Trails capabilities.
URL: https://docs.trails.build/llms.txt
Use this file to give your LLM context about Trails before making integration requests. It includes:
- Core concepts (intents, routes, SDK modes)
- API flow overview
- Common integration patterns
- Links to relevant documentation
MCP Server
The Trails MCP Server allows you to leverage AI agents like Claude or Cursor seamlessly with Trails. The server is available at:https://docs.trails.build/mcp
Connect in Cursor
- Use Command + Shift + P (Ctrl + Shift + P on Windows) to open the command palette.
- Search for “Open MCP settings”.
- Select Add custom MCP to open the
mcp.jsonfile. - In
mcp.json, add the Trails server:
- In Cursor chat, ask “What tools do you have available?” to confirm the Trails MCP server is listed.
Connect in Claude
- Navigate to the [Developers] page in Claude Desktop.
- Select Edit config if you have an existing MCP configuration or add a new one.
- Open your config file and add the Trails MCP server:
- Name:
Trails - URL:
https://docs.trails.build/mcp
- Name:
- Save the configuration
- In a Claude chat, select the
Search and toolsand make sure your configuration file with Trails is enabled. - Ask a question about Trails!
Example Queries
You can ask questions like:- “How would I add a DeFi vault for USDC on Aave to my react app using Trails?”
- “What theming options are available for Trails?”
- “What chains does trails support?”
Function Calling Tools
For custom LLM integrations (OpenAI, Anthropic, etc.), use these tool definitions to enable payment capabilities.Payment Tool Definition
Quote Tool Definition
Swap Tool Definition
Example Prompts
These prompts help LLMs understand common payment scenarios.System Prompt for Payment Agent
User Intent Examples
| User says | Interpreted action |
|---|---|
| ”Pay 0xABC 50 USDC” | create_payment(recipient="0xABC", amount="50", token="USDC") |
| ”Send 100 dollars to merchant.eth” | Resolve ENS, then create_payment(amount="100", token="USDC") |
| ”Swap my ETH on mainnet to USDC on Base” | swap_tokens(from="ETH", from_chain=1, to="USDC", to_chain=8453) |
| ”How much will it cost to send 1000 USDC?” | get_payment_quote(to_token="USDC", amount="1000") |
| ”Pay invoice #123 for 250 USDT” | create_payment(amount="250", token="USDT", memo="Invoice #123") |
API Integration Example
Complete example implementing the payment tool with Trails API:Error Handling
Handle these common errors in your LLM integration:Error Response Format
When returning errors to the LLM, use a structured format:Best Practices
Always confirm before executing
Always confirm before executing
Show the user the full quote including fees before calling
executeIntent. Never auto-execute payments.Handle quote expiration
Handle quote expiration
Quotes expire in 5 minutes. If the user takes too long to confirm, get a fresh quote.
Validate addresses
Validate addresses
Always validate Ethereum addresses and resolve ENS names before making API calls.
Cache token lists
Cache token lists
Use
GetTokenList to cache supported tokens rather than hardcoding. Token availability changes.Provide context in errors
Provide context in errors
When errors occur, give the LLM enough context to explain to the user and suggest alternatives.