Skip to content

tutorial: Add Google ADK with Couchbase MCP Server#3

Merged
teetangh merged 7 commits into
mainfrom
tutorial/google-adk-couchbase-mcp
Apr 17, 2026
Merged

tutorial: Add Google ADK with Couchbase MCP Server#3
teetangh merged 7 commits into
mainfrom
tutorial/google-adk-couchbase-mcp

Conversation

@teetangh

Copy link
Copy Markdown
Contributor

Summary

Adds a new tutorial for building an AI agent using Google's Agent Development Kit (ADK) and the Couchbase MCP Server, following the same pattern as the existing langchain_mcp_adapter and openai_agents tutorials.

This accompanies the Couchbase integration page recently merged into Google's ADK docs (google/adk-docs#1475).

What's included

  • google_adk/test_agent.py — Agent script that connects to Couchbase via MCP, tested against travel-sample bucket
  • google_adk/frontmatter.md — Frontmatter for the developer portal
  • google_adk/.env.sample — Environment variable template

What it does

  • Connects a Gemini-powered ADK agent to Couchbase via the MCP Server (uvx couchbase-mcp-server)
  • Explores cluster health, buckets, scopes, collections, and schemas
  • Runs SQL++ queries through natural language
  • Supports read-only mode, mTLS auth, and tool disabling configuration

Still to come

  • Jupyter notebook (converting the test script into notebook cells with markdown explanations)

Test plan

  • Agent successfully connects to local Couchbase and queries travel-sample data
  • Tool calls verified — MCP tools are called with real database responses (not hallucinated)
  • Jupyter notebook execution end-to-end
  • Frontmatter validation against developer portal schema

Add agent script and frontmatter for building an AI agent using
Google's Agent Development Kit (ADK) with the Couchbase MCP Server.
Jupyter notebook to follow.
@github-actions

github-actions Bot commented Mar 31, 2026

Copy link
Copy Markdown

Caution

Notebooks or Frontmatter Files Have Been Modified

  • Please ensure that a frontmatter.md file is accompanying the notebook file, and that the frontmatter is up to date.
  • These changes will be published to the developer portal tutorials only if frontmatter.md is included.
  • Proofread all changes before merging, as changes to notebook and frontmatter content will update the developer tutorial.

1 Notebook Files Modified:

Notebook File Frontmatter Included?
google_adk/Google_ADK_MCP_Tutorial.ipynb

1 Frontmatter Files Modified:

Frontmatter File
google_adk/frontmatter.md
Note: frontmatter will be checked and tested in the Test Frontmatter workflow.

@teetangh teetangh self-assigned this Mar 31, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a tutorial and a test script for building an AI agent using Google's Agent Development Kit (ADK) and a Couchbase MCP server. The changes include a sample environment file, tutorial metadata, and a Python script to verify the agent's functionality. Review feedback identifies several critical issues: the CB_BUCKET_NAME and GOOGLE_GENAI_API_KEY environment variables are missing from the loading, validation, and MCP server configuration logic. Additionally, the model identifier gemini-2.5-flash is invalid and must be updated to a supported version such as gemini-1.5-flash to prevent initialization errors.

Comment thread google_adk/test_flash_agent.py Outdated
Comment thread google_adk/test_flash_agent.py Outdated
Comment thread google_adk/test_agent.py Outdated
Comment thread google_adk/test_flash_agent.py Outdated
Comment thread google_adk/.env.sample
Adds an interactive notebook with step-by-step tutorial covering:
- MCP and Google ADK concepts for beginners
- Agent setup with Couchbase MCP Server
- 5 example queries (data exploration, SQL++ aggregation, flight/hotel
  recommendations, sightseeing, budget search)
…flash

A/B testing showed gemini-2.5-flash-lite refused to use the landmark
collection for the UK sightseeing question and lost conversational
context on the budget hotel follow-up. Switch the agent default to
gemini-2.5-flash and tighten the system prompt with a schema cheatsheet
plus concrete query templates so the agent reliably handles all five
notebook questions.

Also add test_flash_agent.py and test_flash_lite_agent.py covering all
five notebook questions, replacing the older three-question test_agent.py.
The slim ask_agent helper now retries on transient 429/503 responses
from the Gemini API.

@nithishr nithishr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have failing checks as well

Comment thread google_adk/test_flash_lite_agent.py Outdated
Comment thread google_adk/test_flash_agent.py Outdated
Comment thread google_adk/Google_ADK_MCP_Tutorial.ipynb
- Port iteration-6 production-grade prompt: discovery-first, hallucination
  guard, error recovery, read-only awareness, price-string handling. Removes
  the test_cluster_connection workaround (fixed in couchbase-mcp-server 0.7.1).
- Add CB_BUCKET_NAME to env loading, validation, MCP config, and .env.sample.
- Add GOOGLE_API_KEY / GOOGLE_GENAI_API_KEY explicit validation.
- Suppress the google-genai SDK "non-text parts in the response" warning
  via logging.getLogger("google_genai.types").setLevel(logging.ERROR).
- Fix Jupyter kernel PATH issue: augment os.environ["PATH"] with
  ~/.local/bin and /opt/homebrew/bin so the uvx subprocess can be found.
- Update documentation links to mcp-server.couchbase.com.
- Add mcp-server.couchbase.com to Additional Resources.
- Reword Q5 to explicitly anchor to the UK trip context.
- Clear all cell outputs for a clean re-run.
- Update test_flash_agent.py with the same prompt and 0.7.1 fix notes.
@teetangh

teetangh commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

Hey @nithishr, pushed all review fixes in 44384e7:

  1. ✅ Removed test_cluster_connection workaround (fixed in 0.7.1)
  2. ✅ Suppressed the SDK "non-text parts" warning (googleapis/python-genai#850)
  3. ✅ Doc links updated to mcp-server.couchbase.com + added to Additional Resources
  4. ✅ Added CB_BUCKET_NAME to env loading, validation, MCP config, and .env.sample
  5. ✅ Added GOOGLE_API_KEY / GOOGLE_GENAI_API_KEY validation
  6. ✅ Ported production-grade prompt (discovery-first, hallucination guard, error recovery)

On the test scripts: they're QA harnesses I used to A/B compare flash vs flash-lite — not tutorial content. Happy to remove both once the notebook is approved.

On the failing CI check: the Google ADK tag isn't in couchbase-tutorials yet — opened couchbase-examples/couchbase-tutorials#98 to add it.

On the gemini-code-assist bot saying gemini-2.5-flash is invalid: it's wrong — gemini-2.5-flash is a valid current-gen model. No change needed.

Comment thread google_adk/.env.sample Outdated
couchbase-mcp-server doesn't read CB_BUCKET_NAME — verified by grep
across src/ and confirmed in the README's Additional Configuration
section. The agent already passes bucket_name explicitly to every
run_sql_plus_plus_query call, so the env var was redundant noise.

Removes CB_BUCKET_NAME from:
- .env.sample
- the env loading cell (and its print line)
- the StdioServerParameters env dict in the agent cell
- the .env example block in the setup markdown
@teetangh

Copy link
Copy Markdown
Contributor Author

@nithishr, will remove the test scripts once the notebook is approved.

@teetangh teetangh requested a review from nithishr April 15, 2026 17:36

@nithishr nithishr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the test scripts before merging please

@teetangh teetangh merged commit b7acedc into main Apr 17, 2026
2 checks passed
@nithishr nithishr deleted the tutorial/google-adk-couchbase-mcp branch April 29, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants