Skip to main content
Glama

google_drive_share_file

Share a file on Google Drive by specifying the file ID and recipient email. Set access roles (reader, writer, commenter, owner) and optionally include a custom message in the notification email.

Instructions

Share a file with another user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailAddressYesEmail address of the user to share with
fileIdYesID of the file to share
messageNoCustom message to include in the notification email
roleNoAccess role to grant (reader, writer, commenter, owner)
sendNotificationNoWhether to send a notification email

Implementation Reference

  • Handler function that validates input arguments using isShareFileArgs and calls the GoogleDrive instance's shareFile method to perform the sharing operation.
    export async function handleDriveShareFile(
      args: any,
      googleDriveInstance: GoogleDrive
    ) {
      if (!isShareFileArgs(args)) {
        throw new Error("Invalid arguments for google_drive_share_file");
      }
      const { fileId, emailAddress, role, sendNotification, message } = args;
      const result = await googleDriveInstance.shareFile(
        fileId,
        emailAddress,
        role,
        sendNotification,
        message
      );
      return {
        content: [{ type: "text", text: result }],
        isError: false,
      };
    }
  • MCP tool definition including name, description, and input schema for validating tool arguments.
    export const SHARE_FILE_TOOL: Tool = {
      name: "google_drive_share_file",
      description: "Share a file with another user",
      inputSchema: {
        type: "object",
        properties: {
          fileId: {
            type: "string",
            description: "ID of the file to share",
          },
          emailAddress: {
            type: "string",
            description: "Email address of the user to share with",
          },
          role: {
            type: "string",
            description: "Access role to grant (reader, writer, commenter, owner)",
          },
          sendNotification: {
            type: "boolean",
            description: "Whether to send a notification email",
          },
          message: {
            type: "string",
            description: "Custom message to include in the notification email",
          },
        },
        required: ["fileId", "emailAddress"],
      },
    };
  • Switch case in server request handler that routes 'call tool' requests for 'google_drive_share_file' to the drive handler.
    case "google_drive_share_file":
      return await driveHandlers.handleDriveShareFile(
        args,
        googleDriveInstance
      );
  • Core implementation in GoogleDrive class that uses Google Drive API to create permissions and share the file, returning a success message.
    async shareFile(
      fileId: string,
      emailAddress: string,
      role: string = "reader",
      sendNotification: boolean = true,
      message?: string
    ) {
      try {
        const response = await this.drive.permissions.create({
          fileId: fileId,
          requestBody: {
            type: "user",
            role: role,
            emailAddress: emailAddress,
          },
          sendNotificationEmail: sendNotification,
          emailMessage: message,
        });
    
        // Get the file name
        const fileMetadata = await this.drive.files.get({
          fileId: fileId,
          fields: "name",
        });
    
        return `File '${fileMetadata.data.name}' shared with ${emailAddress} as ${role}.`;
      } catch (error) {
        throw new Error(
          `Failed to share file: ${
            error instanceof Error ? error.message : String(error)
          }`
        );
      }
    }
  • Type guard function for runtime validation of arguments matching the tool's input schema.
    export function isShareFileArgs(args: any): args is {
      fileId: string;
      emailAddress: string;
      role?: string;
      sendNotification?: boolean;
      message?: string;
    } {
      return (
        args &&
        typeof args.fileId === "string" &&
        typeof args.emailAddress === "string" &&
        (args.role === undefined || typeof args.role === "string") &&
        (args.sendNotification === undefined ||
          typeof args.sendNotification === "boolean") &&
        (args.message === undefined || typeof args.message === "string")
      );
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Share a file' implies a mutation operation that grants access, but the description doesn't mention critical behaviors like required permissions (e.g., needing to own the file), whether sharing is reversible, rate limits, or what the response looks like (e.g., success confirmation or error cases). 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. It's front-loaded with the core purpose and appropriately sized for a simple action, 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 complexity of a mutation tool (sharing files) with no annotations and no output schema, the description is incomplete. It lacks behavioral details (e.g., permissions needed, effects), usage context, and output information. While the schema covers parameters well, the overall context for safe and effective use is insufficient.

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%, meaning all parameters are documented in the schema itself. The description adds no additional parameter semantics beyond what the schema provides (e.g., it doesn't clarify default values, constraints like email format validation, or how parameters interact). With high schema coverage, the baseline score of 3 is appropriate.

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 ('share') and resource ('a file') with a specific target ('with another user'), which is a complete verb+resource statement. However, it doesn't distinguish this tool from potential sibling sharing tools (though none are listed among the provided siblings), so it falls short of 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. There are no explicit when/when-not instructions, no mention of prerequisites (e.g., file ownership/permissions), and no comparison to other Google Drive tools like 'google_drive_update_file' that might handle permissions differently.

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

Related 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/vakharwalad23/google-mcp'

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