Skip to main content
Glama
baryhuang
by baryhuang

MCP 헤드리스 Gmail 서버

npm 버전 도커 풀 라이센스: MIT

로컬 자격 증명이나 토큰 설정 없이 Gmail을 받고 보낼 수 있는 MCP(Model Context Protocol) 서버입니다.

왜 MCP 헤드리스 Gmail 서버를 사용해야 하나요?

중요한 장점

  • 헤드리스 및 원격 작업 : Docker 및 로컬 파일 액세스 외부에서 실행해야 하는 다른 MCP Gmail 솔루션과 달리 이 서버는 브라우저나 로컬 파일 액세스 없이 원격 환경에서 완전히 헤드리스로 실행될 수 있습니다.

  • 분리된 아키텍처 : 모든 클라이언트가 OAuth 흐름을 독립적으로 완료한 다음 자격 증명을 컨텍스트로 이 MCP 서버에 전달하여 자격 증명 저장소와 서버 구현이 완전히 분리됩니다.

좋지만 비판적이지는 않음

  • 집중된 기능 : 많은 사용 사례, 특히 마케팅 애플리케이션의 경우 캘린더와 같은 추가 Google 서비스 없이 Gmail 접속만 필요하므로 이 집중된 구현 방식이 이상적입니다.

  • Docker 지원 : 컨테이너화를 염두에 두고 설계되어 환경에 구애받지 않고 한 번의 클릭으로 완벽하게 격리된 설정이 가능합니다.

  • 안정적인 종속성 : 잘 유지 관리되는 google-api-python-client 라이브러리를 기반으로 구축되었습니다.

Related MCP server: MCP Headless Gmail Server

특징

  • 본문의 처음 1,000자까지 Gmail에서 가장 최근 이메일을 가져옵니다.

  • 오프셋 매개변수를 사용하여 1k 청크로 전체 이메일 본문 콘텐츠를 가져옵니다.

  • Gmail을 통해 이메일 보내기

  • 액세스 토큰을 별도로 새로 고침

  • 자동 새로 고침 토큰 처리

필수 조건

  • Python 3.10 이상

  • Google API 자격 증명(클라이언트 ID, 클라이언트 비밀, 액세스 토큰 및 새로 고침 토큰)

설치

지엑스피1

도커

Docker 이미지 빌드

# Build the Docker image
docker build -t mcp-headless-gmail .

Claude Desktop과 함께 사용

Claude 구성에 다음을 추가하여 Docker 이미지를 사용하도록 Claude Desktop을 구성할 수 있습니다.

도커

{
  "mcpServers": {
    "gmail": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "buryhuang/mcp-headless-gmail:latest"
      ]
    }
  }
}

npm 버전

{
  "mcpServers": {
    "gmail": {
      "command": "npx",
      "args": [
        "@peakmojo/mcp-server-headless-gmail"
      ]
    }
  }
}

참고: 이 구성을 사용하면 도구 사용 섹션에 설명된 대로 도구 호출 시 Google API 사용자 인증 정보를 제공해야 합니다. Gmail 사용자 인증 정보는 사용자 인증 정보 저장소와 서버 구현을 분리하기 위해 환경 변수로 전달되지 않습니다.

크로스 플랫폼 퍼블리싱

여러 플랫폼에 Docker 이미지를 게시하려면 docker buildx 명령을 사용할 수 있습니다. 다음 단계를 따르세요.

  1. 새로운 빌더 인스턴스를 만듭니다 (아직 만들지 않았다면):

    docker buildx create --use
  2. 여러 플랫폼에 대한 이미지를 빌드하고 푸시합니다 .

    docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t buryhuang/mcp-headless-gmail:latest --push .
  3. 지정된 플랫폼에서 이미지를 사용할 수 있는지 확인하세요 .

    docker buildx imagetools inspect buryhuang/mcp-headless-gmail:latest

용법

이 서버는 MCP 도구를 통해 Gmail 기능을 제공합니다. 전용 토큰 새로 고침 도구를 사용하면 인증 처리가 간소화됩니다.

서버 시작

mcp-server-headless-gmail

도구 사용

Claude와 같은 MCP 클라이언트를 사용하는 경우 인증을 처리하는 두 가지 주요 방법이 있습니다.

토큰 새로 고침(첫 번째 단계 또는 토큰 만료 시)

액세스 토큰과 새로 고침 토큰이 모두 있는 경우:

{
  "google_access_token": "your_access_token",
  "google_refresh_token": "your_refresh_token",
  "google_client_id": "your_client_id",
  "google_client_secret": "your_client_secret"
}

액세스 토큰이 만료된 경우 새로 고침 토큰만으로 새로 고칠 수 있습니다.

{
  "google_refresh_token": "your_refresh_token",
  "google_client_id": "your_client_id",
  "google_client_secret": "your_client_secret"
}

이렇게 하면 새로운 액세스 토큰과 만료 시간이 반환되며, 이를 후속 호출에 사용할 수 있습니다.

최근 이메일 받기

각 이메일 본문의 처음 1,000자를 포함한 최근 이메일을 검색합니다.

{
  "google_access_token": "your_access_token",
  "max_results": 5,
  "unread_only": false
}

응답에는 다음이 포함됩니다.

  • 이메일 메타데이터(ID, 스레드 ID, 보낸 사람, 받는 사람, 제목, 날짜 등)

  • 이메일 본문의 처음 1000자

  • body_size_bytes : 이메일 본문의 총 크기(바이트)

  • contains_full_body : 본문 전체가 포함되는지(true) 또는 잘리는지(false)를 나타내는 부울 값입니다.

전체 이메일 본문 내용 가져오기

본문이 1,000자를 넘는 이메일의 경우 전체 내용을 청크로 검색할 수 있습니다.

{
  "google_access_token": "your_access_token",
  "message_id": "message_id_from_get_recent_emails",
  "offset": 0
}

스레드 ID로 이메일 내용을 받을 수도 있습니다.

{
  "google_access_token": "your_access_token",
  "thread_id": "thread_id_from_get_recent_emails",
  "offset": 1000
}

응답에는 다음이 포함됩니다.

  • 지정된 오프셋에서 시작하는 이메일 본문의 1k 청크

  • body_size_bytes : 이메일 본문의 총 크기

  • chunk_size : 반환된 청크의 크기

  • contains_full_body : 청크에 본문의 나머지 부분이 포함되어 있는지 여부를 나타내는 부울 값입니다.

긴 메시지의 전체 이메일 본문을 검색하려면, contains_full_body 참이 될 때까지 오프셋을 1000씩 증가시키는 순차적 호출을 수행합니다.

이메일 보내기

{
  "google_access_token": "your_access_token",
  "to": "recipient@example.com",
  "subject": "Hello from MCP Gmail",
  "body": "This is a test email sent via MCP Gmail server",
  "html_body": "<p>This is a <strong>test email</strong> sent via MCP Gmail server</p>"
}

토큰 새로 고침 워크플로

  1. 다음 중 하나를 사용하여 gmail_refresh_token 도구를 호출하여 시작하세요.

    • 전체 자격 증명(액세스 토큰, 새로 고침 토큰, 클라이언트 ID 및 클라이언트 비밀번호) 또는

    • 액세스 토큰이 만료된 경우 새로 고침 토큰, 클라이언트 ID 및 클라이언트 비밀번호만 있으면 됩니다.

  2. 반환된 새 액세스 토큰을 후속 API 호출에 사용합니다.

  3. 토큰 만료를 나타내는 응답을 받으면 gmail_refresh_token 도구를 다시 호출하여 새로운 토큰을 받으세요.

이 접근 방식은 모든 작업에 대해 클라이언트 자격 증명을 요구하지 않고도 대부분의 API 호출을 간소화하는 동시에 필요할 때 토큰 새로 고침을 활성화합니다.

Google API 자격 증명 얻기

필요한 Google API 자격 증명을 얻으려면 다음 단계를 따르세요.

  1. Google Cloud Console 로 이동

  2. 새 프로젝트를 만듭니다

  3. Gmail API 활성화

  4. OAuth 동의 화면 구성

  5. OAuth 클라이언트 ID 자격 증명을 만듭니다(애플리케이션 유형으로 "데스크톱 앱"을 선택).

  6. 클라이언트 ID와 클라이언트 비밀번호를 저장합니다.

  7. 다음 범위의 액세스 토큰과 새로 고침 토큰을 얻으려면 OAuth 2.0을 사용하세요.

    • https://www.googleapis.com/auth/gmail.readonly (이메일 읽기용)

    • https://www.googleapis.com/auth/gmail.send (이메일 전송용)

토큰 새로 고침

이 서버는 토큰 자동 갱신을 구현합니다. 액세스 토큰이 만료되면 Google API 클라이언트는 갱신 토큰, 클라이언트 ID, 클라이언트 비밀번호를 사용하여 사용자 개입 없이 새 액세스 토큰을 얻습니다.

보안 참고 사항

이 서버는 Google API 사용자 인증 정보에 직접 액세스해야 합니다. 토큰과 사용자 인증 정보는 항상 안전하게 보관하고 신뢰할 수 없는 사람과 공유하지 마세요.

특허

자세한 내용은 LICENSE 파일을 참조하세요.

Available Tools

4 tools
gmail_get_email_body_chunkB

Get a 1k character chunk of an email body starting from the specified offset

ParametersJSON Schema
NameRequiredDescriptionDefault
google_access_tokenYesGoogle OAuth2 access token
message_idNoID of the message to retrieve
thread_idNoID of the thread to retrieve (will get the first message if multiple exist)
offsetNoOffset in characters to start from (default: 0)

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the 1k character chunking behavior, which is valuable, but doesn't address authentication needs (though implied by google_access_token parameter), error handling, rate limits, or what happens with invalid offsets/message_ids. For a tool with no annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that immediately conveys the core functionality without any wasted words. It's appropriately sized and front-loaded with the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is minimally adequate. It explains the chunking behavior but lacks details about authentication requirements, error conditions, and how this tool relates to siblings. Without annotations or output schema, more behavioral context would be helpful for safe usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so parameters are well-documented in the schema. The description adds context about the 'offset' parameter (default: 0) and clarifies that thread_id retrieves the first message if multiple exist, providing some value beyond the schema. However, it doesn't explain parameter interactions or provide additional semantic context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get'), resource ('email body chunk'), and key constraint ('1k character chunk starting from specified offset'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like gmail_get_recent_emails, which retrieves multiple emails rather than a specific body chunk.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives. The description doesn't mention prerequisites (like needing a message_id or thread_id), nor does it explain when this tool is appropriate compared to gmail_get_recent_emails for retrieving email content.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

gmail_get_recent_emailsC

Get the most recent emails from Gmail (returns metadata, snippets, and first 1k chars of body)

ParametersJSON Schema
NameRequiredDescriptionDefault
google_access_tokenYesGoogle OAuth2 access token
max_resultsNoMaximum number of emails to return (default: 10)
unread_onlyNoWhether to return only unread emails (default: False)

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions what data is returned (metadata, snippets, first 1k chars of body) which is helpful, but doesn't cover important behavioral aspects like authentication requirements (beyond the parameter), rate limits, pagination behavior, error conditions, or whether this is a read-only operation. For a tool with no annotations, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that communicates the core functionality and return format. It's appropriately sized for a straightforward retrieval tool, though it could potentially benefit from slightly more detail given the lack of annotations and output schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of email retrieval (3 parameters, no annotations, no output schema), the description is insufficiently complete. It doesn't explain the return format in detail, doesn't mention authentication requirements beyond the parameter, and doesn't cover important behavioral aspects. For a tool with no annotations or output schema, the description should provide more context about what to expect from the operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents all three parameters. The description doesn't add any parameter-specific information beyond what's in the schema. The baseline of 3 is appropriate when the schema does all the parameter documentation work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get the most recent emails from Gmail' specifies the verb (get) and resource (emails). It distinguishes from sibling 'gmail_get_email_body_chunk' by indicating it returns metadata, snippets, and partial body content, but doesn't explicitly differentiate from other siblings like 'gmail_send_email' or 'gmail_refresh_token' beyond the obvious functional difference.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives is provided. The description doesn't mention when to use this versus 'gmail_get_email_body_chunk' for full body retrieval, or when to use 'gmail_refresh_token' for token management. Usage context is implied by the tool name but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

gmail_refresh_tokenB

Refresh the access token using the refresh token and client credentials

ParametersJSON Schema
NameRequiredDescriptionDefault
google_access_tokenNoGoogle OAuth2 access token (optional if expired)
google_refresh_tokenYesGoogle OAuth2 refresh token
google_client_idYesGoogle OAuth2 client ID for token refresh
google_client_secretYesGoogle OAuth2 client secret for token refresh

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states what the tool does at a high level. It doesn't disclose behavioral traits like whether this invalidates previous tokens, rate limits, error conditions, or what the refreshed token enables. For a security-sensitive operation with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose with zero waste. It's appropriately sized and front-loaded, with every word contributing to understanding the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a security-critical token refresh operation with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after refresh (e.g., token lifetime, scope preservation), error handling, or integration with sibling tools. Given the complexity and lack of structured data, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 4 parameters thoroughly. The description adds no parameter-specific semantics beyond what's in the schema (e.g., it doesn't explain relationships between parameters or provide usage examples). Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Refresh') and resource ('access token'), specifying it uses refresh token and client credentials. It distinguishes from sibling tools (email-related operations) by focusing on authentication token management, though it doesn't explicitly name alternatives for token refresh.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when access tokens expire (via 'optional if expired' in schema), but doesn't explicitly state when to use this tool versus alternatives like initial authentication or other token management methods. No guidance on prerequisites or exclusions is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

gmail_send_emailC

Send an email via Gmail

ParametersJSON Schema
NameRequiredDescriptionDefault
google_access_tokenYesGoogle OAuth2 access token
toYesRecipient email address
subjectYesEmail subject
bodyYesEmail body content (plain text)
html_bodyNoEmail body content in HTML format (optional)

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('send an email') but lacks critical details: it doesn't mention authentication requirements (implied by the 'google_access_token' parameter but not explicitly stated), potential rate limits, error handling, or what happens upon success (e.g., whether it returns a confirmation). This leaves significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words—'Send an email via Gmail' is front-loaded and directly conveys the core action. It's appropriately sized for the tool's complexity, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation tool with 5 parameters, no annotations, and no output schema), the description is incomplete. It fails to address key contextual aspects like authentication needs, behavioral traits (e.g., what 'send' entails operationally), or output expectations, leaving the agent with insufficient information for reliable use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with all parameters well-documented in the schema (e.g., 'to' as recipient email, 'body' as plain text content). The description adds no additional meaning beyond the schema, such as explaining parameter interactions (e.g., 'body' vs. 'html_body') or constraints. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Send an email via Gmail' clearly states the verb ('send') and resource ('email via Gmail'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'gmail_get_recent_emails' or 'gmail_refresh_token' beyond the obvious action distinction, which keeps it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing authentication via 'google_access_token'), nor does it clarify scenarios where other tools like 'gmail_get_recent_emails' might be more appropriate, leaving usage context entirely implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updates
    • First observedgmail_get_email_body_chunk
    • First observedgmail_get_recent_emails
    • First observedgmail_refresh_token
    • First observedgmail_send_email

TDQS

B3.4/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: retrieving email body chunks, listing recent emails, refreshing tokens, and sending emails. There is no overlap in functionality that would cause confusion or misselection.

Naming Consistency5/5

All tools follow a consistent 'gmail_verb_noun' pattern with snake_case, making them predictable and easy to understand. The naming convention is uniform across all four tools.

Tool Count4/5

With 4 tools, the count is reasonable for a Gmail server, though it feels slightly thin for covering all common email operations. It includes core functions but could benefit from additional tools like searching or managing drafts.

Completeness3/5

The tools cover basic email operations (read, list, send) and authentication, but there are notable gaps such as searching emails, managing labels, or handling attachments. This could limit agents in performing more complex email tasks.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    A Model Context Protocol server that enables applications to interact with Gmail through a clean API, supporting email searching, sending, reading, and label management.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that exposes the Gmail API for integration with LLMs, enabling email management tasks such as reading, labeling, and searching emails.
    7
    MIT

Appeared in Searches