Leaf’s MCP server works with Claude Code, giving you Leaf API access from the command line through natural language. You can list users, browse fields, pull operations data, and read API documentation without writing HTTP requests.
Before you start
curl -X POST "https://api.withleaf.io/api/authenticate" \
-H "Content-Type: application/json" \
-d '{"username": "your-email@example.com", "password": "your-password"}'
Save the id_token.
Add the Leaf MCP server to your Claude Code configuration. Create or edit ~/.claude/claude_code_config.json:
{
"mcpServers": {
"leaf-mcp": {
"type": "url",
"url": "https://mcp.withleaf.io/mcp",
"headers": {
"LEAF_TOKEN": "your-leaf-api-token"
}
}
}
}
For project-level configuration, add the same block to .mcp.json in your project root instead.
Your Leaf token expires periodically. If you get authentication errors, generate a fresh token and update the config.
Step 2: Verify the connection
Launch Claude Code and ask:
List available Leaf API documentation
Claude Code calls get_docs_index and returns the documentation index. If you see the list, the MCP server is connected.
Step 3: Query your data
The same tools available in Cursor work here. A few examples:
List Leaf users:
Query fields:
List fields for Leaf user <leaf_user_id>
Pull harvest operations:
Show harvested operations for Leaf user <leaf_user_id>
Get an operation summary:
Get the summary for operation <operation_id>
Check weather:
What's the daily weather forecast for field <field_id> under Leaf user <leaf_user_id>?
Step 4: Use documentation tools for context
Claude Code can pull Leaf API documentation inline to answer questions about endpoints, schemas, and behavior:
Show me the Leaf documentation for field operations endpoints
This calls get_leaf_doc with the path API_Reference/Field_Operations/operations_endpoints and returns the full endpoint documentation, which Claude Code can then reference when helping you write integration code.
| Category | Tools |
|---|
| Users | list_users |
| Fields | list_fields, get_field, get_field_boundary |
| Operations | list_operations, get_operation, get_operation_summary, get_operation_units |
| Machine files | list_files, get_file, get_file_summary, get_file_status, get_file_units |
| Batches | list_batches, get_batch, get_batch_status |
| Weather | Forecast and historical, daily and hourly, by field or lat/lon |
| Billing | list_billing_contracts, get_contract_consumption |
| Configuration | get_api_owner_configuration, get_leaf_user_configuration |
| Credentials | Provider credential event tools for John Deere, Climate FieldView, CNHi |
| Documentation | get_docs_index, get_leaf_doc |
What you built
You connected Leaf’s MCP server to Claude Code and queried Leaf data from the terminal. This setup is useful for exploring customer data, debugging integrations, and getting contextual API documentation while writing code.
For the same workflow in Cursor IDE, see Connect Leaf’s MCP Server in Cursor.