Google (Gemini)
MCP Client Configuration Guide
Configure Google Gemini to access b.well's healthcare data and services through b.well Health SDK for AI. This guide includes configuration parameters and code examples for quickly setting up the MCP client in Google's Generative AI API.
Prerequisites
Install the Google GenAI Python libraries:
pip install google-genai fastmcpRequired Credentials:
| Credential | Source | Notes |
|---|---|---|
| Google Gemini API Key | Google AI Studio | Required for all requests |
| b.well User Token | OAuth 2.0 Token Exchange | Bearer token for user authenticatio |
MCP Configuration Parameters:
Google Gemini connects to b.well's MCP server through the FastMCP client using Bearer token authentication. Configure the MCP client with these parameters:
| Parameter | Value | Description |
|---|---|---|
mcp_fhir_agent_url | https://mcpfhiragent.{ENVIRONMENT}.icanbwell.com | b.well MCP server endpoint (client-sandbox) |
auth | BearerAuth(user_token) | Bearer token authentication wrapper |
model | gemini-2.0-flash | Google Gemini model version |
tools | [mcp_client.session] | MCP client session for tool acces |
Code Example: Bearer Token Authentication
Use this approach when you have a user access token from b.well's OAuth 2.0 token exchange
import asyncio
from fastmcp import Client
from fastmcp.client.auth import BearerAuth
from google import genai
person_id = "{insert person id here}"
user_token = "{insert user token here}"
mcp_fhir_agent_url = "https://mcpfhiragent.client-sandbox.icanbwell.com"
mcp_client = Client(
mcp_fhir_agent_url,
auth=BearerAuth(user_token),
)
gemini_client = genai.Client(api_key="{insert your Gemini Key here}")
async def main():
async with mcp_client:
response = await gemini_client.aio.models.generate_content(
model="gemini-2.0-flash",
contents=f"Get Active Medications for person_id={person_id}",
config=genai.types.GenerateContentConfig(
temperature=0,
tools=[mcp_client.session]
),
)
print(response.text)
if __name__ == "__main__":
asyncio.run(main())Updated 8 days ago
