loading…
Search for a command to run...
loading…
A Python MCP server that provides a lightweight CRM by integrating Google Sheets, Gmail, and Google Docs for contact management, email communication, and docume
A Python MCP server that provides a lightweight CRM by integrating Google Sheets, Gmail, and Google Docs for contact management, email communication, and document creation. It features 30 specialized tools, OAuth2 endpoint protection, and a comprehensive audit logging system.
A Python MCP (Model Context Protocol) server that acts as a lightweight CRM by integrating Google Sheets (contact management & generic spreadsheet ops), Gmail (email communication), and Google Docs (document creation). Designed for hosting on Replit with Streamable HTTP transport, compatible with both Claude and ChatGPT as MCP clients.
/mcp endpoint with Client Credentials or Authorization Code + PKCE flow — compatible with Claude's Advanced Settings| Tool | Description | R/W |
|---|---|---|
crm_list_contacts |
List all contacts with optional field filtering | Read |
crm_get_contact |
Get a single contact by email or row number | Read |
crm_add_contact |
Add a new contact to the CRM | Write |
crm_update_contact |
Update an existing contact's fields | Write |
crm_delete_contact |
Soft-delete a contact (moves to "Deleted" sheet) | Destructive |
crm_search_contacts |
Full-text search across all contact fields | Read |
crm_add_note |
Append a timestamped note to a contact | Write |
crm_get_contact_with_emails |
Get contact profile + recent email history | Read |
| Tool | Description | R/W |
|---|---|---|
sheets_read_range |
Read data from a specific A1 range | Read |
sheets_write_range |
Write a 2D array to a specific A1 range | Write |
sheets_append_rows |
Append rows to the end of a sheet tab | Write |
sheets_read_all |
Read all data from an entire sheet tab | Read |
sheets_list_tabs |
List all worksheet tabs with dimensions | Read |
sheets_create_tab |
Create a new worksheet tab with optional headers | Write |
sheets_delete_tab |
Delete a worksheet tab (permanent, requires confirm) | Destructive |
| Tool | Description | R/W |
|---|---|---|
sheets_create_spreadsheet |
Create a brand new Google Sheets file | Write |
docs_create_document |
Create a new Google Doc with optional initial text | Write |
docs_append_text |
Append text to an existing Google Doc | Write |
docs_read_document |
Read the full text of a Google Doc | Read |
| Tool | Description | R/W |
|---|---|---|
gmail_send_email |
Send an email (plain text or HTML) | Write |
gmail_search_emails |
Search emails using Gmail query syntax | Read |
gmail_get_email |
Get full email content by message ID | Read |
gmail_send_reply |
Reply to an existing email thread | Write |
gmail_draft_email |
Create a draft email without sending | Write |
crm_log_email_to_contact |
Log an email interaction on a contact's record | Write |
crm_get_contact_with_emails |
Get contact profile + recent email history | Read |
| Tool | Description | R/W |
|---|---|---|
cache_put |
Store a value in the agent cache with optional TTL and namespace | Write |
cache_get |
Retrieve a value from the cache | Read |
cache_list |
List cache keys, optionally filtered by namespace | Read |
cache_delete |
Delete a cache entry | Write |
cache_stats |
View cache statistics (entries, hits, misses, hit rate) | Read |
| Tool | Description | R/W |
|---|---|---|
system_health_check |
Test connectivity to all Google services | Read |
audit_get_logs |
Query the audit log (filter by tool, stage, errors) | Read |
audit_trace_request |
Get the full lifecycle trace of a request by ID | Read |
audit_confirm_delivery |
Confirm the chat agent received a tool result | Write |
The /mcp endpoint can be protected with OAuth2 authentication, preventing unauthorized access.
When MCP_CLIENT_ID and MCP_CLIENT_SECRET are configured as secrets:
/.well-known/oauth-authorization-server for metadata/authorize with PKCE challenge/token for a Bearer token/mcp requests require Authorization: Bearer <token>Without these secrets, the endpoint remains open (backward-compatible).
The Settings UI provides one-click test buttons for all major services:
| Test | Endpoint | Steps | Description |
|---|---|---|---|
| Service Account | /api/service-account/test |
3 | Verifies Google API connectivity and file access |
| MCP Tools | /api/mcp-tools/test |
8 | Creates test tab, writes/reads data, cleans up |
| Gmail Send & Reply | /api/gmail-test/full |
7 | Sends email, verifies delivery, sends reply, checks thread |
| Cache Pipeline | /api/cache/test |
7 | Reads contacts, caches, creates jokes, drafts & sends email |
| CRM Contacts | /api/crm-contacts/test |
10 | Tests all 8 CRM tools, writes results to dated tab |
| OAuth2 Auth | Settings UI button | 3 | Verifies unauthenticated access is blocked |
Every tool call is tracked through a 5-stage lifecycle:
1. REQUEST_RECEIVED → Incoming tool invocation from the chat agent
2. API_CALL → Each Google API / SMTP call made by the server
3. GOOGLE_VALIDATED → Confirmation the action landed on the Google side
4. RESULT_DELIVERED → Response payload returned to the chat agent
5. DELIVERY_CONFIRMED → (Optional) Chat agent confirmed receipt
Every tool response includes an _audit field with the request_id:
{
"contact": { ... },
"message": "Contact added at row 5.",
"_audit": { "request_id": "a1b2c3d4e5f6..." }
}
The in-memory agent cache enables fast batch processing workflows:
contacts, emails)Create a Google Sheet and format the first row as headers:
| Column | Header | Example |
|---|---|---|
| A | first_name | Ali |
| B | last_name | Smith |
| C | [email protected] | |
| D | phone | +1-555-0123 |
| E | company | OPTT Health |
| F | role | CEO |
| G | status | lead |
| H | notes | [2025-02-19] Initial outreach... |
| I | created_at | 2025-02-19T10:00:00Z |
| J | updated_at | 2025-02-19T10:00:00Z |
Valid status values: lead, prospect, customer, churned
Important: Share the Google Sheet with your service account email (shown in the Settings UI after uploading the service account JSON). Give it Editor access.
The easiest way to configure everything is through the Settings UI at the root path (/):
Path C — OAuth2 (Recommended):
Path A — Google Workspace Domain-Wide Delegation:
If your Gmail is on a Workspace domain (e.g., [email protected]):
[email protected]Path B — SMTP Fallback:
If you use a personal @gmail.com account:
USE_SMTP_FALLBACK=true, [email protected], GMAIL_APP_PASSWORD=xxxx xxxx xxxx xxxxTo protect the /mcp endpoint with OAuth2:
MCP_CLIENT_ID and MCP_CLIENT_SECRETAdd these as Replit Secrets (Tools → Secrets):
| Secret | Required | Description |
|---|---|---|
MCP_CLIENT_ID |
Recommended | OAuth2 Client ID for MCP endpoint protection |
MCP_CLIENT_SECRET |
Recommended | OAuth2 Client Secret for MCP endpoint protection |
MCP_SERVER_PORT |
No | Default: 5000 |
All other credentials (service account, OAuth tokens, spreadsheet selection) are managed through the Settings UI and stored in PostgreSQL.
https://your-app.replit.app/mcpMCP_CLIENT_ID and MCP_CLIENT_SECRETAdd to your claude_desktop_config.json:
{
"mcpServers": {
"google-workspace-crm": {
"url": "https://your-app.replit.app/mcp"
}
}
}
claude mcp add google-workspace-crm --transport http https://your-app.replit.app/mcp
ChatGPT supports MCP servers via its plugin/actions system:
Endpoint: https://your-app.replit.app/mcp
Transport: Streamable HTTP
OAuth2 Metadata: https://your-app.replit.app/.well-known/oauth-authorization-server
Token Endpoint: https://your-app.replit.app/token
├── main.py # MCP server entry point (30 tools, OAuth2 auth, startup checks)
├── config.py # Environment config loader
├── requirements.txt # Python dependencies
├── tools/
│ ├── sheets.py # CRM tools (8) + generic sheet tools (7)
│ ├── gmail.py # Gmail tools (5) + workflow tools (2)
│ ├── workspace.py # Spreadsheet/Doc creation (4) + audit tools (3)
│ └── cache.py # Agent cache tools (5)
├── services/
│ ├── google_auth.py # Service account credential loading
│ ├── sheets_client.py # gspread client with caching & rate limiting
│ ├── gmail_client.py # Gmail API / SMTP client wrapper
│ ├── docs_client.py # Google Docs + Drive API client
│ ├── cache.py # Thread-safe agent cache (TTL, LRU, namespaces)
│ ├── mcp_auth.py # OAuth2 auth for MCP endpoint (PKCE, tokens)
│ ├── audit_logger.py # 5-stage audit log with ring buffer
│ └── health_check.py # Connectivity testing for all Google services
├── web/
│ ├── routes.py # Settings UI routes & test endpoints
│ ├── settings_store.py # PostgreSQL-backed settings storage
│ ├── oauth.py # Gmail OAuth2 flow handler
│ ├── sheets_browser.py # Google Sheets browser for selection UI
│ └── templates/
│ └── settings.html # Settings dashboard UI
└── models/
└── contact.py # Pydantic models
MIT
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"google-workspace-crm-mcp-server": {
"command": "npx",
"args": []
}
}
}