gmail
gmail
¶
Gmail connector — bulk email sync via the Gmail REST API.
Uses OAuth 2.0 tokens stored locally (see :mod:openjarvis.connectors.oauth).
All network calls are isolated in module-level functions (_gmail_api_*)
to make them trivially mockable in tests.
Classes¶
GmailConnector
¶
Bases: BaseConnector
Connector that syncs emails from Gmail via the REST API.
Authentication is handled through Google OAuth 2.0. Tokens are stored locally in a JSON credentials file.
| PARAMETER | DESCRIPTION |
|---|---|
credentials_path
|
Path to the JSON file where OAuth tokens are stored. Defaults to
TYPE:
|
Source code in src/openjarvis/connectors/gmail.py
Functions¶
is_connected
¶
Return True if a credentials file with a valid token exists.
Source code in src/openjarvis/connectors/gmail.py
disconnect
¶
auth_url
¶
Return a Google OAuth consent URL requesting gmail.readonly scope.
handle_callback
¶
Handle the OAuth callback by persisting the authorization code.
In a full implementation this would exchange the code for tokens. For now the code is saved directly as the token value.
Source code in src/openjarvis/connectors/gmail.py
sync
¶
sync(*, since: Optional[datetime] = None, cursor: Optional[str] = None) -> Iterator[Document]
Yield :class:Document objects for Gmail messages.
Paginates through the messages.list API and fetches each message's full payload to extract headers and body.
| PARAMETER | DESCRIPTION |
|---|---|
since
|
When provided, only messages received after this timestamp are
returned. Translated to a Gmail
TYPE:
|
cursor
|
TYPE:
|
Source code in src/openjarvis/connectors/gmail.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
sync_status
¶
sync_status() -> SyncStatus
Return sync progress from the most recent :meth:sync call.
Source code in src/openjarvis/connectors/gmail.py
mcp_tools
¶
mcp_tools() -> List[ToolSpec]
Expose three MCP tool specs for real-time Gmail queries.