rivian_get_drivers_and_keys
Retrieve vehicle access details including drivers, phone keys, and key fobs to monitor who can operate your Rivian.
Instructions
See who has access to your vehicle — drivers, phone keys, and key fobs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vehicle_id | Yes | Vehicle ID from your account info |
Implementation Reference
- mcp-server.js:521-535 (registration)Tool registration with MCP server, including the schema definition (vehicle_id parameter) and handler that calls rivian.getDriversAndKeys() and formats the output.server.tool( 'rivian_get_drivers_and_keys', 'See who has access to your vehicle — drivers, phone keys, and key fobs.', { vehicle_id: z.string().describe('Vehicle ID from your account info'), }, async ({ vehicle_id }) => { try { requireAuth(); return text(formatDriversAndKeys(await rivian.getDriversAndKeys(vehicle_id))); } catch (err) { return text(err.message); } }, );
- mcp-server.js:527-534 (handler)The async handler function that executes when the tool is called - requires authentication, calls the API, and returns formatted text.async ({ vehicle_id }) => { try { requireAuth(); return text(formatDriversAndKeys(await rivian.getDriversAndKeys(vehicle_id))); } catch (err) { return text(err.message); } },
- mcp-server.js:525-525 (schema)Zod schema defining the vehicle_id input parameter for the tool.vehicle_id: z.string().describe('Vehicle ID from your account info'),
- lib/rivian.js:224-248 (handler)Core implementation that executes the GraphQL query to Rivian's API to fetch drivers, phone keys, and key fobs for a given vehicle.export async function getDriversAndKeys(vehicleId) { const body = { operationName: 'DriversAndKeys', query: `query DriversAndKeys($vehicleId: String) { getVehicle(id: $vehicleId) { __typename id vin invitedUsers { __typename ... on ProvisionedUser { firstName lastName email roles userId devices { type mappedIdentityId id hrid deviceName isPaired isEnabled } } ... on UnprovisionedUser { email inviteId status } } } }`, variables: { vehicleId }, }; return (await gql(GRAPHQL_GATEWAY, body, authHeaders())).getVehicle; }
- mcp-server.js:347-380 (helper)Helper function that formats the API response into readable text, displaying user roles, devices, and their pairing/enabled status.function formatDriversAndKeys(data) { const lines = []; if (data.vin) lines.push(`Vehicle: ${data.vin}`); if (!data.invitedUsers?.length) { lines.push('No drivers or keys found.'); return lines.join('\n'); } lines.push(''); for (const user of data.invitedUsers) { if (user.firstName) { lines.push(`${user.firstName} ${user.lastName} (${user.email})`); if (user.roles?.length) lines.push(` Roles: ${user.roles.join(', ')}`); if (user.devices?.length) { for (const d of user.devices) { const name = d.deviceName || d.type; const status = [ d.isPaired ? 'paired' : 'not paired', d.isEnabled ? 'enabled' : 'disabled', ].join(', '); lines.push(` ${name} — ${status}`); } } } else { lines.push(`${user.email} (invited, ${user.status})`); } lines.push(''); } return lines.join('\n').trim(); }