Gmail MCP Email
List, search and read Gmail, draft replies and (optionally) send email through your Google account connected on gsuite.oshaani.com.
Quick start
- Prepare access in Gmail by following the setup guide.
- Add a Gmail connection with the settings below, then click Test configuration.
- Create an API key for your agent.
- Paste the key below, click Test endpoint, and copy the configuration for your platform.
| Endpoint | https://market.oshaani.com/gmail (your default connection) or https://market.oshaani.com/gmail/<connection-id> |
|---|---|
| Transport | Streamable HTTP (stateless, JSON responses). MCP protocol versions 2024-11-05 to 2025-11-25 and 2026-07-28. |
| Authentication | Authorization: Bearer <API key>, using a key from the API keys page. |
Setup guide: connect your Gmail account
Gmail on the marketplace uses your Google account through
Smart Inbox
(gsuite.oshaani.com). You connect Google once there, create an API key, and paste that key into
this connection. The marketplace never stores Google passwords or OAuth tokens.
| Smart Inbox | https://gsuite.oshaani.com/app |
|---|---|
| API key prefix | ge_ |
1. Sign in and connect Google
- Open https://gsuite.oshaani.com/app.
- Sign in with your Oshaani account.
- Click Connect Google and grant Gmail access for the mailbox agents should use.
2. Create a Smart Inbox API key
- On the Smart Inbox dashboard, generate an API key (or call
POST /api-keywhile signed in). - Copy the key. It starts with
ge_and is shown only once.
3. Create the marketplace connection
- Paste the key into Smart Inbox API key below. Leave the Smart Inbox URL as
https://gsuite.oshaani.comunless you self-host it. - Leave drafting and sending off until you have tested with Test configuration.
- When agents should draft or send, enable the matching toggles. Optionally restrict recipients to certain domains.
Agents talk to Gmail only through Smart Inbox. Revoking the API key or disconnecting Google on gsuite.oshaani.com immediately stops this connection.
Agent configuration
initialize and tools/list against the endpoint, exactly like an agent. No credits are charged.
Any MCP client that supports remote (Streamable HTTP) servers with custom headers.
{
"name": "gmail",
"transport": "streamable-http",
"url": "https://market.oshaani.com/gmail",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
~/.cursor/mcp.json (all projects) or .cursor/mcp.json in a project.
{
"mcpServers": {
"gmail": {
"url": "https://market.oshaani.com/gmail",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
Settings > Developer > Edit Config (claude_desktop_config.json). Uses the mcp-remote bridge; needs Node.js.
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://market.oshaani.com/gmail",
"--header",
"Authorization:${AUTH_HEADER}"
],
"env": {
"AUTH_HEADER": "Bearer YOUR_API_KEY"
}
}
}
}
Run in your terminal, or put the JSON in .mcp.json at the project root.
claude mcp add --transport http gmail https://market.oshaani.com/gmail \
--header "Authorization: Bearer YOUR_API_KEY"
# .mcp.json
{
"mcpServers": {
"gmail": {
"type": "http",
"url": "https://market.oshaani.com/gmail",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
.vscode/mcp.json (GitHub Copilot agent mode). VS Code prompts for the key once and stores it securely.
{
"inputs": [
{
"type": "promptString",
"id": "oshaani-mcp-key",
"description": "oshaani MCP Marketplace API key",
"password": true
}
],
"servers": {
"gmail": {
"type": "http",
"url": "https://market.oshaani.com/gmail",
"headers": {
"Authorization": "Bearer ${input:oshaani-mcp-key}"
}
}
}
}
~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"gmail": {
"serverUrl": "https://market.oshaani.com/gmail",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
Responses API remote MCP tool (Python SDK).
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-4.1",
tools=[{
"type": "mcp",
"server_label": "gmail",
"server_url": "https://market.oshaani.com/gmail",
"headers": {"Authorization": "Bearer YOUR_API_KEY"},
"require_approval": "never", # or "always" to approve each tool call
}],
input="What can you do with these tools?",
)
print(response.output_text)
Messages API MCP connector (Python SDK).
import anthropic
client = anthropic.Anthropic()
response = client.beta.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "What can you do with these tools?"}],
mcp_servers=[{
"type": "url",
"url": "https://market.oshaani.com/gmail",
"name": "gmail",
"authorization_token": "YOUR_API_KEY",
}],
betas=["mcp-client-2025-04-04"],
)
print(response.content)
Official MCP Python SDK 2.x (pip install mcp); works inside any agent framework.
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import create_mcp_http_client, streamable_http_client
async def main():
headers = {"Authorization": "Bearer YOUR_API_KEY"}
async with create_mcp_http_client(headers=headers) as http:
async with streamable_http_client("https://market.oshaani.com/gmail", http_client=http) as (read, write, *_):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
print([tool.name for tool in tools.tools])
asyncio.run(main())
Quick check from a terminal: lists the tools without charging credits.
curl -s https://market.oshaani.com/gmail \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "MCP-Protocol-Version: 2025-06-18" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
Connection settings
Entered once per connection on market.oshaani.com. Secrets are encrypted and never shown again or sent to agents.
| Setting | Type | Description |
|---|---|---|
Smart Inbox API keyapi_key
required secret |
string | Starts with ge_. Create one at https://gsuite.oshaani.com/app after connecting Google. |
Smart Inbox URLbase_url
|
string (uri) default "https://gsuite.oshaani.com" |
Leave as https://gsuite.oshaani.com unless you self-host Smart Inbox. min length 1, max length 2083 |
Allow drafting and marking emails as readallow_write_actions
|
boolean default false |
Off by default: agents can only list and read until this is enabled. |
Allow sending emails and repliesallow_sending
|
boolean default false |
Off by default. Prefer create_draft so a person can review before anything is sent. |
Allowed recipient domainsallowed_recipient_domains
|
string | Comma-separated, e.g. acme.com,partner.com. Sending to any other domain is refused. Leave empty to allow any. |
Tools (7)
list_messages
read-only
List recent Gmail messages, optionally filtered with a Gmail search query
| Argument | Type | Description |
|---|---|---|
query |
string | Optional Gmail search query max length 500 |
top |
integer default 25 |
Number of messages (max 100) min 1, max 100 |
search_messages
read-only
Search Gmail with a query, e.g. 'invoice from:billing@acme.com newer_than:30d'
| Argument | Type | Description |
|---|---|---|
query required |
string | Gmail search query, e.g. is:unread from:billing@acme.com newer_than:7d min length 1, max length 500 |
top |
integer default 25 |
Number of messages (max 100) min 1, max 100 |
get_message
read-only
Read an email: sender, recipients, body and labels
| Argument | Type | Description |
|---|---|---|
message_id required |
string | Gmail message id from list_messages or search_messages pattern ^[A-Za-z0-9_\-]{6,128}$ |
max_body_chars |
integer default 20000 |
min 200, max 100000 |
create_draft
Save a draft email in Gmail Drafts for a person to review and send
| Argument | Type | Description |
|---|---|---|
to required |
string | pattern ^[^@\s/\\]+@[^@\s/\\]+\.[^@\s/\\]+$ |
subject required |
string | min length 1, max length 998 |
body required |
string | min length 1, max length 200000 |
thread_id |
string | pattern ^[A-Za-z0-9_\-]{6,128}$ |
send_email
destructive
Send an email from the connected Gmail account
| Argument | Type | Description |
|---|---|---|
to required |
string | pattern ^[^@\s/\\]+@[^@\s/\\]+\.[^@\s/\\]+$ |
subject required |
string | min length 1, max length 998 |
body required |
string | min length 1, max length 200000 |
reply_to_message
destructive
Reply to an email (or reply all), threaded under the original
| Argument | Type | Description |
|---|---|---|
message_id required |
string | Gmail message id from list_messages or search_messages pattern ^[A-Za-z0-9_\-]{6,128}$ |
body required |
string | Reply text min length 1, max length 200000 |
reply_all |
boolean default false |
mark_as_read
Mark an email as read
| Argument | Type | Description |
|---|---|---|
message_id required |
string | Gmail message id from list_messages or search_messages pattern ^[A-Za-z0-9_\-]{6,128}$ |
Billing & errors
Each successful tool call costs 1 oshaani.com credit. initialize, tools/list, failed calls and timeouts are free.
| JSON-RPC code | Meaning |
|---|---|
-32054 (HTTP 401) | Missing, unknown or revoked API key |
-32053 (HTTP 404) | No Gmail connection configured for your organisation, or the connection ID is wrong |
-32055 (HTTP 403) | Connection disabled or origin not allowed |
-32052 (HTTP 429) | Rate limit reached; retry after a minute |
-32050 | Not enough oshaani.com credits for the call |
-32051 | Billing temporarily unavailable; the call was not run |
Errors from Gmail itself (bad IDs, permissions) come back as tool results with isError: true so the agent can read and correct them.
See the Gmail API documentation.