Package-level declarations

Types

Link copied to clipboard

Serves one contact per droidmcp://contacts/{id} URI as JSON — the same shape read_contact returns. Nothing is listed up front (an address book is too large and too personal to advertise); clients find ids with search_contacts and read them by template. Needs READ_CONTACTS; without it every read fails as not found. Hidden while read_contact is gated off.

Link copied to clipboard

Provider for the contacts tool module. Wires up SearchContactsTool, ReadContactTool, ListContactsTool, CreateContactTool, UpdateContactTool and DeleteContactTool, which query and edit via ContactsContract.

Link copied to clipboard

Creates a contact with one ContactsContract batch: a RawContacts row in the local device account (null account name/type), a StructuredName row from name, and optional Phone and Email rows. Requires WRITE_CONTACTS (plus READ_CONTACTS to look up the aggregated id).

Link copied to clipboard

Deletes a contact (the aggregated contact_id) and every raw contact merged into it. Requires WRITE_CONTACTS and READ_CONTACTS. Errors when the contact doesn't exist, so a repeated call reports not-found. On synced accounts the provider marks the raw contacts deleted and the sync adapter removes them on its next sync. Output: contact_id, deleted (true), and the deleted contact's name.

Link copied to clipboard
class ListContactsTool(context: Context) : McpTool

Lists all contacts (name + phone presence only) via ContentResolver on ContactsContract.Contacts, sorted by display name, with cursor-based pagination. Requires READ_CONTACTS. Output: contacts (list of {id, name, has_phone}), plus count, offset, and limit. limit clamps to 1–100 (default 50); offset is non-negative (default 0).

Link copied to clipboard
class ReadContactTool(context: Context) : McpTool

Reads full details for one contact identified by contact_id (accepts a number or numeric string) via ContactsContract, aggregating name, phones, emails, and postal addresses. Requires READ_CONTACTS; returns an error if the id is missing/non-numeric or no contact matches. Output: id, name, phones (list of {number, type}), emails (list of {address, type}), and addresses (list of formatted-address strings). Phone/email type is mapped to home/mobile/work/other.

Link copied to clipboard

Searches contacts whose DISPLAY_NAME_PRIMARY matches query (SQL LIKE substring; %, _ and \ in query match literally), then attaches every match's phone numbers and email addresses with a single ContactsContract.Data query (CONTACT_ID IN (...)). Requires READ_CONTACTS. Output: contacts (list of {id, name, phones (list of strings), emails (list of strings)}), count, and the echoed query, capped at limit (1–100, default 10).

Link copied to clipboard

Edits an existing contact (the aggregated contact_id from search_contacts / read_contact) in one ContactsContract batch: renames it, and adds or removes a phone number or email. Requires WRITE_CONTACTS and READ_CONTACTS.