Skip to content
Skip to main content

Give your agent contacts access

Your agent needs contacts access to look up people by name or email, enrich context before sending messages, and manage address books on behalf of users. The Nylas CLI gives your agent access to contacts across Gmail, Outlook, Exchange, and iCloud through shell commands that return structured JSON.

Make sure the CLI is installed and authenticated. If not, follow the AI agents quickstart first.

nylas auth whoami --json

Find contacts by name or email. This is the most common operation — look someone up before sending an email or scheduling a meeting.

nylas contacts search --query "Alice" --json
nylas contacts search --query "[email protected]" --json

List all contacts for the connected user.

nylas contacts list --limit 10 --json

Get the full details for a specific contact — emails, phone numbers, company, job title.

nylas contacts show <CONTACT_ID> --json

Add a new contact to the user’s address book.

nylas contacts create --name "Bob Smith" --email "[email protected]"

See how contacts are organized (labels in Gmail, folders in Outlook).

nylas contacts groups list --json

Example: enrich context before sending email

Section titled “Example: enrich context before sending email”

A common agent pattern — look up the recipient before composing a message:

# 1. Search for the contact
nylas contacts search --query "[email protected]" --json
# 2. (Agent uses contact details like company, title, and
# recent interactions to personalize the email)
# 3. Send a personalized email
nylas email send \
--subject "Following up on our conversation" \
--body "Hi Alice, great talking with you at the conference..." \
--yes

If your agent supports Model Context Protocol (Claude Code, Cursor, Windsurf, VS Code, Codex CLI), register the CLI as an MCP server for typed contact tools:

nylas mcp install --assistant claude-code

See the Nylas MCP server docs for details.