Skip to main content
Glama

rivian_get_charging_session

Monitor active charging sessions to track power usage, battery level, time remaining, and cost for your Rivian vehicle.

Instructions

Check on an active charging session — power, battery level, time remaining, and cost.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vehicle_idYesVehicle ID from your account info

Implementation Reference

  • The core implementation of getLiveChargingSession that executes a GraphQL query to the Rivian charging API, retrieving live charging session data including power, battery level, time remaining, cost, and other charging metrics.
    export async function getLiveChargingSession(vehicleId) { const body = { operationName: 'getLiveSessionData', query: `query getLiveSessionData($vehicleId: ID!) { getLiveSessionData(vehicleId: $vehicleId) { __typename chargerId current { __typename value updatedAt } currentCurrency currentMiles { __typename value updatedAt } currentPrice isFreeSession isRivianCharger kilometersChargedPerHour { __typename value updatedAt } locationId power { __typename value updatedAt } rangeAddedThisSession { __typename value updatedAt } soc { __typename value updatedAt } startTime timeElapsed timeRemaining { __typename value updatedAt } totalChargedEnergy { __typename value updatedAt } vehicleChargerState { __typename value updatedAt } } }`, variables: { vehicleId }, }; return (await gql(GRAPHQL_CHARGING, body, chargingHeaders())).getLiveSessionData; }
  • mcp-server.js:505-519 (registration)
    The MCP server tool registration for 'rivian_get_charging_session', defining the tool schema (accepts vehicle_id parameter) and the handler function that authenticates, calls getLiveChargingSession, and formats the response.
    server.tool( 'rivian_get_charging_session', 'Check on an active charging session — power, battery level, time remaining, and cost.', { vehicle_id: z.string().describe('Vehicle ID from your account info'), }, async ({ vehicle_id }) => { try { requireAuth(); return text(formatChargingSession(await rivian.getLiveChargingSession(vehicle_id))); } catch (err) { return text(err.message); } }, );
  • The formatChargingSession helper function that formats the raw charging session data from the API into a human-readable text format with battery level, power, range added, energy charged, time, cost, and charger state.
    function formatChargingSession(data) { if (!data) return 'No active charging session.'; const lines = ['Charging Session']; const add = (label, entry, suffix = '') => { const value = entry?.value; if (value !== undefined && value !== null) lines.push(` ${label}: ${value}${suffix}`); }; add('Battery', data.soc, '%'); add('Power', data.power, ' kW'); add('Range added', data.rangeAddedThisSession, ' miles'); add('Energy charged', data.totalChargedEnergy, ' kWh'); add('Current', data.current, ' A'); if (data.timeElapsed) lines.push(` Time elapsed: ${data.timeElapsed}`); add('Time remaining', data.timeRemaining, ' min'); if (data.isRivianCharger) lines.push(' Network: Rivian Adventure Network'); if (data.isFreeSession) { lines.push(' Cost: Free'); } else if (data.currentPrice) { lines.push(` Cost so far: ${data.currentCurrency || '$'}${data.currentPrice}`); } add('Charger state', data.vehicleChargerState); return lines.join('\n'); }
  • The chargingHeaders helper function that provides the authentication headers required for API calls to the Rivian charging GraphQL endpoint.
    function chargingHeaders() { return { 'U-Sess': userSessionToken }; }

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