{"id":10330,"date":"2026-04-17T00:48:53","date_gmt":"2026-04-17T07:48:53","guid":{"rendered":"https:\/\/www.couchbase.com\/developers\/tutorials\/ai-agent-using-google-adk-and-couchbase-mcp-server\/"},"modified":"2026-04-17T00:48:53","modified_gmt":"2026-04-17T07:48:53","slug":"ai-agent-using-google-adk-and-couchbase-mcp-server","status":"publish","type":"tutorials","link":"https:\/\/www.couchbase.com\/pt\/developers\/tutorials\/ai-agent-using-google-adk-and-couchbase-mcp-server\/","title":{"rendered":"Building an AI Agent Using Google ADK with Couchbase MCP Server"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/couchbase-examples\/mcp-cookbook\/tree\/main\/google_adk\/Google_ADK_MCP_Tutorial.ipynb\">View Source<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This notebook demonstrates how to build an intelligent AI agent using <a href=\"https:\/\/google.github.io\/adk-docs\/\">Google&#8217;s Agent Development Kit (ADK)<\/a> that can interact with a Couchbase database. The key to this interaction is the <strong>Model Context Protocol (MCP)<\/strong>, which allows the AI agent to seamlessly connect to and query Couchbase using natural language.<\/p>\n\n\n\n<h3 id=\"h-what-you-ll-build\" class=\"wp-block-heading\">What You&#8217;ll Build<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">By the end of this tutorial, you will have an AI agent that can:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Connect to a Couchbase cluster and explore its structure<\/li>\n\n\n<li>Discover buckets, scopes, collections, and document schemas<\/li>\n\n\n<li>Run SQL++ queries through natural language conversations<\/li>\n\n\n<li>Analyze query performance and get index recommendations<\/li>\n\n<\/ul>\n\n\n\n<h3 id=\"h-what-is-the-model-context-protocol-mcp\" class=\"wp-block-heading\">What is the Model Context Protocol (MCP)?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/modelcontextprotocol.io\/\">Model Context Protocol (MCP)<\/a> is an open standard that standardizes how AI assistants connect to external data sources and tools. Think of it as a <strong>universal adapter<\/strong> between AI models and the systems they need to interact with.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How MCP Works:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>MCP Server<\/strong> \u2014 A lightweight program that exposes tools from an external system (in our case, Couchbase). The <a href=\"https:\/\/mcp-server.couchbase.com\">Couchbase MCP Server<\/a> provides tools for querying, exploring schemas, checking cluster health, and more.<\/li>\n\n\n<li><strong>MCP Client<\/strong> \u2014 An application that connects to the MCP server and makes its tools available to an AI model. Google ADK&#8217;s <code>McpToolset<\/code> acts as the MCP client in this tutorial.<\/li>\n\n\n<li><strong>Communication<\/strong> \u2014 The client and server communicate over <strong>stdio<\/strong> (standard input\/output) when running locally. The MCP server runs as a subprocess, and ADK handles all the communication automatically.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This architecture means your agent doesn&#8217;t need the Couchbase SDK installed \u2014 the MCP server handles all database communication behind the scenes.<\/p>\n\n\n\n<h3 id=\"h-what-is-google-adk\" class=\"wp-block-heading\">What is Google ADK?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/google.github.io\/adk-docs\/\">Google&#8217;s Agent Development Kit (ADK)<\/a> is a framework for building AI agents powered by Gemini models. It provides:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>LlmAgent<\/strong> \u2014 The core agent class that takes user queries, decides which tools to call, and generates natural language responses.<\/li>\n\n\n<li><strong>McpToolset<\/strong> \u2014 A toolset that connects to any MCP server, automatically discovering all available tools.<\/li>\n\n\n<li><strong>Runner<\/strong> \u2014 Manages the agent&#8217;s execution loop, handling the back-and-forth between the LLM and tools.<\/li>\n\n\n<li><strong>Built-in Web UI<\/strong> \u2014 A local web interface for testing agents interactively.<\/li>\n\n<\/ul>\n\n\n\n<h3 id=\"h-get-credentials-for-google-gemini\" class=\"wp-block-heading\">Get Credentials for Google Gemini<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You&#8217;ll need a Google Gemini API key to power the AI agent. Get one for free from <a href=\"https:\/\/aistudio.google.com\/\">Google AI Studio<\/a>.<\/p>\n\n\n\n<h3 id=\"h-create-and-deploy-your-free-tier-operational-cluster-on-capella\" class=\"wp-block-heading\">Create and Deploy Your Free Tier Operational Cluster on Capella<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To get started with Couchbase Capella, create an account and use it to deploy a forever free tier operational cluster. This account provides you with an environment where you can explore and learn about Capella with no time constraint.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To learn more, please follow the <a href=\"https:\/\/docs.couchbase.com\/cloud\/get-started\/create-account.html\">instructions<\/a>.<\/p>\n\n\n\n<h4 id=\"h-couchbase-capella-configuration\" class=\"wp-block-heading\">Couchbase Capella Configuration<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">When running Couchbase using <a href=\"https:\/\/cloud.couchbase.com\/sign-in\">Capella<\/a>, the following prerequisites need to be met:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create the <a href=\"https:\/\/docs.couchbase.com\/cloud\/clusters\/manage-database-users.html\">database credentials<\/a> to access the required bucket (Read and Write) used in the application.<\/li>\n\n\n<li><a href=\"https:\/\/docs.couchbase.com\/cloud\/clusters\/allow-ip-address.html\">Allow access<\/a> to the Cluster from the IP on which the application is running.<\/li>\n\n\n<li>Your Capella free-tier account includes a <code>travel-sample<\/code> bucket, with sample documents used for booking and travel purposes. You can find more information <a href=\"https:\/\/docs.couchbase.com\/cloud\/get-started\/run-first-queries.html\">here<\/a>.<\/li>\n\n<\/ul>\n\n\n\n<h3 id=\"h-setup-instructions\" class=\"wp-block-heading\">Setup Instructions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before running this notebook, ensure you have the following prerequisites met:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<p><strong>Set Environment Variables:<\/strong> This notebook loads the Gemini API key and Couchbase credentials from a <code>.env<\/code> file. Include the following:<\/p>\n<pre><code>GOOGLE_GENAI_API_KEY=your_gemini_api_key_here\nCB_CONNECTION_STRING=your_couchbase_connection_string\nCB_USERNAME=your_couchbase_username\nCB_PASSWORD=your_couchbase_password\n<\/code><\/pre>\n<p>We have already included a <code>.env.sample<\/code> file. Rename it to <code>.env<\/code> and fill in the values.<\/p>\n<\/li>\n\n\n<li>\n<p><strong>Setup uv:<\/strong> <code>uv<\/code> is a modern and fast Python package manager. We use it to run the MCP server without manual installation. Install uv from <a href=\"https:\/\/docs.astral.sh\/uv\/getting-started\/installation\/#installing-uv\">here<\/a>.<\/p>\n<\/li>\n\n\n<li>\n<p><strong>Python Libraries:<\/strong> Install the necessary libraries by running the code cell below.<\/p>\n<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>%pip install -q &#039;google-adk&gt;=1.18.0&#039; &#039;python-dotenv&gt;=1.0.0&#039;\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Note: you may need to restart the kernel to use updated packages.\n<\/code><\/pre>\n\n\n\n<h3 id=\"h-importing-libraries-and-loading-environment-variables\" class=\"wp-block-heading\">Importing Libraries and Loading Environment Variables<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s import everything we need:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>dotenv<\/code><\/strong> \u2014 Loads API keys and database credentials from a <code>.env<\/code> file so we don&#8217;t hardcode secrets.<\/li>\n\n\n<li><strong><code>LlmAgent<\/code><\/strong> \u2014 The main agent class from Google ADK. It takes a model, instructions, and tools, and handles the reasoning loop.<\/li>\n\n\n<li><strong><code>Runner<\/code><\/strong> \u2014 Executes the agent, managing the conversation flow and tool calls.<\/li>\n\n\n<li><strong><code>InMemorySessionService<\/code><\/strong> \u2014 Stores conversation history in memory (for this tutorial; production apps would use persistent storage).<\/li>\n\n\n<li><strong><code>McpToolset<\/code> and <code>StdioConnectionParams<\/code><\/strong> \u2014 Connect to the Couchbase MCP Server over stdio.<\/li>\n\n\n<li><strong><code>StdioServerParameters<\/code><\/strong> \u2014 Configures how the MCP server subprocess is launched.<\/li>\n\n\n<li><strong><code>types<\/code><\/strong> \u2014 Google GenAI types for constructing messages.<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>import os\nimport logging\nimport warnings\n\nfrom dotenv import load_dotenv\nfrom google.adk.agents.llm_agent import LlmAgent\nfrom google.adk.runners import Runner\nfrom google.adk.sessions import InMemorySessionService\nfrom google.adk.tools.mcp_tool import McpToolset, StdioConnectionParams\nfrom google.genai import types\nfrom mcp import StdioServerParameters\n\n# Suppress noisy logs from MCP subprocess and SDK internals\nlogging.getLogger(&quot;couchbase&quot;).setLevel(logging.ERROR)\nlogging.getLogger(&quot;mcp&quot;).setLevel(logging.ERROR)\nlogging.getLogger(&quot;google.genai&quot;).setLevel(logging.ERROR)\n# The google-genai SDK emits &quot;non-text parts in the response&quot; via this\n# logger (underscore, not dot) when the ADK runner accesses .text on a\n# multi-part response containing function_call parts. See:\n# https:\/\/github.com\/googleapis\/python-genai\/issues\/850\nlogging.getLogger(&quot;google_genai.types&quot;).setLevel(logging.ERROR)\nwarnings.filterwarnings(&quot;ignore&quot;)\n\n# Ensure common tool paths are in PATH (Jupyter kernels often have a\n# restricted PATH that doesn&#039;t include ~\/.local\/bin where uv\/uvx lives)\n_extra_paths = os.path.expanduser(&quot;~\/.local\/bin&quot;) + &quot;:\/opt\/homebrew\/bin:\/usr\/local\/bin&quot;\nos.environ[&quot;PATH&quot;] = os.environ.get(&quot;PATH&quot;, &quot;\/usr\/bin&quot;) + &quot;:&quot; + _extra_paths\n\n# Load environment variables from .env file\nload_dotenv()\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>True\n<\/code><\/pre>\n\n\n\n<h3 id=\"h-loading-couchbase-credentials\" class=\"wp-block-heading\">Loading Couchbase Credentials<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We read the Couchbase connection details from environment variables. These will be passed to the MCP server so it can connect to your cluster.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Important:<\/strong> Environment variables loaded via <code>dotenv<\/code> in this notebook do NOT automatically propagate to the MCP server subprocess. That&#8217;s why we read them here and explicitly pass them in the <code>env<\/code> dict when configuring the MCP connection later.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>CB_CONNECTION_STRING = os.getenv(&quot;CB_CONNECTION_STRING&quot;)\nCB_USERNAME = os.getenv(&quot;CB_USERNAME&quot;)\nCB_PASSWORD = os.getenv(&quot;CB_PASSWORD&quot;)\nGOOGLE_API_KEY = os.getenv(&quot;GOOGLE_API_KEY&quot;) or os.getenv(&quot;GOOGLE_GENAI_API_KEY&quot;)\n\n# Verify credentials are loaded\nif not all([CB_CONNECTION_STRING, CB_USERNAME, CB_PASSWORD]):\n    raise ValueError(\n        &quot;Missing Couchbase credentials. Please create a .env file with &quot;\n        &quot;CB_CONNECTION_STRING, CB_USERNAME, CB_PASSWORD&quot;\n    )\nif not GOOGLE_API_KEY:\n    raise ValueError(\n        &quot;Missing Gemini API key. Set GOOGLE_API_KEY or GOOGLE_GENAI_API_KEY &quot;\n        &quot;in your .env file. Get one at https:\/\/aistudio.google.com\/&quot;\n    )\n\nprint(f&quot;Connection String: {CB_CONNECTION_STRING}&quot;)\nprint(f&quot;Username: {CB_USERNAME}&quot;)\nprint(&quot;Password: ****&quot;)\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Connection String: couchbase:\/\/127.0.0.1\nUsername: kaustav\nPassword: ****\n<\/code><\/pre>\n\n\n\n<h3 id=\"h-defining-the-system-prompt\" class=\"wp-block-heading\">Defining the System Prompt<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The system prompt is a crucial piece of instruction given to the LLM that powers our agent. It tells the model:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>What it is<\/strong> \u2014 A read-only Couchbase database assistant<\/li>\n\n\n<li><strong>How to discover data<\/strong> \u2014 Use the schema and discovery tools first, don&#8217;t guess field names<\/li>\n\n\n<li><strong>How to query<\/strong> \u2014 SQL++ syntax rules specific to Couchbase (bare collection names in FROM, UNNEST for arrays)<\/li>\n\n\n<li><strong>How to handle errors<\/strong> \u2014 Retry on failures, don&#8217;t assume empty results mean no data<\/li>\n\n\n<li><strong>How to handle data quirks<\/strong> \u2014 Price fields are strings, not numbers<\/li>\n\n\n<li><strong>What NOT to do<\/strong> \u2014 Never answer from training data; always run a real query first<\/li>\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">A well-crafted system prompt is the difference between an agent that generates correct SQL++ queries and one that hallucinates results. The key design principles here are <strong>discovery-first<\/strong> (use schema tools before guessing) and <strong>grounding<\/strong> (every claim must be backed by a query result).<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>system_prompt = &quot;&quot;&quot;You are a Couchbase database assistant. You have READ-ONLY\naccess to a Couchbase cluster via the provided MCP tools. You cannot run\nINSERT\/UPDATE\/DELETE\/UPSERT or any data-modifying operations. If a user\nasks you to modify, delete, or write data, explain that you have read-only\naccess and offer to help them write the query they could run themselves.\n\n# Discovery first\nUse the discovery tools whenever you need to know what data exists or what\nshape a document has. Prefer them over guessing field names from memory:\n- `get_buckets_in_cluster` \u2014 list available buckets\n- `get_scopes_and_collections_in_bucket` \u2014 list scopes and collections\n- `get_schema_for_collection` \u2014 sample the JSON schema of a collection\n- `list_indexes` \u2014 see which fields are indexed (helps you write efficient\n  queries; queries on non-indexed fields fall back to a primary scan)\n\nWhen asked to *describe* the database or its contents (e.g. &quot;tell me about\nthe database&quot;), start with `get_buckets_in_cluster` and then\n`get_scopes_and_collections_in_bucket` so the answer actually lists buckets\nand collections \u2014 not just server config.\n\nYou are connected to the `travel-sample` bucket. Most analytical data lives\nunder the `inventory` scope.\n\nRule of thumb: the FIRST time you query a collection in a conversation,\ncall `get_schema_for_collection` on it before writing the query \u2014 even if\nyou think you know the field names. Couchbase document schemas are\ndataset-specific and intuitive guesses (`hotelname` vs `name`, `source`\nvs `sourceairport`, `rating` vs `ratings.Overall`) are often wrong.\nCached schema knowledge from earlier in the same conversation is fine to\nreuse.\n\n# Querying with SQL++\nRun SQL++ via `run_sql_plus_plus_query`. Always pass `bucket_name` and\n`scope_name` so the scope context is set, then use bare collection names in\nthe FROM clause:\n    FROM hotel h                       (correct)\n    FROM `travel-sample`.`inventory`.`hotel` h   (wrong \u2014 produces an\n                                                  ambiguous-reference error\n                                                  when the scope is already set)\nWrap any identifier that is also a SQL++ reserved word in backticks. For\naggregations over array fields, flatten the array with UNNEST first, then\nGROUP BY the parent field.\n\n# Error and empty-result handling\n- If a query errors, read the message, fix the obvious issue (wrong field\n  name, missing UNNEST, reserved word), and retry once. If it still fails,\n  report the error to the user concisely instead of looping.\n- If a query returns zero rows, do NOT immediately conclude &quot;no such data\n  exists.&quot; Zero rows is the #1 source of false-negative answers \u2014 your\n  query was probably wrong, not the database. When the question is about\n  entities that obviously exist in real life (countries, airlines, cities,\n  airports, etc.), ALWAYS take at least one of these actions before\n  reporting empty results:\n  1. Reconsider whether you queried the right collection. The field you\n     filtered on (e.g. `country`) may live on a different collection\n     (e.g. `airline.country`, not `route.country`).\n  2. Call `get_schema_for_collection` to verify the field name and the\n     format of sample values.\n  3. Drop the most restrictive predicate and retry, or relax string\n     comparisons (e.g. `LOWER(country) = &quot;france&quot;`).\n  Only report &quot;no data&quot; after at least one such retry.\n\n# Data quirks in this dataset\n- The `price` field on `hotel` and `landmark` is stored as a free-form\n  STRING in mixed currencies and formats \u2014 ranges, &quot;From \u00a350&quot;, &quot;Free&quot;,\n  weekly rates, or null \u2014 NOT a number. Numeric comparisons like\n  `WHERE price &lt; 200` will return zero rows. For budget questions on\n  price, retrieve the raw rows (filtering with `IS NOT NULL` if\n  appropriate) and parse the strings in your final response.\n  This warning applies ONLY to the `price` field. All other numeric\n  fields in this dataset (review ratings, route distances, counts,\n  geo coordinates, etc.) are stored as proper numbers and CAN be\n  filtered, sorted, and aggregated with normal SQL++ operators\n  (SUM, AVG, ORDER BY, comparison operators).\n- Many optional fields are null in a large fraction of documents. Use\n  `IS NOT NULL` filters when a field must be present for your answer to\n  make sense, and do not assume a field is universally populated until\n  you have checked the schema.\n\n# Hallucination guard \u2014 read this carefully\nBefore producing any answer that mentions specific data values (names,\nprices, addresses, schedules, counts, places, dates), you MUST have at\nleast one successful `run_sql_plus_plus_query` call in your tool history\nfor the current question. Schema discovery alone is NOT sufficient:\n`get_schema_for_collection` returns the SHAPE of documents (field names\nand types), not the data itself. If you have only called schema or\ndiscovery tools and have not yet run an actual query, do NOT write the\nanswer \u2014 run the query first, then answer from its rows.\n\nIf a schema sample shows that a field is mostly null, or that a collection\nlooks sparse, that is NOT a reason to skip the query. Run it anyway and\nreport what you actually found \u2014 even if the result is &quot;0 rows match&quot; or\n&quot;prices are mostly null.&quot; Never substitute training-data knowledge (real\nhotel names, real landmark prices, real airline schedules) for a missing\nquery result. The user is asking about the database, not about the world.\n\n# Answering style\n- Ground every claim in data you actually retrieved from a tool call. Do\n  not invent prices, names, counts, or schedules.\n- For list or recommendation questions (&quot;show me hotels in X&quot;, &quot;recommend\n  places to visit&quot;), aim for roughly 8-15 results by default \u2014 enough to\n  feel useful, not so many you bury the answer. If a query naturally\n  returns far more, summarize: pick the most relevant subset, group by a\n  useful attribute (city, country, airline, etc.), and offer to expand.\n- Ask one short clarifying question only when a request is genuinely\n  ambiguous (e.g. multiple plausible cities or countries). For routine\n  intents, make a sensible default choice and explain it briefly in your\n  answer.\n&quot;&quot;&quot;\n<\/code><\/pre>\n\n\n\n<h3 id=\"h-creating-the-agent\" class=\"wp-block-heading\">Creating the Agent<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now we create the AI agent. This is where everything comes together:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>model=\"gemini-2.5-flash\"<\/code><\/strong> \u2014 The Gemini model that powers the agent&#8217;s reasoning. <code>gemini-2.5-flash<\/code> handles the multi-step reasoning and conversational follow-ups in this tutorial reliably and is the recommended default. The free tier allows 250 requests\/day, which is plenty for tutorial use. If you hit that limit while iterating, you can swap in <code>gemini-2.5-flash-lite<\/code> (1000 requests\/day, but may struggle with the more open-ended questions) or, for maximum reasoning quality, <code>gemini-2.5-pro<\/code>. All three are drop-in replacements.<\/li>\n\n\n<li><strong><code>instruction=system_prompt<\/code><\/strong> \u2014 The system prompt we defined above, which tells the agent how to behave.<\/li>\n\n\n<li><strong><code>tools=[McpToolset(...)]<\/code><\/strong> \u2014 The connection to the Couchbase MCP Server. Let&#8217;s break down this configuration:\n<ul>\n<li><code>command=\"uvx\"<\/code> and <code>args=[\"couchbase-mcp-server\"]<\/code> \u2014 Launches the MCP server using <code>uv<\/code>. This automatically downloads and runs the server without manual installation.<\/li>\n<li><code>env={...}<\/code> \u2014 Passes Couchbase credentials to the MCP server subprocess. This is required because the subprocess doesn&#8217;t inherit environment variables from <code>dotenv<\/code>.<\/li>\n<li><code>CB_MCP_READ_ONLY_MODE=\"true\"<\/code> \u2014 Restricts the server to read-only operations, preventing accidental data modifications. Set to <code>\"false\"<\/code> if you need write access.<\/li>\n<li><code>timeout=60<\/code> \u2014 Allows up to 60 seconds for the MCP server to start.<\/li>\n<\/ul>\n<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>root_agent = LlmAgent(\n    model=&quot;gemini-2.5-flash&quot;,\n    name=&quot;couchbase_agent&quot;,\n    description=(\n        &quot;An agent that interacts with Couchbase databases using the &quot;\n        &quot;Couchbase MCP server.&quot;\n    ),\n    instruction=system_prompt,\n    tools=[\n        McpToolset(\n            connection_params=StdioConnectionParams(\n                server_params=StdioServerParameters(\n                    command=&quot;uvx&quot;,\n                    args=[&quot;couchbase-mcp-server&quot;],\n                    env={\n                        &quot;PATH&quot;: os.environ.get(&quot;PATH&quot;, &quot;\/usr\/bin&quot;),\n                        &quot;CB_CONNECTION_STRING&quot;: CB_CONNECTION_STRING,\n                        &quot;CB_USERNAME&quot;: CB_USERNAME,\n                        &quot;CB_PASSWORD&quot;: CB_PASSWORD,\n                        &quot;CB_MCP_READ_ONLY_MODE&quot;: &quot;true&quot;,\n                    },\n                ),\n                timeout=60,\n            ),\n        )\n    ],\n)\n\nprint(&quot;Agent created successfully!&quot;)\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Agent created successfully!\n<\/code><\/pre>\n\n\n\n<h3 id=\"h-defining-the-helper-function\" class=\"wp-block-heading\">Defining the Helper Function<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We need a helper function to send questions to the agent and collect responses. Here&#8217;s how it works:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong><code>Runner<\/code><\/strong> manages the agent&#8217;s execution. It sends the user&#8217;s message to the agent, which then decides what tools to call.<\/li>\n\n\n<li><strong><code>InMemorySessionService<\/code><\/strong> keeps track of the conversation history so the agent can reference previous messages.<\/li>\n\n\n<li>The agent returns a stream of <strong>events<\/strong> \u2014 we collect only the final response text.<\/li>\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>ask_agent<\/code> function below wraps all of this into a simple interface: pass in a question, get back the agent&#8217;s answer.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>import asyncio\nfrom google.genai import errors as genai_errors\n\n# Set up the session and runner (shared across all questions)\nsession_service = InMemorySessionService()\nrunner = Runner(\n    agent=root_agent,\n    app_name=&quot;couchbase_agent&quot;,\n    session_service=session_service,\n)\n\n\nasync def ask_agent(question: str, session_id: str) -&gt; str:\n    &quot;&quot;&quot;Send a question to the agent. Retries on transient Gemini errors.&quot;&quot;&quot;\n    for attempt in range(4):\n        try:\n            response = &quot;&quot;\n            async for event in runner.run_async(\n                session_id=session_id,\n                user_id=&quot;tutorial_user&quot;,\n                new_message=types.Content(\n                    role=&quot;user&quot;,\n                    parts=[types.Part(text=question)],\n                ),\n            ):\n                if event.is_final_response() and event.content and event.content.parts:\n                    for part in event.content.parts:\n                        if part.text:\n                            response += part.text\n            return response\n        except (genai_errors.ClientError, genai_errors.ServerError):\n            if attempt == 3:\n                raise\n            wait = 5 * (2 ** attempt)  # 5s, 10s, 20s\n            print(f&quot;  [Gemini API error, retrying in {wait}s...]&quot;)\n            await asyncio.sleep(wait)\n    return &quot;&quot;\n\n\nprint(&quot;Helper function ready!&quot;)\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Helper function ready!\n<\/code><\/pre>\n\n\n\n<h3 id=\"h-running-the-agent\" class=\"wp-block-heading\">Running the Agent<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s put our agent to work! We&#8217;ll ask it a series of questions that demonstrate different capabilities:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Database exploration<\/strong> \u2014 Understanding what data is available<\/li>\n\n\n<li><strong>SQL++ aggregation queries<\/strong> \u2014 Complex queries with array operations<\/li>\n\n\n<li><strong>Multi-step reasoning<\/strong> \u2014 Finding flights AND hotels in one question<\/li>\n\n\n<li><strong>Sightseeing recommendations<\/strong> \u2014 Querying the landmarks collection<\/li>\n\n\n<li><strong>Budget-based filtering<\/strong> \u2014 Combining price filters with ratings<\/li>\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Each question triggers the agent to:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Analyze the question and decide which MCP tools to call<\/li>\n\n\n<li>Call the appropriate tools (e.g., <code>get_scopes_and_collections_in_bucket<\/code>, <code>run_sql_plus_plus_query<\/code>)<\/li>\n\n\n<li>Process the results from Couchbase<\/li>\n\n\n<li>Generate a natural language answer<\/li>\n\n<\/ol>\n\n\n\n<h4 id=\"h-question-1-tell-me-about-the-database\" class=\"wp-block-heading\">Question 1: Tell me about the database<\/h4>\n\n\n\n<pre class=\"wp-block-code language-python\"><code># Create a session for our conversation\nsession = await session_service.create_session(\n    app_name=&quot;couchbase_agent&quot;, user_id=&quot;tutorial_user&quot;\n)\n\nquestion = &quot;Tell me about the database that you are connected to.&quot;\nprint(f&quot;Question: {question}n&quot;)\nresponse = await ask_agent(question, session.id)\nprint(response)\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Question: Tell me about the database that you are connected to.\n\nI am connected to a Couchbase cluster with the following buckets: `beer-sample`, `gamesim-sample`, `travel-sample`, and `vector-search-testing`.\n\nWithin the `travel-sample` bucket, the following scopes and collections are available:\n\n*   **`_default` scope**: `_default` collection\n*   **`_system` scope**: `_query`, `_mobile` collections\n*   **`inventory` scope**: `airport`, `airline`, `route`, `landmark`, `hotel` collections\n*   **`tenant_agent_00` scope**: `bookings`, `users` collections\n*   **`tenant_agent_01` scope**: `users`, `bookings` collections\n*   **`tenant_agent_02` scope**: `users`, `bookings` collections\n*   **`tenant_agent_03` scope**: `users`, `bookings` collections\n*   **`tenant_agent_04` scope**: `bookings`, `users` collections\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-question-2-top-hotels-by-rating\" class=\"wp-block-heading\">Question 2: Top hotels by rating<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This question tests the agent&#8217;s ability to write SQL++ queries with array operations. It needs to use <code>UNNEST<\/code> to flatten the reviews array and aggregate ratings \u2014 a common Couchbase pattern.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>question = &quot;List out the top 5 hotels by the highest aggregate rating.&quot;\nprint(f&quot;Question: {question}n&quot;)\nresponse = await ask_agent(question, session.id)\nprint(response)\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Question: List out the top 5 hotels by the highest aggregate rating.\n\nHere are the top 5 hotels by the highest aggregate rating:\n\n1.  **ibis Birmingham Bordesley** (Average Rating: 5)\n2.  **Pitlochry Backpackers Hotel** (Average Rating: 5)\n3.  **Hotel Bijou** (Average Rating: 5)\n4.  **Culloden House Hotel** (Average Rating: 5)\n5.  **Handlery Union Square Hotel** (Average Rating: 5)\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-question-3-flight-and-hotel-recommendations\" class=\"wp-block-heading\">Question 3: Flight and hotel recommendations<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This is a multi-step question that requires the agent to query two different collections (<code>route<\/code> for flights, <code>hotel<\/code> for accommodation) and combine the results into a single recommendation.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>question = &quot;Find flights from JFK to SFO and recommend a hotel in San Francisco under $200 a night.&quot;\nprint(f&quot;Question: {question}n&quot;)\nresponse = await ask_agent(question, session.id)\nprint(response)\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Question: Find flights from JFK to SFO and recommend a hotel in San Francisco under $200 a night.\n\nHere are some hotels in San Francisco with prices that appear to be under $200 per night based on the available data:\n\n*   **Redwood Inn** (1530 Lombard St): Approximately $75-$90\n*   **Hotel Whitcomb** (1231 Market St): Approximately $89-$109\n*   **Pacific Tradewinds Backpackers** (680 Sacramento St): Approximately $26-29.50\/night\n*   **SW Hotel** (615 Broadway St): Approximately $140-$160\n*   **Hostelling International-Downtown** (312 Mason St): Dorms $27-$30, private rooms $69-$109\n*   **Greenwich Inn** (3201 Steiner St): Approximately $54-$104\n*   **Civic Center Hotel** (20 12th St): Single occupancy with a shared bath: $150\/week (this is significantly under $200\/night)\n*   **The Opal San Francisco** (1050 Van Ness Ave): Approximately $60-$110\n*   **Taylor Hotel** (615 Taylor St): Approximately $66-$90\n*   **Chancellor Hotel** (433 Powell St): Approximately $90\u2013$200\n\nPlease remember that prices can vary and the `price` field in this database is a string, so the ranges are approximate. You should verify current pricing directly with the hotel.\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-question-4-sightseeing-in-the-uk\" class=\"wp-block-heading\">Question 4: Sightseeing in the UK<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This question tests the agent&#8217;s ability to query the <code>landmark<\/code> collection and filter by country and activity type.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>question = &quot;I&#039;m going to the UK for 1 week. Recommend some great spots to visit for sightseeing. Also mention the respective prices of those places for adults and kids.&quot;\nprint(f&quot;Question: {question}n&quot;)\nresponse = await ask_agent(question, session.id)\nprint(response)\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Question: I&#039;m going to the UK for 1 week. Recommend some great spots to visit for sightseeing. Also mention the respective prices of those places for adults and kids.\n\nHere are some great sightseeing spots in the United Kingdom, along with their available price information. Please note that prices are listed as they appear in the database and may require further clarification for exact adult\/child rates where not explicitly stated:\n\n*   **Topolski Century**:\n    *   Description: A unique, monumental work by Polish artist Feliks Topolski, presenting a remarkable record of 20th-century events and figures.\n    *   Price: \u00a32 (\u00a31 concession)\n\n*   **Roxy Bar and Screen**:\n    *   Description: A bar-cinema hybrid that shows films every night except Friday and Saturday, doubling as a second-run cinema and bar.\n    *   Price: Tickets from \u00a33\n\n*   **Tate Britain**:\n    *   Description: This gallery houses the Tate collection of British art from 1500 through to contemporary art, including a collection of paintings by Turner.\n    *   Price: Free (though there is a charge for temporary exhibitions)\n\n*   **Tynemouth Castle and Priory**:\n    *   Description: A fortress and religious site perched on a rocky headland overlooking Tynemouth Pier, combining moated castle-towers, gatehouse, keep, and ruins of a Benedictine priory.\n    *   Price: Adults \u00a34.70, children \u00a32.80, concessions \u00a34.20\n\n*   **Pickering Castle**:\n    *   Description: Heritage 13th-century castle.\n    *   Price: Adults \u00a34.00, children \u00a32.40, concessions \u00a33.60\n\n*   **Portchester Castle**:\n    *   Description: One of the best preserved Roman fortifications in Northern Europe, featuring a Norman-built castle keep and extensive late Roman structures.\n    *   Price: Adults \u00a35.00, children \u00a33.00, concessions \u00a34.50\n\nOther places listed either had no price information or were not specifically &quot;sightseeing&quot; locations (e.g., a golf club, a grocer, a bar). Always double-check the latest prices and opening times before visiting.\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-question-5-budget-hotel-search\" class=\"wp-block-heading\">Question 5: Budget hotel search<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This question demonstrates conversational context \u2014 since it follows the UK sightseeing question, the agent should understand the context and search for UK hotels within the budget. We explicitly anchor the question to the UK trip to avoid ambiguity with the San Francisco hotels from Question 3.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>question = &quot;Sticking with the UK trip \u2014 what hotels in the database fit a budget of around \u00a330 a night?&quot;\nprint(f&quot;Question: {question}n&quot;)\nresponse = await ask_agent(question, session.id)\nprint(response)\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Question: Sticking with the UK trip \u2014 what hotels in the database fit a budget of around \u00a330 a night?\n\nFinding hotels in the database precisely at or around \u00a330 a night is challenging because the `price` field is a free-form string and often indicates ranges or weekly rates. However, based on the retrieved data, here are a couple of options that *might* fit your budget, especially if you consider dorms or the lower end of a price range:\n\n*   **Hilton Chambers** (Manchester):\n    *   Price: \u00a315-25 for dorms, \u00a345-70 for private rooms. (The dorm option clearly fits your budget!)\n*   **Once Brewed YHA Hostel** (Northumberland):\n    *   Price: Beds from \u00a316. (This is a hostel, but the price is well within your budget for a bed.)\n\nOther hotels listed generally start at \u00a344 or higher for a room. &quot;The Granary at Roch Mill&quot; offers &quot;From \u00a3320 per week,&quot; which could potentially average to under \u00a350 a night if you are staying for the full week, but it&#039;s not explicitly a daily rate.\n\nAlways confirm the exact prices and room types directly with the accommodation provider, as the `price` field here is descriptive and not a numerical value I can directly filter on.\n<\/code><\/pre>\n\n\n\n<h3 id=\"h-what-just-happened\" class=\"wp-block-heading\">What Just Happened?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Behind the scenes, here&#8217;s the flow for each question:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>User Question\n    \u2193\nGoogle ADK (LlmAgent)\n    \u2193 Gemini decides which tools to call\nMcpToolset \u2192 StdioConnectionParams \u2192 MCP Server subprocess\n    \u2193 Tool call (e.g., run_sql_plus_plus_query)\nCouchbase MCP Server\n    \u2193 Executes SQL++ query against Couchbase\nCouchbase Cluster (travel-sample bucket)\n    \u2193 Returns query results\nMCP Server \u2192 McpToolset \u2192 LlmAgent\n    \u2193 Gemini formats results into natural language\nAgent Response\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The agent automatically:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Parsed your natural language question<\/li>\n\n\n<li>Decided which Couchbase MCP tools to call<\/li>\n\n\n<li>Generated correct SQL++ queries<\/li>\n\n\n<li>Executed them against your live database<\/li>\n\n\n<li>Formatted the results into a readable answer<\/li>\n\n<\/ol>\n\n\n\n<h3 id=\"h-next-steps\" class=\"wp-block-heading\">Next Steps<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Try your own questions<\/strong> \u2014 Modify the question strings above and re-run the cells<\/li>\n\n\n<li><strong>Enable write operations<\/strong> \u2014 Set <code>CB_MCP_READ_ONLY_MODE<\/code> to <code>\"false\"<\/code> to allow document inserts, updates, and deletes<\/li>\n\n\n<li><strong>Use the ADK Web UI<\/strong> \u2014 Run <code>adk web<\/code> from the command line to get an interactive chat interface<\/li>\n\n\n<li><strong>Explore the full tool list<\/strong> \u2014 The Couchbase MCP Server provides 19+ tools for cluster management, schema discovery, querying, and performance analysis. See the <a href=\"https:\/\/mcp-server.couchbase.com\">full documentation<\/a><\/li>\n\n\n<li><strong>Check out the ADK integration page<\/strong> \u2014 <a href=\"https:\/\/google.github.io\/adk-docs\/integrations\/couchbase\/\">Google ADK Couchbase Integration<\/a> for more configuration options<\/li>\n\n<\/ul>\n\n\n\n<h3 id=\"h-additional-resources\" class=\"wp-block-heading\">Additional Resources<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/mcp-server.couchbase.com\">Couchbase MCP Server Documentation<\/a><\/li>\n\n\n<li><a href=\"https:\/\/github.com\/Couchbase-Ecosystem\/mcp-server-couchbase\">Couchbase MCP Server Repository<\/a><\/li>\n\n\n<li><a href=\"https:\/\/google.github.io\/adk-docs\/\">Google ADK Documentation<\/a><\/li>\n\n\n<li><a href=\"https:\/\/modelcontextprotocol.io\/\">Model Context Protocol<\/a><\/li>\n\n\n<li><a href=\"https:\/\/docs.couchbase.com\/\">Couchbase Documentation<\/a><\/li>\n\n\n<li><a href=\"https:\/\/cloud.couchbase.com\/\">Couchbase Capella Free Tier<\/a><\/li>\n\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>View Source This notebook demonstrates how to build an intelligent AI agent using Google&#8217;s Agent Development Kit (ADK) that can interact with a Couchbase database. The key to this interaction is the Model Context Protocol (MCP), which allows the AI agent to seamlessly connect to and query Couchbase using natural language. What You&#8217;ll Build By [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false,"_acf":"","inline_featured_image":false,"footnotes":""},"tutorial-languages":[606],"tutorial-tags":[607,633,630,574],"tutorial-technologies":[631],"tutorial-types":[555],"class_list":["post-10330","tutorials","type-tutorials","status-publish","hentry","tutorial-languages-python","tutorial-tags-artificial-intelligence","tutorial-tags-google-adk","tutorial-tags-model-context-protocol-mcp","tutorial-tags-sql-n1ql","tutorial-technologies-model-context-protocol-mcp","tutorial-types-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.9 (Yoast SEO v28.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Building an AI Agent Using Google ADK with Couchbase MCP Server - Couchbase<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/pt\/developers\/tutorials\/ai-agent-using-google-adk-and-couchbase-mcp-server\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building an AI Agent Using Google ADK with Couchbase MCP Server\" \/>\n<meta property=\"og:description\" content=\"View Source This notebook demonstrates how to build an intelligent AI agent using Google&#8217;s Agent Development Kit (ADK) that can interact with a Couchbase database. The key to this interaction is the Model Context Protocol (MCP), which allows the AI agent to seamlessly connect to and query Couchbase using natural language. What You&#8217;ll Build By [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/pt\/developers\/tutorials\/ai-agent-using-google-adk-and-couchbase-mcp-server\/\" \/>\n<meta property=\"og:site_name\" content=\"Couchbase\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Couchbase\/\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/10\/Cloud-2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2548\" \/>\n\t<meta property=\"og:image:height\" content=\"1171\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@couchbase\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"21 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/developers\\\/tutorials\\\/ai-agent-using-google-adk-and-couchbase-mcp-server\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/developers\\\/tutorials\\\/ai-agent-using-google-adk-and-couchbase-mcp-server\\\/\",\"name\":\"Building an AI Agent Using Google ADK with Couchbase MCP Server - Couchbase\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/#website\"},\"datePublished\":\"2026-04-17T07:48:53+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/developers\\\/tutorials\\\/ai-agent-using-google-adk-and-couchbase-mcp-server\\\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/developers\\\/tutorials\\\/ai-agent-using-google-adk-and-couchbase-mcp-server\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/developers\\\/tutorials\\\/ai-agent-using-google-adk-and-couchbase-mcp-server\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/ko\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building an AI Agent Using Google ADK with Couchbase MCP Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/\",\"name\":\"Couchbase\",\"description\":\"The Operational Data Platform for AI\u2122\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/#organization\"},\"alternateName\":\"Couchbase, Inc.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/#organization\",\"name\":\"Couchbase\",\"alternateName\":\"Couchbase, Inc.\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Couchbase_Logo_Couchbase_Token_Red-1.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Couchbase_Logo_Couchbase_Token_Red-1.png\",\"width\":1129,\"height\":1129,\"caption\":\"Couchbase\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/pt\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Couchbase\\\/\",\"https:\\\/\\\/x.com\\\/couchbase\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/CouchbaseServer\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/couchbase\\\/\",\"https:\\\/\\\/github.com\\\/couchbase\\\/\",\"https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Couchbase,_Inc.\"],\"description\":\"Couchbase is a database software company headquartered in San Jose, California, providing an operational data platform for AI used by hundreds of global enterprises.\",\"legalName\":\"Couchbase, Inc.\",\"foundingDate\":\"2011-01-01\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Building an AI Agent Using Google ADK with Couchbase MCP Server - Couchbase","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/pt\/developers\/tutorials\/ai-agent-using-google-adk-and-couchbase-mcp-server\/","og_locale":"pt_BR","og_type":"article","og_title":"Building an AI Agent Using Google ADK with Couchbase MCP Server","og_description":"View Source This notebook demonstrates how to build an intelligent AI agent using Google&#8217;s Agent Development Kit (ADK) that can interact with a Couchbase database. The key to this interaction is the Model Context Protocol (MCP), which allows the AI agent to seamlessly connect to and query Couchbase using natural language. What You&#8217;ll Build By [&hellip;]","og_url":"https:\/\/www.couchbase.com\/pt\/developers\/tutorials\/ai-agent-using-google-adk-and-couchbase-mcp-server\/","og_site_name":"Couchbase","article_publisher":"https:\/\/www.facebook.com\/Couchbase\/","og_image":[{"width":2548,"height":1171,"url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/10\/Cloud-2.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@couchbase","twitter_misc":{"Est. reading time":"21 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/pt\/developers\/tutorials\/ai-agent-using-google-adk-and-couchbase-mcp-server\/","url":"https:\/\/www.couchbase.com\/pt\/developers\/tutorials\/ai-agent-using-google-adk-and-couchbase-mcp-server\/","name":"Building an AI Agent Using Google ADK with Couchbase MCP Server - Couchbase","isPartOf":{"@id":"https:\/\/www.couchbase.com\/pt\/#website"},"datePublished":"2026-04-17T07:48:53+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/pt\/developers\/tutorials\/ai-agent-using-google-adk-and-couchbase-mcp-server\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/pt\/developers\/tutorials\/ai-agent-using-google-adk-and-couchbase-mcp-server\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/pt\/developers\/tutorials\/ai-agent-using-google-adk-and-couchbase-mcp-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/ko\/"},{"@type":"ListItem","position":2,"name":"Building an AI Agent Using Google ADK with Couchbase MCP Server"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/pt\/#website","url":"https:\/\/www.couchbase.com\/pt\/","name":"Couchbase","description":"The Operational Data Platform for AI\u2122","publisher":{"@id":"https:\/\/www.couchbase.com\/pt\/#organization"},"alternateName":"Couchbase, Inc.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/pt\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-BR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/pt\/#organization","name":"Couchbase","alternateName":"Couchbase, Inc.","url":"https:\/\/www.couchbase.com\/pt\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/pt\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Couchbase_Logo_Couchbase_Token_Red-1.png","contentUrl":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Couchbase_Logo_Couchbase_Token_Red-1.png","width":1129,"height":1129,"caption":"Couchbase"},"image":{"@id":"https:\/\/www.couchbase.com\/pt\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Couchbase\/","https:\/\/x.com\/couchbase","https:\/\/www.youtube.com\/c\/CouchbaseServer","https:\/\/www.linkedin.com\/company\/couchbase\/","https:\/\/github.com\/couchbase\/","https:\/\/en.wikipedia.org\/wiki\/Couchbase,_Inc."],"description":"A Couchbase \u00e9 uma empresa de software de banco de dados com sede em San Jose, Calif\u00f3rnia, que fornece uma plataforma de dados operacional para a intelig\u00eancia artificial utilizada por centenas de empresas globais.","legalName":"Couchbase, Inc.","foundingDate":"2011-01-01"}]}},"permalink_manager":null,"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/pt\/wp-json\/wp\/v2\/tutorials\/10330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/pt\/wp-json\/wp\/v2\/tutorials"}],"about":[{"href":"https:\/\/www.couchbase.com\/pt\/wp-json\/wp\/v2\/types\/tutorials"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/pt\/wp-json\/wp\/v2\/tutorials\/10330\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/pt\/wp-json\/wp\/v2\/media?parent=10330"}],"wp:term":[{"taxonomy":"tutorial-languages","embeddable":true,"href":"https:\/\/www.couchbase.com\/pt\/wp-json\/wp\/v2\/tutorial-languages?post=10330"},{"taxonomy":"tutorial-tags","embeddable":true,"href":"https:\/\/www.couchbase.com\/pt\/wp-json\/wp\/v2\/tutorial-tags?post=10330"},{"taxonomy":"tutorial-technologies","embeddable":true,"href":"https:\/\/www.couchbase.com\/pt\/wp-json\/wp\/v2\/tutorial-technologies?post=10330"},{"taxonomy":"tutorial-types","embeddable":true,"href":"https:\/\/www.couchbase.com\/pt\/wp-json\/wp\/v2\/tutorial-types?post=10330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}