rivian_get_charging_session
Get details on an active charging session, including power, battery level, time remaining, and cost.
Instructions
Check on an active charging session — power, battery level, time remaining, and cost.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp-server.js:177-190 (registration)Registration of the 'rivian_get_charging_session' tool using server.tool() with an empty schema. Calls requireAuth, resolveVehicleId, rivian.getLiveChargingSession, and format.formatChargingSession.
server.tool( 'rivian_get_charging_session', 'Check on an active charging session — power, battery level, time remaining, and cost.', {}, async () => { try { requireAuth() const vehicleId = await resolveVehicleId() return text(format.formatChargingSession(await rivian.getLiveChargingSession(vehicleId))) } catch (err) { return text(err.message) } }, ) - mcp-server.js:181-190 (handler)Async handler that authenticates, resolves the vehicle ID, fetches the live charging session from the Rivian API, and formats the result for display.
async () => { try { requireAuth() const vehicleId = await resolveVehicleId() return text(format.formatChargingSession(await rivian.getLiveChargingSession(vehicleId))) } catch (err) { return text(err.message) } }, ) - lib/rivian-api.js:201-230 (helper)getLiveChargingSession function that executes a GraphQL query 'getLiveSessionData' against the charging endpoint, returning charging session data (power, SOC, range, energy, cost, etc.).
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 } - lib/format.js:506-537 (helper)formatChargingSession function that formats the charging session data into a human-readable display with power, SOC bar, range, energy, current, time elapsed, time remaining, network, cost, and charger state.
export function formatChargingSession(data) { if (!data) return c.dim('No active charging session.') const lines = [section('Charging Session'), ''] const add = (label, entry, suffix = '') => { const value = entry?.value if (value !== undefined && value !== null) lines.push(kv(label, value, suffix)) } const soc = data.soc?.value if (soc !== undefined && soc !== null) { lines.push(` ${bar(soc)} ${c.bold(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(kv('Time elapsed', data.timeElapsed)) add('Time remaining', data.timeRemaining, ' min') if (data.isRivianCharger) lines.push(kv('Network', c.green('Rivian Adventure Network'))) if (data.isFreeSession) { lines.push(kv('Cost', c.green('Free'))) } else if (data.currentPrice) { lines.push(kv('Cost so far', `${data.currentCurrency || '$'}${data.currentPrice}`)) } add('Charger state', data.vehicleChargerState) return lines.filter((l) => l !== null).join('\n') } - mcp-server.js:180-180 (schema)Empty schema object ({}) for the tool - no input parameters are required.
{},