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 access token exists.
The previous "any non-empty dict counts" check returned True for
files containing only client_id/client_secret (no actual OAuth
token), which made jarvis connect gmail short-circuit with
"already connected" before any OAuth flow ran.
Source code in src/openjarvis/connectors/gmail.py
disconnect
¶
auth_url
¶
Return a Google OAuth consent URL for the shared Google scopes.
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, query_extra: str = '') -> 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:
|
query_extra
|
Additional Gmail search operators appended to the base query,
e.g.
TYPE:
|
Source code in src/openjarvis/connectors/gmail.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
delete_message
¶
archive_message
¶
Archive a message by removing the INBOX label.
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.