Gemini CLI + Google MCPs: Migrate & deploy full stack apps

By Google Cloud Tech

Share:

Migrating a Full-Stack Application to Google Cloud with Remote MCP Servers

Key Concepts:

  • MCP (Model Call Proxy) Servers: Remote servers provided by Google Cloud that allow AI agents (like Gemini) to interact with Google Cloud services.
  • Gemini CLI: Command-line interface used to interact with the MCP servers.
  • Developer Knowledge MCP Server: Provides access to Google Cloud documentation for AI-assisted code generation and problem-solving.
  • Cloud SQL MCP Server: Enables natural language interaction with Cloud SQL databases (MySQL, PostgreSQL, SQL Server) for tasks like querying, optimization, and troubleshooting.
  • Cloud Run MCP Server: Facilitates application deployment to Cloud Run using tools like the "deploy service from image" tool.
  • Allstrides Application: The full-stack application used as a case study for migration.
  • AI Studio: Platform for obtaining Gemini API keys.
  • settings.json: Configuration file used to store API keys and settings for connecting to MCP servers.

1. Introduction and Workflow Setup

The video demonstrates a workflow for migrating a full-stack application, “Allstrides,” from a local machine to Google Cloud using Google Cloud Console, Cloud Shell, and Gemini CLI interacting with remote MCP servers. The core idea is to leverage AI agents to automate tasks typically involved in cloud migration, such as database selection, instance creation, data migration, and application deployment. The workflow relies on three key MCP servers: Developer Knowledge, Cloud SQL, and Cloud Run.

2. Environment Configuration & Gemini CLI Initialization

The process begins within Cloud Shell. The first step involves cloning the MCP repository containing the Allstrides application. Crucially, proper credential setup is required for Gemini CLI to communicate with the necessary MCP servers. This is achieved by obtaining a Gemini API key from AI Studio and a Developer Knowledge API key. Configuration details, including API keys, are stored in the settings.json file within the cloned project directory.

Initializing Gemini CLI with the command gemini establishes the connection to the configured MCP servers. The command gemini tools then displays the connected MCP servers and their available tools, confirming successful setup. The Developer Knowledge server is highlighted as a tool to prevent AI agents from generating incorrect or non-functional code by providing access to official Google Cloud documentation.

3. Database Platform Selection with AI Assistance

The initial prompt to Gemini CLI is: “Hi, I need to choose a database platform for my All Strides application in Google Cloud. Can you analyze documentation and prepare a tutorial to choose the correct database engine?” Gemini CLI utilized the “search documents” tool within the Developer Knowledge MCP server to analyze the application and relevant Google Cloud documentation.

The AI agent concluded that Cloud SQL is the best choice for the Allstrides application and generated a tutorial outlining the migration process. This demonstrates the ability of the AI to make informed decisions based on documentation and provide actionable guidance.

4. Cloud SQL Instance Creation and Data Migration

Following the database platform selection, the next prompt instructs Gemini CLI to create a Cloud SQL for PostgreSQL instance in the us-central1 region with specific configurations: public IP, 2 CPUs, and 8GB of memory. Gemini CLI then used the “create instance” tool within the Cloud SQL MCP server to provision the instance.

Once the Cloud SQL instance was ready, Gemini CLI was tasked with migrating data from the cloned GitHub repository to the new instance. The prompt specified creating a new user ("allstrides") with database owner privileges and a database named "allstridesDB." Gemini CLI successfully created the database, user, and password, and then imported the application's data. A summary of these actions was then generated by Gemini CLI.

5. Application Deployment to Cloud Run

The final step involves deploying the Allstrides application to Cloud Run. Gemini CLI was instructed to deploy the application, utilizing the “deploy service from image” tool within the Cloud Run MCP server. Upon successful deployment, Gemini CLI provided the URL for the deployed application.

6. Application Verification and Demonstration

The deployed Allstrides application, a community platform for runners, was demonstrated. The video showcased the events and chat features, confirming that the application successfully retrieves and displays data from the newly created Cloud SQL database. This validates the entire migration process.

7. Resources and Further Information

The video concludes by directing viewers to resources in the description box, including:

  • A link to the Google MCP repository with sample applications.
  • Links to blog posts detailing the latest MCP servers.
  • Links to the official Google Cloud documentation for MCP servers.

Notable Quote:

“Developer knowledge is essentially a great way for your AI agents to connect to Google Cloud’s documentation. So no longer would your AI agents be generating code which potentially might not even work or run because it would now have access to actual developer documentation in order to generate the right code samples for example.” – Video Presenter

Synthesis/Conclusion:

This video effectively demonstrates the power of Google Cloud’s remote MCP servers in streamlining the migration of a full-stack application to the cloud. By leveraging AI agents through Gemini CLI, complex tasks like database selection, instance creation, data migration, and deployment can be automated, significantly reducing manual effort and potential errors. The integration with official Google Cloud documentation via the Developer Knowledge MCP server ensures the accuracy and reliability of the generated code and configurations. This approach represents a significant step towards AI-assisted cloud development and deployment.

Chat with this Video

AI-Powered

Hi! I can answer questions about this video "Gemini CLI + Google MCPs: Migrate & deploy full stack apps". What would you like to know?

Chat is based on the transcript of this video and may not be 100% accurate.

Related Videos

Ready to summarize another video?

Summarize YouTube Video