Skip to main content

mcp_gmailcal/
lib.rs

1pub mod auth;
2pub mod config;
3pub mod token_cache;
4// ===== Module Declarations =====
5
6/**
7 * Gmail MCP Server Implementation
8 *
9 * This crate provides an MCP (Model Completion Protocol) server for Gmail,
10 * allowing Claude to read emails from a Gmail account, search for contacts,
11 * and manage calendar events.
12 *
13 * # Features
14 *
15 * - List emails from inbox
16 * - Search emails using Gmail search queries
17 * - Get details for a specific email
18 * - List email labels
19 * - Search for contacts
20 * - List calendar events
21 * - Create calendar events
22 * - Check connection status
23 *
24 * # Testing
25 *
26 * The crate includes unit tests for internal functions and integration tests
27 * for testing the MCP commands. Future improvements could include more
28 * sophisticated mocking of the API endpoints and more comprehensive tests.
29 */
30// Core functionality
31pub mod errors;
32pub mod logging;
33pub mod utils;
34
35// API clients
36pub mod calendar_api;
37pub mod gmail_api;
38pub mod people_api;
39
40// Server implementation
41pub mod cli;
42pub mod oauth;
43pub mod prompts;
44pub mod server;
45
46// ===== Re-exports =====
47
48// Error handling and results
49pub use crate::errors::{
50    error_codes, CalendarApiError, CalendarResult, ConfigError, GmailApiError, GmailResult,
51    PeopleApiError, PeopleResult,
52};
53
54// Configuration and constants
55pub use crate::config::{get_token_expiry_seconds, Config, GMAIL_API_BASE_URL, OAUTH_TOKEN_URL};
56
57// Logging setup
58pub use crate::logging::setup_logging;
59
60// Authentication
61pub use crate::auth::TokenManager;
62pub use crate::token_cache::{TokenCache, TokenCacheConfig, CachedToken};
63
64// Gmail API types
65pub use crate::gmail_api::{DraftEmail, EmailMessage, GmailService};
66
67// People API types
68pub use crate::people_api::{
69    Contact, ContactList, EmailAddress, Organization, PeopleClient, PersonName, PhoneNumber, Photo,
70};
71
72// Calendar API types
73pub use crate::calendar_api::{
74    Attendee, CalendarClient, CalendarEvent, CalendarInfo, CalendarList, ConferenceData,
75    ConferenceSolution, EntryPoint, EventOrganizer,
76};
77
78// Utils and prompts
79pub use crate::prompts::*;
80pub use crate::utils::{
81    decode_base64, encode_base64_url_safe, error_codes as utils_error_codes, map_gmail_error,
82    parse_max_results, to_mcp_error,
83};
84
85// Server implementation
86pub use crate::server::GmailServer;