Skip to main content
Glama

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
NameRequiredDescriptionDefault
vehicle_idYesVehicle 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);
        }
      },
    );
  • 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);
      }
    },
  • Zod schema defining the vehicle_id input parameter for the tool.
    vehicle_id: z.string().describe('Vehicle ID from your account info'),
  • 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;
    }
  • 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();
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PatrickHeneise/rivian-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server