gcp agentic platform creating mcp server

In gcp agentic platform mcp server is an abtraction that allows your agent to call a actual MCP hosted elsewhere.  It is not to create and deploy an MCP server. You can of course do that via Google Cloud run. 

Typically you can use the following code in your agentic runtime to call this MCP server 

import os

from google.adk.integrations.agent_registry import AgentRegistry
from google.auth import default
from google.adk.agents import Agent
from google.adk.models import Gemini
from google.genai import types

_, project_id = default()
LOCATION = os.environ.setdefault("GOOGLE_CLOUD_LOCATION", "us-central1")
MCP_SERVER_NAME = os.environ.get("MCP_SERVER_NAME", "agentregistry-00000000-0000-0000-bd07-35253020786b")
os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "True"
registry = AgentRegistry(project_id=project_id, location=LOCATION)

mcp_toolset = registry.get_mcp_toolset(
    f"projects/project-id/locations/us-central1/mcpServers/
agentregistry-00000000-0000-0000-bd07-35253020786b"
)

root_agent = Agent(
        name="sample",
        description=(
            "You are a helpful AI Assistant who can answer questions."
        ),
        model=Gemini(
            model="gemini-3.8-flash",
            retry_options=types.HttpRetryOptions(attempts=3),
        ),
        tools=[mcp_toolset],
)

And let's talk about setup. You can add your mcp here :-




After that, you can configure its name and descriptions.


The key item here is the MCP server URL and json. This is where you specify what method and parameter exposed by your MCP tool 

In the JSON payload, you must specify the field "inputSchema" otherwise you will get this error 

Sample json schema you can use are :-



{
  "tools": [
    {
      "name": "get_weather",
      "description": "Get the current weather for a city",
      "inputSchema": {
        "type": "object",
        "properties": {
          "city": { "type": "string", "description": "City name" }
        },
        "required": ["city"]
      }
    },
    {
      "name": "ping",
      "description": "Health check, takes no arguments",
      "inputSchema": { "type": "object", "properties": {} }
    }
  ]
}










Comments

Popular posts from this blog

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

llama cpp running it in google colab