Learning resourcesReviewed · Pydantic

Pydantic AI Harness Google Workspace Guide

This Pydantic AI Harness documentation page shows Python developers building Pydantic AI agents how to give them Gmail, Calendar, Drive and other Google Workspace tools through Google's hosted MCP servers; their application must manage Google OAuth authorization and expiring access tokens. It explains the GoogleWorkspace capability, Google's hosted Model Context Protocol (MCP) servers, per-user credentials and controls for tools that can send, change or delete data.

Researched 15 Nov 2026

In short.

This Pydantic AI Harness guide helps Python developers building Pydantic AI agents add Google Workspace tools, but their application must supply and renew Google access tokens. GoogleWorkspace exposes tools from selected Google-hosted MCP servers, including tools that modify data unless filtered. The page explains per-user credentials, read-only filtering and approval wrappers, and warns that 0.x APIs may change between minor releases. Runtime reliability, security effectiveness, pricing and licensing are not established by the page.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete captured page at [https://pydantic.dev/docs/ai/harness/google-workspace/index.md], including installation, credentials, product selection, tool controls, connections, telemetry, the 0.x API warning and documentation-index/query-parameter notices. Linked pages, repository files and the external diagram asset are outside the evidence; its supplied descriptive text is included. No behavior was executed or tested.

The overview

Identity

The resource is the Google Workspace documentation page for Pydantic AI Harness at [https://pydantic.dev/docs/ai/harness/google-workspace/index.md]. It teaches developers to configure the GoogleWorkspace capability inside a Python agent.

The capability connects agents to Google's hosted MCP servers. MCP provides the interface through which the agent receives and calls the selected products' tools.

Assessment

The guide is useful for developers already building Python agents who need access to several Google Workspace products. Its practical value is the combination of installation examples, account-selection rules, credential-expiry behavior and approval guidance.

It explains integration choices but supplies no execution results, performance measurements or evidence of production reliability. Following the examples alone does not establish that an application's authentication and approval handling work correctly.

Users

The intended readers are Python developers building assistants that work with email, calendars, files, documents or other Workspace content. The examples cover both scripts using one account and applications where each user connects a separate Google account.

Beginners need familiarity with Python packages, environment variables and Google OAuth configuration. Experienced developers receive details about dependency-based credentials, connections across runs, tool-name collisions and durable execution.

Capabilities

The services setting selects gmail, drive, docs, sheets, slides, calendar, chat or people. The capability exposes every tool offered by the selected servers, including tools that send, change and delete. Tool names start with the product, such as gmail_search_threads. The page does not enumerate every available tool.

Documented controls include read_only=True, toolset wrappers for filtering or approval, include_instructions=False for excluding server-supplied instructions, and links to output-size limits and Prompt Injection Defender. The linked controls' implementation details are outside this page.

Using it

Requirements

The documented installation uses pydantic-ai-harness[google-workspace]. The OpenAI example also installs pydantic-ai-slim[openai]. Python compatibility, minimum package versions and model-provider credential setup are not specified.

Developers must register a Google OAuth client and request the scopes needed by the selected products. Automatic client registration is unsupported, and auth='oauth' raises an error. With auth unset, None or an empty string, GOOGLE_ACCESS_TOKEN must be available when the agent is created.

Mechanism

The capability opens a connection to each selected product's hosted MCP server, using the same Google access token across those product connections. OAuth scopes limit what the token authorizes; selecting products determines which servers supply tools.

A fixed token is read when the agent is created, and its connections are shared across runs. An auth function is called once at the start of each run, can be asynchronous, and supplies the token for that run's separate connections. Returning None or an empty string disables Workspace tools for that run without falling back to GOOGLE_ACCESS_TOKEN.

GoogleWorkspace emits no spans of its own; the page says core instrumentation records individual Workspace tool calls. Logging contents, redaction and retention are not explained.

Setup

The documented pip command is pip install "pydantic-ai-harness[google-workspace]" "pydantic-ai-slim[openai]". The uv equivalent is uv add with the same package names. Configure a Google OAuth client, obtain an access token, and provide it through GOOGLE_ACCESS_TOKEN or auth. The page links provider setup at [https://developers.google.com/workspace/guides/configure-mcp-servers], whose contents are outside the supplied evidence.

For per-user accounts, the example stores google_token in the run's dependencies and reads it through an auth function. The application must retain refresh tokens and exchange them for access tokens before runs, or perform that exchange inside an asynchronous auth function. For durable execution, the page recommends reading credentials from run dependencies because execution may move to another process.

Example

The introductory example creates an Agent using openai:gpt-6.1-sol and GoogleWorkspace(services=['gmail', 'calendar']). It calls run_sync('Summarize the resources I can access') and prints result.output. The page supplies no observed response or retrieval-quality result.

That constructor leaves read_only unset. Asking for a summary does not itself restrict the available tools to reading. The guide recommends read_only=True for agents that only read or summarize.

Assessment & evidence

Limitations

Google access tokens expire after about an hour, and the capability does not refresh them. The page provides no evidence about recovery from expiry during a long-running operation. It also warns that APIs may change between minor releases while Pydantic AI Harness is on 0.x releases.

Read-only filtering depends on the server marking its tools correctly. If no tools are marked read-only, the capability exposes none and emits MCPReadOnlyNoToolsWarning. Email bodies and shared documents can contain instructions aimed at the model; read-only access does not establish protection against all such instructions.

Instances selecting overlapping products register colliding tool names. The page directs developers to wrap one with PrefixTools and, when the product selections are identical, assign a distinct capability id.

Fit rationale

The practical trade-off is convenient access to several Workspace products alongside application responsibility for authorization, token renewal and tool permissions. Product selection, OAuth scopes, read-only filtering and approval wrappers control different parts of that access.

A summary assistant benefits from read-only filtering and appropriately limited account permissions. For an assistant that can change Workspace data, the page recommends requiring approval for tool calls or adding Prompt Injection Defender (a separate linked page outside this evidence). include_instructions=False concerns server-supplied instructions; the page separately warns about instructions embedded in tool results.

Alternatives

The page does not compare competing Workspace integrations or direct API approaches, so relative cost, coverage and reliability are unknown.

Within this integration, it describes fixed credentials for one-account scripts and an auth function for per-user applications. Toolset wrappers offer additional filtering and approval choices around the same capability.

Evidence

The evidence is the complete documentation page at [https://pydantic.dev/docs/ai/harness/google-workspace/index.md], captured on 15 November 2026 at 11:36:15.413 UTC. Its source revision is sha256:162ab98481bc1245a141855eeabb0c28d5585f1e47a985862cddc91bff73a601.

The page provides API descriptions and Python examples. Linked documentation and implementation files are not included. No installation, code, OAuth flow, model request or Workspace tool call was executed, so documented behavior has not been independently verified.

Access & freshness

Costs

The page states no package price, Google MCP pricing, model charges, quotas or measured operating costs. Total cost and billing requirements are unknown from this evidence. The installation commands and model identifier do not establish that any part of the deployment is free.

Rights

The page does not state a license for the documentation, examples or implementation. It links the implementation directory at [https://github.com/pydantic/pydantic-ai/tree/main/src/pydantic_ai_harness/pydantic_ai_harness/google_workspace/], but repository contents and licensing terms are outside the evidence.

Permission to redistribute the captured documentation or implementation is therefore not established here. Google service terms and the chosen model provider's terms are also not supplied.

Freshness

The capture date identifies when this copy was obtained; it does not establish when the page or implementation last changed. No exact package release or implementation commit is specified.

The 0.x warning makes version matching relevant: the page says minor releases may change APIs, with deprecation warnings and release-note migration guidance. Those linked materials and current compatibility are not assessed.

Next steps

Start by identifying the required Workspace products and OAuth scopes. Choose fixed credentials for a single account or an auth function for per-user access, then implement token renewal in the application. Check package compatibility and provider setup before adopting the examples.

For reading and summarizing, configure read_only=True and handle the possibility that server annotations expose no tools. For approval before every call, the page shows capability.get_toolset().approval_required() with DeferredToolRequests allowed in the agent's output type; the application must implement the deferred-tools approval flow. As an alternative to approval, the page points to Prompt Injection Defender, whose behavior is not covered by this evidence.

Before relying on the integration, verify credential expiry, account isolation, available tools and approval handling in the intended application. Confirm pricing and licensing separately; this page establishes neither.

Evidence for this report

selected-page.txtselected · checked 2026-11-15