Cloud Blog: Guide to build MCP servers using vibe coding with Gemini 2.5 Pro

Source URL: https://cloud.google.com/blog/products/ai-machine-learning/build-mcp-servers-using-vibe-coding-with-gemini-2-5-pro/
Source: Cloud Blog
Title: Guide to build MCP servers using vibe coding with Gemini 2.5 Pro

Feedly Summary: Have you ever had something on the tip of your tongue, but you weren’t exactly sure how to describe what’s in your mind? 
For developers, this is where “vibe coding " comes in. Vibe coding helps developers achieve their vision with models like Gemini 2.5 Pro to generate code from natural language prompts. Instead of writing every line of code, developers can now describe the desired functionality in plain language. AI translates these "vibes" into your vision. 
Today, we’ll show you how vibe coding can help developers create Model Context Protocol (MCP) servers. MCP, launched in November 2024 by Anthropic, provides an open standard for integrating AI models with various data sources and tools. Since its release, it has become increasingly popular for building AI applications – including with new experimental models like Gemini 2.5. 
You can use Gemini 2.5 Pro’s code generation capabilities to create MCP servers with ease, helping you build  intuitive, natural language specifications and operational AI infrastructure.

aside_block
), (‘btn_text’, ‘Start building for free’), (‘href’, ‘http://console.cloud.google.com/freetrial?redirectPath=/vertex-ai/’), (‘image’, None)])]>

The methodology
Effective AI-assisted coding, especially for specific tasks like generating MCP server code with models such as Gemini 2.5 Pro, starts with clear prompting. To achieve the best results:

Provide context: Offer relevant background information about the MCP server.

Be specific: Give clear and detailed instructions for the code you need.

Be patient: Generating and refining code can take time.

Remember that this is often an iterative process. Be prepared to refine your instructions and regenerate the code until the results are satisfactory.
How to create an MCP server using vibe coding, step by step
There are two ways to leverage Gemini 2.5 Pro for vibe coding: through the Gemini app (gemini.google.com) or by utilizing the Google Gen AI SDK.
Approach 1: Use the Gemini app

Save the webpage https://modelcontextprotocol.io/quickstart as a PDF.

Visit gemini.google.com and upload the saved PDF file.

Enter your prompt to generate the desired code.

Here’s an example of prompt to generate a Google Cloud BigQuery MCP Server:
instruction = """
You are an MCP server expert. Your mission is to write python code for MCP server. The MCP server development guide and examples are provided.
Please create MCP server code for Google Cloud BigQuery. It has two tools:
One is to list tables for all datasets,
The other is to describe a table.
Google Cloud project ID and location will be provided in the query string. Please use project id to access BigQuery client.
”””
4. Copy your code, and test the server using this notebook
Alternatively, you can use Google Gen AI SDK to create your server code in a notebook.
Approach 2: Use the Google Gen AI SDK

Begin by configuring the system’s instructions.

system_instruction = f"""
You are an MCP server expert.
Your mission is to write python code for MCP server.
Here’s the MCP server development guide and example:
{reference_content}
"""
2. Set user prompt
This step involves defining the instructions or questions that will guide the Gemini Vibe Coding process. The user prompt acts as the input for the AI model, specifying the desired outcome for building MCP servers.
url = "https://medlineplus.gov/about/developers/webservices/"
prompt_base = """
Please create an MCP server code for https://medlineplus.gov/about/developers/webservices/. It has one tool:
– get_medical_term. You provide a medical term, this tool will return an explanation of the medical term.
Here’s the API details:
"""

prompt = [prompt_base, types.Part.from_uri(file_uri=url, mime_type="text/html")]
Creating an MCP server example for a government website offering free API services is shown above.
To enhance understanding of the API being used, the API service URL is provided as additional context for Gemini content generation.
3. Generate code
Utilize the provided function to create the necessary server code.
def generate_mcp_server(prompt):
response = client.models.generate_content(
model=MODEL_ID,
contents=prompt,
config=GenerateContentConfig(
system_instruction=system_instruction,
response_mime_type="application/json",
response_schema=ResponseSchema,
),
)
return response.text
4. Use this notebook to test the server. The complete and detailed code is available within this notebook. 
Test it by yourself
Gemini 2.5 Pro, currently in preview, offers exceptional code generation capabilities for MCP servers, drastically speeding up and easing the development of your MCP applications. Keep in mind that vibe coding, including models like Gemini 2.5 Pro, may produce errors, so thorough code review is essential before implementation.
To begin creating your own code, explore Gemini app. We suggest experimenting with various prompts and Gemini models.

AI Summary and Description: Yes

Summary: The text introduces “vibe coding,” a new approach for developers utilizing AI models like Gemini 2.5 Pro to generate code from natural language prompts. It discusses how this technique can streamline the creation of Model Context Protocol (MCP) servers, enhancing efficiency and ease of development in AI applications.

Detailed Description:
The text elaborates on the innovative concept of vibe coding, which enables developers to translate their ideas into executable code through AI assistance. This methodology is particularly relevant for security and compliance professionals in the fields of AI, cloud, and infrastructure, showcasing the evolving capabilities of AI in software development.

Key Points:

– **Vibe Coding Explained**:
– Vibe coding involves expressing design intentions and functionality in plain language.
– AI models like Gemini 2.5 Pro interpret these “vibes” and generate the corresponding code.

– **Introduction to Model Context Protocol (MCP)**:
– MCP was launched by Anthropic in November 2024 as an open standard.
– It facilitates integration between AI models and various data sources/tools, essential for building robust AI applications.

– **Using Gemini 2.5 Pro**:
– The AI’s code generation capabilities can expedite the development of MCP servers.
– Vibe coding requires specific and clear prompting to optimize results, making the method iterative and user-involved.

– **Step-by-step Guide for Creating MCP Servers**:
– **Two Approaches**:
– Using the Gemini app to upload context and generate code.
– Utilizing the Google Gen AI SDK for more customizable server development.
– Example instructions demonstrate how to prompt the AI effectively to produce desired functionalities.

– **Error Handling and Best Practices**:
– Emphasizes the necessity of comprehensive code reviews to catch potential issues arising from AI-generated code.
– Encourages experimentation with different models and prompts to fully leverage Gemini’s capabilities.

This text is particularly significant for security, compliance, and development professionals as it demonstrates how advancements in AI can influence programming practices, ultimately improving efficiency while necessitating ongoing vigilance in code quality and security compliance.