Enhanced Guide to Using Prompts in Gemini CLI

Gists

Abstract

This report provides a comprehensive overview of how to utilize prompts within the Gemini Command-Line Interface (CLI). Leveraging a Google Apps Script MCP server, we will explore practical examples, including roadmap generation, real-time weather inquiries, and Google Drive file searches. This enhanced document offers more in-depth explanations and a broader context to empower users in their understanding and application of these powerful features.

Introduction

The Model Context Protocol (MCP) establishes a standardized framework for servers to offer clients predefined, structured prompt templates. These user-controllable prompts, customizable with arguments, are engineered to streamline interactions with large language models. The Gemini CLI, starting with version v0.1.15, integrates support for these prompts, significantly expanding its capabilities.

This document will guide you through the use of these prompts with concrete examples. The MCP server in our illustrations is built upon MCPApp and ToolsForMCPServer, two libraries expressly designed for the Google Apps Script environment. This allows the Gemini CLI to seamlessly interact with various Google Workspace services.

Repositories

  • MCPApp: A foundational library for creating MCP servers using Google Apps Script.
  • ToolsForMCPServer: An extension for MCPApp that provides a rich collection of pre-built tools and prompts for interacting with Google Workspace.

Available Prompts and Tools

For detailed instructions on setup and usage, please consult the official repository: https://github.com/tanaikech/ToolsForMCPServer?tab=readme-ov-file#usage

Currently, ToolsForMCPServer boasts an impressive arsenal of 45 tools and 3 distinct prompts, empowering users to perform a wide array of tasks within the Google ecosystem directly from the command line.

This report will now showcase the functionality of the three available prompts with illustrative examples.

Sample Prompts

Generate a Strategic Roadmap

This prompt facilitates the creation of a detailed roadmap within a new Google Sheet, perfect for project planning and goal setting. To invoke this prompt, simply type a forward slash (/) in the Gemini CLI console, which will reveal the list of available prompts for you to select.

Prompt:

/generate_roadmap --goal="Cooking delicious sukiyaki"

Result:

The generated roadmap, neatly organized in a Google Sheet, will resemble the following:

In this operation, two tools from the ToolsForMCPServer library were utilized: create_file_to_google_drive and generate_roadmap_to_google_sheets. The underlying prompt is constructed with the goal argument you provide:

{
  "messages": [
    {
      "role": "user",
      "content": {
        "type": "text",
        "text": "Create a roadmap for a new Google Spreadsheet with the goal of \"Cooking delicious sukiyaki\".\n1. Create a new Google Spreadsheet.\n2. Generate a detailed roadmap in the spreadsheet to reach the goal.\n3. Return the spreadsheet's URL."
      }
    }
  ]
}

Instantly Check the Current Weather

This straightforward prompt allows you to retrieve the current weather conditions for any specified location.

Prompt:

/get_weather --location="Tokyo"

Result:

The prompt sent to the model is a direct question, incorporating the location argument:

{
  "messages": [
    {
      "role": "user",
      "content": {
        "type": "text",
        "text": "What is the current weather in Tokyo?"
      }
    }
  ]
}

Effortlessly Search Your Google Drive

Quickly locate files within your Google Drive by providing a filename. This prompt streamlines file retrieval without ever leaving your terminal.

Prompt:

/search_files_on_google_drive --filename="sample file"

Result:

This prompt leverages the search_file_in_google_drive tool. The model receives a request for the file’s metadata, using the filename you specified:

{
  "messages": [
    {
      "role": "user",
      "content": {
        "type": "text",
        "text": "Return file metadata of 'sample file' on Google Drive."
      }
    }
  ]
}

Summary

This guide has illuminated the powerful capabilities unlocked by using prompts in the Gemini CLI. Key takeaways include:

  • The Gemini CLI, since version v0.1.15, supports prompts defined by MCP, enabling more structured and potent interactions with language models.
  • MCP provides a standardized method for servers to expose prompt templates, which can be customized with arguments.
  • The demonstrated examples utilize an MCP server built with MCPApp and ToolsForMCPServer, libraries specifically designed for the Google Apps Script environment, allowing for deep integration with Google Workspace.
  • The ToolsForMCPServer library offers a substantial collection of 45 tools and 3 prompts, facilitating a wide range of automated tasks.
  • The showcased prompts provide practical, out-of-the-box solutions for generating roadmaps in Google Sheets, checking the weather, and searching for files in Google Drive, all from the convenience of the command line.

 Share!