GCP – Guide to build MCP servers using vibe coding with Gemini 2.5 Pro
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
- <ListValue: [StructValue([(‘title’, ‘$300 in free credit to try Google Cloud AI and ML’), (‘body’, <wagtail.rich_text.RichText object at 0x3eba671716d0>), (‘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.
Read More for the details.