Skip to main content
Glama
ricleedo

Google Services MCP Server

by ricleedo

gmail-send-email

Send emails through Gmail by specifying recipients, subject, and body content. This tool enables email dispatch with optional CC and BCC fields for communication management.

Instructions

Send an email using Gmail

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesRecipient email address
subjectYesEmail subject
bodyYesEmail body content
ccNoCC email addresses (comma-separated)
bccNoBCC email addresses (comma-separated)

Implementation Reference

  • Main handler function that constructs and sends an email via the Gmail API using base64url encoded raw email format and OAuth2 authentication.
    export async function sendEmail(params: z.infer<typeof sendEmailSchema>) {
      try {
        const auth = createGmailAuth();
        const gmail = google.gmail({ version: "v1", auth });
    
        // Create email content
        const email = [];
        email.push(`To: ${params.to}`);
        if (params.cc) email.push(`Cc: ${params.cc}`);
        if (params.bcc) email.push(`Bcc: ${params.bcc}`);
        email.push(`Subject: ${params.subject}`);
        email.push("");
        email.push(params.body);
    
        const rawEmail = Buffer.from(email.join("\n")).toString("base64url");
    
        const response = await gmail.users.messages.send({
          userId: "me",
          requestBody: {
            raw: rawEmail,
          },
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: `# Email Sent Successfully ✅\n\nMessage ID: \`${response.data.id}\`  \nThread ID: \`${response.data.threadId}\`  \nTo: ${params.to}  \nSubject: ${params.subject}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error sending email: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
    }
  • Zod schema defining the input parameters for the gmail-send-email tool.
    export const sendEmailSchema = z.object({
      to: z.string().describe("Recipient email address"),
      subject: z.string().describe("Email subject"),
      body: z.string().describe("Email body content"),
      cc: z.string().optional().describe("CC email addresses (comma-separated)"),
      bcc: z.string().optional().describe("BCC email addresses (comma-separated)"),
    });
  • src/index.ts:182-189 (registration)
    Tool registration in the MCP server, linking the name, description, schema, and handler.
    server.tool(
      "gmail-send-email",
      "Send an email using Gmail",
      sendEmailSchema.shape,
      async (params) => {
        return await sendEmail(params);
      }
    );
  • Helper function to create and configure OAuth2 client for Gmail API authentication using environment variables.
    function createGmailAuth() {
      const clientId = process.env.GOOGLE_CLIENT_ID;
      const clientSecret = process.env.GOOGLE_CLIENT_SECRET;
      const redirectUri =
        process.env.GOOGLE_REDIRECT_URI || "http://localhost:3000/oauth2callback";
    
      if (!clientId || !clientSecret) {
        throw new Error(
          "GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET are required. Run oauth-setup.js to configure."
        );
      }
    
      const oauth2Client = new google.auth.OAuth2(
        clientId,
        clientSecret,
        redirectUri
      );
    
      const accessToken = process.env.GOOGLE_ACCESS_TOKEN;
      const refreshToken = process.env.GOOGLE_REFRESH_TOKEN;
    
      if (!accessToken || !refreshToken) {
        throw new Error("OAuth2 tokens missing. Run oauth-setup.js to get tokens.");
      }
    
      oauth2Client.setCredentials({
        access_token: accessToken,
        refresh_token: refreshToken,
      });
    
      return oauth2Client;
    }
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 states the action ('send an email') but doesn't cover critical traits: it doesn't mention authentication requirements, rate limits, whether emails are sent immediately or queued, error handling, or what happens on success/failure. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 extremely concise at just four words ('Send an email using Gmail'), with zero wasted language. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place by conveying essential purpose without redundancy.

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 this is a mutation tool (sending emails) with no annotations, no output schema, and 5 parameters, the description is incomplete. It doesn't address authentication, side effects, error cases, or return values. While the schema covers parameters well, the description fails to provide necessary context for safe and effective use, especially for a write 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%, with all parameters clearly documented in the input schema (e.g., 'to' as recipient email address). The description adds no parameter-specific information beyond what the schema provides. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description, which applies here.

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 using Gmail' clearly states the action (send) and resource (email via Gmail), making the purpose immediately understandable. It distinguishes from sibling tools like gmail-get-email or gmail-read-emails by focusing on sending rather than retrieving. However, it doesn't specify if this is for single emails or batches, which prevents 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., authentication needs), when not to use it (e.g., for reading emails), or compare it to similar tools like calendar-create-event for scheduling communications. This leaves the agent without context for appropriate tool selection.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ricleedo/Google-Service-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server