How to integrate Gigasheet MCP with Pydantic AI

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Gigasheet logo
Pydantic AI logo
divider

Introduction

This guide walks you through connecting Gigasheet to Pydantic AI using the Composio tool router. By the end, you'll have a working Gigasheet agent that can list all columns in your sales dataset, download export url for last week's data, apply saved filter to monthly report sheet through natural language commands.

This guide will help you understand how to give your Pydantic AI agent real control over a Gigasheet account through Composio's Gigasheet MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

Also integrate Gigasheet with

TL;DR

Here's what you'll learn:
  • How to set up your Composio API key and User ID
  • How to create a Composio Tool Router session for Gigasheet
  • How to attach an MCP Server to a Pydantic AI agent
  • How to stream responses and maintain chat history
  • How to build a simple REPL-style chat interface to test your Gigasheet workflows

What is Pydantic AI?

Pydantic AI is a Python framework for building AI agents with strong typing and validation. It leverages Pydantic's data validation capabilities to create robust, type-safe AI applications.

Key features include:

  • Type Safety: Built on Pydantic for automatic data validation
  • MCP Support: Native support for Model Context Protocol servers
  • Streaming: Built-in support for streaming responses
  • Async First: Designed for async/await patterns

What is the Gigasheet MCP server, and what's possible with it?

The Gigasheet MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Gigasheet account. It provides structured and secure access to your big data spreadsheets, so your agent can perform actions like retrieving datasets, applying filters, exporting data, managing sheets, and integrating with connector sources on your behalf.

  • Dataset retrieval and inspection: Instantly fetch metadata or details for any dataset or sheet, such as column names, types, and structure, so you can quickly understand and analyze your data.
  • Automated data export and download: Direct your agent to initiate data exports and retrieve download links for processed datasets, streamlining big data extraction directly to your tools or workflows.
  • Smart filtering and template application: Apply saved filter templates to sheets or retrieve available filter templates, enabling rapid, repeatable data curation without manual setup.
  • Sheet and folder management: Effortlessly delete sheets or folders—including recursive deletions—so you can keep your workspace organized and clutter-free.
  • Connector and integration management: List and manage connector connections to keep all your external data sources in sync with Gigasheet, making data aggregation seamless and automated.

Supported Tools & Triggers

Tools
Append Rows to DatasetAppends rows to an existing Gigasheet dataset using column letters as keys.
Append Sheet from Another SheetTool to append data from a source sheet to a target sheet by matching column names.
Apply HTTP EnrichmentTool to apply generic HTTP enrichment to a Gigasheet dataset.
Calculate Enrich Expected CreditsCalculate expected credits for a user-defined HTTP enrichment operation.
Cancel HTTP Enrichment TaskTool to cancel a running enrichment task.
Check Connector Source AvailabilityTool to check if a source of the given type is available.
Combine FilesTool to combine multiple files into a new file.
Copy FileTool to copy a file in Gigasheet.
Count Dataset Deduplication ResultsTool to count how many duplicates will be removed and how many rows remain when deduplicating.
Count Dataset GroupsTool to count the number of groups matching certain criteria in a Gigasheet dataset.
Count Dataset RowsCounts rows in a Gigasheet dataset matching specified filter criteria.
Count Dataset ActivitiesTool to get total activity count on a given Gigasheet dataset.
Create AI Chat QueryAI analysis assistant for Gigasheet datasets.
Create Dataset Column CommentTool to add a comment to a column in a Gigasheet dataset.
Add Comment to CellTool to add a comment to a specific cell in a Gigasheet dataset.
Create Conditional Label ColumnTool to add a label column to a Gigasheet dataset with values based on conditional filters.
Create Formula ColumnTool to create a new column based on a formula input in a Gigasheet dataset.
Edit Formula ColumnTool to edit a formula column in a Gigasheet dataset.
Create Formula PreviewTool to calculate a formula preview on a Gigasheet dataset and return sample results with involved column values.
Create Iterator ColumnTool to add an iterator column to a Gigasheet dataset based on current filters and order.
Create Dataset LiveshareTool to create a new liveshare for a Gigasheet dataset.
Create Dataset ViewTool to create a new view for a Gigasheet dataset with a specified name and client state version.
Explode JSON ColumnTool to explode JSON data in a column into separate columns.
Create File AggregationTool to retrieve ungrouped aggregated values for a Gigasheet file.
Create Blank FileTool to create an empty file in your Gigasheet Library.
Create Files DirectoryTool to create a new folder in your Gigasheet Library.
Create Cross-File LookupCreates a cross-file lookup to enrich data by matching values between two sheets.
Send MCP Request to Sheet AssistantTool to interact with Gigasheet Sheet Assistant via the Model Context Protocol (MCP) over HTTP.
Split ColumnTool to split a column into multiple columns based on a separator.
Delete Sheet Assistant LogsTool to delete Sheet Assistant chat history for a specific sheet.
Delete columns by nameTool to delete multiple columns from a Gigasheet dataset by their column names.
Delete Connector SourceTool to delete a connector source for the authenticated user.
Delete Dataset CommentTool to delete a comment from a cell in a Gigasheet dataset.
Delete Rows Not Matching FilterDeletes rows in a Gigasheet dataset that do NOT match the specified filter criteria.
Delete Duplicated Rows from DatasetTool to delete duplicated rows from a Gigasheet dataset based on specified columns and sort model.
Delete Rows from DatasetTool to delete selected rows from a Gigasheet dataset.
Delete Rows Matching FilterTool to delete rows in a Gigasheet dataset that match a specified filter.
Delete dataset viewTool to delete a specific view from a Gigasheet dataset.
Delete dataset live shareTool to delete a live share of a Gigasheet dataset.
Delete sheet or folder by handleDeletes a Gigasheet sheet or folder by its unique handle identifier.
Delete column from sheetTool to delete a single column from a Gigasheet sheet by its column identifier.
Delete Filter TemplateTool to delete a saved filter template by its unique handle.
Delete multiple columns from fileTool to delete multiple columns from a Gigasheet file.
Filter File RowsTool to retrieve rows from a Gigasheet file matching specified filter criteria.
Generate Dataset DescriptionGenerates an AI-powered description for a Gigasheet dataset.
Get Sheet AI Chat HistoryTool to retrieve AI chat history for a sheet.
Get Cell CommentsTool to get comments for a specific cell in a Gigasheet dataset.
Get Client State Current VersionRetrieves the current client-state version and timestamp for a specified sheet.
Get Connector Connection ParametersTool to get connection parameters for a specific connector.
Get Connector Connection ParametersTool to retrieve connection parameters for a specific connector type.
Get Connector ConnectionsTool to list connector connections.
Get Connector SourcesTool to retrieve information about connected data sources for the user.
Get Connector Source ParametersTool to get parameters required for a specific connector source type.
Get Dataset Column CommentsTool to get comments for a specific column in a dataset sheet.
Get Dataset by HandleRetrieves comprehensive metadata for a specific dataset in Gigasheet.
Get Dataset ColumnsTool to list all column metadata (IDs, names, types) for a dataset.
Get Dataset Export Download URLTool to retrieve the download URL for an exported dataset.
Get Dataset Liveshare CSVTool to retrieve CSV data from a Gigasheet liveshare.
Get Dataset NoteTool to retrieve a dataset's note by handle.
Get Dataset Organization PermissionsTool to retrieve organization file permissions for a dataset.
Get Dataset Version MetadataRetrieves metadata about a dataset at a specific version.
Get Dataset ViewsTool to list all views associated with a specific dataset.
Get Dataset Operation StatusTool to get information about the last operation on a dataset.
Get Dataset ActivityTool to get the list of write actions on a given dataset sheet.
Get Dataset View MetadataTool to retrieve view metadata for a specific view within a dataset.
Get Docs Formulas FunctionsTool to retrieve all supported formula functions.
Get Enrich Task StatusTool to get status for a user-defined HTTP enrichment task.
Apply Filter Template On SheetTool to fetch a saved filter template's model for a given sheet.
Get Filter TemplatesRetrieves all saved filter templates from GigaSheet.
Get Filter Template by HandleRetrieves details of a specific saved filter template by its unique handle.
Generate New HandleTool to generate a new unique dataset handle.
Get Library FilesTool to retrieve all datasets and files in the user's Gigasheet library.
Get Library Files in DirectoryRetrieves all library files with file permissions in a given directory.
Get Library Home Page FilesTool to retrieve suggested recent files for the home page.
Get Library PathTool to retrieve the chain of parent directories for a file or folder in Gigasheet.
Get TICIntel NPI Public ProfileTool to retrieve public NPI (National Provider Identifier) profile from TICIntel database.
Get TIC Intel StatesTool to list available TIC Intel states from Gigasheet.
List Cities by StateTool to retrieve a list of cities for a given US state code from the TICIntel dataset.
List Providers by CityTool to retrieve a list of healthcare providers in a specific city and state from the TicIntel dataset.
Get User DetailsRetrieves detailed information about the authenticated user in Gigasheet.
Get User Enrichment CreditsTool to get the current user's enrichment credit information.
Get User MetadataTool to retrieve metadata for the authenticated user.
Get User Autofill SuggestionsRetrieves autofill suggestions for the authenticated user, including team members and previously used share recipients.
Get User Space UsedTool to get the amount of space used by the current user in bytes.
Get Authenticated User InfoTool to fetch the authenticated user's details.
List Billing PlansTool to list available Gigasheet billing plans.
List Dataset CommentsTool to get all comments in a dataset sheet.
List Dataset LivesharesTool to list all liveshares for a specific Gigasheet dataset.
List All DatasetsTool to retrieve all datasets owned by the user at any folder depth.
List Datasets by HandleTool to list files and datasets in a given Gigasheet location.
List Library ExportsTool to list exports owned by the current user, regardless of location.
List Shared Files by HandleTool to retrieve all files with permissions shared with the user in a specific directory location.
Move file or folder to directoryTool to move a file or folder into a folder or to the root of your Library.
Update User MetadataTool to update user metadata in Gigasheet.
Generate AI FormulaTool to generate Excel-style formulas using AI based on natural language queries.
Cast Column Data TypeTool to change a column's data type in a Gigasheet dataset.
Change Column CaseTool to change the case of a column to Uppercase, Lowercase, Capitalized, or Proper.
Clean Company NameTool to clean company names by stripping common business suffixes (Inc.
Combine ColumnsTool to combine multiple columns into a single new column with a separator.
Append Rows to Sheet by NameAppends one or more rows to a Gigasheet dataset using column names as keys.
Generate Dataset Assistant TipsTool to generate AI-powered tips for analyzing a dataset.
Initiate Dataset ExportInitiates an asynchronous export job for a Gigasheet dataset.
Find and Replace in DatasetTool to find and replace values in specified columns of a Gigasheet dataset.
Insert Blank Row in DatasetTool to insert a blank row with null values into a dataset.
Rename Columns to UniqueTool to rename all columns in a dataset to unique names.
Save Current ViewSaves the current view state of a Gigasheet dataset and returns a view handle.
Select columns by nameTool to select specific columns from a Gigasheet dataset by name, keeping only those columns in the specified order.
Extract Domain from URL ColumnTool to extract domain from a URL column in a Gigasheet dataset.
Filter File Rows by Column NameFilter rows in a Gigasheet file by column names and return matching results.
Get Filtered Row IndexMaps an unfiltered row number to its position in the filtered result set.
Filter File with Stream ProgressFilter data from a Gigasheet file with real-time streaming progress updates.
Save Exported FileSaves a file state with applied filters and grouping to create an exported version.
Combine Files by NameTool to combine multiple files by a shared column name.
Export Gigasheet to S3Tool to export Gigasheet data to AWS S3.
Import from S3Tool to import data from AWS S3 into your Gigasheet Library.
Request Access to FileTool to request access to a Gigasheet file.
Request API AccessRequest API access by sending a notification to Gigasheet support team.
Trim Column WhitespaceTool to trim leading and trailing whitespace from all values in a column.
Unroll Delimited ColumnTool to explode a column containing delimited data into multiple rows.
Upload Raw Data DirectTool to upload raw data directly to Gigasheet using byte array contents.
Upload from URLTool to upload data to Gigasheet from a specified URL.
Preview HTTP EnrichmentTool to preview a generic HTTP enrichment on a Gigasheet dataset before executing it on all rows.
Set Dataset Client State VersionApplies or restores a specific client state version to a dataset.
Update cell by column name and rowTool to update a cell in a dataset by specifying column name and row number.
Share fileTool to share a Gigasheet file with specified recipients.
Opt out of shared fileTool to remove your access from a file that has been shared with you.
Create/Update Filter TemplateTool to create or update a saved filter template.
Rename Columns by NameTool to rename columns in a Gigasheet dataset using their current names.
Rename FileTool to rename a file in Gigasheet.
Reset Client State to DefaultResets the client state of a sheet to the default state.
Reset User PasswordTool to trigger password reset for the authenticated user.
Search Dataset ActivityTool to search the history of write actions performed on a Gigasheet dataset.
Search LibraryTool to search through the Gigasheet file library by file metadata.
Send Invite EmailsTool to send email invitations to join Gigasheet.
Set Aggregate Filter ModelTool to set the aggregate filter model in the client state of a sheet.
Set Client State AggregationsSets aggregations in the client state of a sheet.
Set Client State Column StateTool to set column state in the client state of a sheet.
Set Client State Filter ModelTool to set the filter model in the client state of a sheet.
Set Client State Group ColumnsTool to set group columns in the client state of a sheet.
Set Client State Sort ModelSets the sort model for a sheet's client state.
Set Client State Visible ColumnsTool to set visible columns in the client state of a sheet.
Set Dataset Client StateSets the client state of a dataset using a state object.
Set Dataset Column CurrencyTool to set currency format for a dataset column.
Set Dataset NoteTool to set or update a note on a dataset in Gigasheet.
Update Dataset CellTool to update a single cell value in a Gigasheet dataset by column letter and row number.
Update Dataset ViewTool to update the client state of a specified view.
Upsert Rows in DatasetTool to upsert rows in an existing Gigasheet dataset.
Validate Dataset FormulaTool to validate a formula expression against a dataset.
Validate Files CombineTool to validate a combine files request and return all errors that might appear.
Validate Files Combine by NameTool to validate a combine by name request before executing it.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Prerequisites

Before starting, make sure you have:
  • Python 3.9 or higher
  • A Composio account with an active API key
  • Basic familiarity with Python and async programming

Getting API Keys for OpenAI and Composio

OpenAI API Key
  • Go to the OpenAI dashboard and create an API key. You'll need credits to use the models, or you can connect to another model provider.
  • Keep the API key safe.
Composio API Key
  • Log in to the Composio dashboard.
  • Navigate to your API settings and generate a new API key.
  • Store this key securely as you'll need it for authentication.

Install dependencies

bash
pip install composio pydantic-ai python-dotenv

Install the required libraries.

What's happening:

  • composio connects your agent to external SaaS tools like Gigasheet
  • pydantic-ai lets you create structured AI agents with tool support
  • python-dotenv loads your environment variables securely from a .env file

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
USER_ID=your_user_id_here
OPENAI_API_KEY=your_openai_api_key

Create a .env file in your project root.

What's happening:

  • COMPOSIO_API_KEY authenticates your agent to Composio's API
  • USER_ID associates your session with your account for secure tool access
  • OPENAI_API_KEY to access OpenAI LLMs

Import dependencies

python
import asyncio
import os
from dotenv import load_dotenv
from composio import Composio
from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerStreamableHTTP

load_dotenv()
What's happening:
  • We load environment variables and import required modules
  • Composio manages connections to Gigasheet
  • MCPServerStreamableHTTP connects to the Gigasheet MCP server endpoint
  • Agent from Pydantic AI lets you define and run the AI assistant

Create a Tool Router Session

python
async def main():
    api_key = os.getenv("COMPOSIO_API_KEY")
    user_id = os.getenv("USER_ID")
    if not api_key or not user_id:
        raise RuntimeError("Set COMPOSIO_API_KEY and USER_ID in your environment")

    # Create a Composio Tool Router session for Gigasheet
    composio = Composio(api_key=api_key)
    session = composio.create(
        user_id=user_id,
        toolkits=["gigasheet"],
    )
    url = session.mcp.url
    if not url:
        raise ValueError("Composio session did not return an MCP URL")
What's happening:
  • We're creating a Tool Router session that gives your agent access to Gigasheet tools
  • The create method takes the user ID and specifies which toolkits should be available
  • The returned session.mcp.url is the MCP server URL that your agent will use

Initialize the Pydantic AI Agent

python
# Attach the MCP server to a Pydantic AI Agent
gigasheet_mcp = MCPServerStreamableHTTP(url, headers={"x-api-key": COMPOSIO_API_KEY})
agent = Agent(
    "openai:gpt-5",
    toolsets=[gigasheet_mcp],
    instructions=(
        "You are a Gigasheet assistant. Use Gigasheet tools to help users "
        "with their requests. Ask clarifying questions when needed."
    ),
)
What's happening:
  • The MCP client connects to the Gigasheet endpoint
  • The agent uses GPT-5 to interpret user commands and perform Gigasheet operations
  • The instructions field defines the agent's role and behavior

Build the chat interface

python
# Simple REPL with message history
history = []
print("Chat started! Type 'exit' or 'quit' to end.\n")
print("Try asking the agent to help you with Gigasheet.\n")

while True:
    user_input = input("You: ").strip()
    if user_input.lower() in {"exit", "quit", "bye"}:
        print("\nGoodbye!")
        break
    if not user_input:
        continue

    print("\nAgent is thinking...\n", flush=True)

    async with agent.run_stream(user_input, message_history=history) as stream_result:
        collected_text = ""
        async for chunk in stream_result.stream_output():
            text_piece = None
            if isinstance(chunk, str):
                text_piece = chunk
            elif hasattr(chunk, "delta") and isinstance(chunk.delta, str):
                text_piece = chunk.delta
            elif hasattr(chunk, "text"):
                text_piece = chunk.text
            if text_piece:
                collected_text += text_piece
        result = stream_result

    print(f"Agent: {collected_text}\n")
    history = result.all_messages()
What's happening:
  • The agent reads input from the terminal and streams its response
  • Gigasheet API calls happen automatically under the hood
  • The model keeps conversation history to maintain context across turns

Run the application

python
if __name__ == "__main__":
    asyncio.run(main())
What's happening:
  • The asyncio loop launches the agent and keeps it running until you exit

Complete Code

Here's the complete code to get you started with Gigasheet and Pydantic AI:

python
import asyncio
import os
from dotenv import load_dotenv
from composio import Composio
from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerStreamableHTTP

load_dotenv()

async def main():
    api_key = os.getenv("COMPOSIO_API_KEY")
    user_id = os.getenv("USER_ID")
    if not api_key or not user_id:
        raise RuntimeError("Set COMPOSIO_API_KEY and USER_ID in your environment")

    # Create a Composio Tool Router session for Gigasheet
    composio = Composio(api_key=api_key)
    session = composio.create(
        user_id=user_id,
        toolkits=["gigasheet"],
    )
    url = session.mcp.url
    if not url:
        raise ValueError("Composio session did not return an MCP URL")

    # Attach the MCP server to a Pydantic AI Agent
    gigasheet_mcp = MCPServerStreamableHTTP(url, headers={"x-api-key": COMPOSIO_API_KEY})
    agent = Agent(
        "openai:gpt-5",
        toolsets=[gigasheet_mcp],
        instructions=(
            "You are a Gigasheet assistant. Use Gigasheet tools to help users "
            "with their requests. Ask clarifying questions when needed."
        ),
    )

    # Simple REPL with message history
    history = []
    print("Chat started! Type 'exit' or 'quit' to end.\n")
    print("Try asking the agent to help you with Gigasheet.\n")

    while True:
        user_input = input("You: ").strip()
        if user_input.lower() in {"exit", "quit", "bye"}:
            print("\nGoodbye!")
            break
        if not user_input:
            continue

        print("\nAgent is thinking...\n", flush=True)

        async with agent.run_stream(user_input, message_history=history) as stream_result:
            collected_text = ""
            async for chunk in stream_result.stream_output():
                text_piece = None
                if isinstance(chunk, str):
                    text_piece = chunk
                elif hasattr(chunk, "delta") and isinstance(chunk.delta, str):
                    text_piece = chunk.delta
                elif hasattr(chunk, "text"):
                    text_piece = chunk.text
                if text_piece:
                    collected_text += text_piece
            result = stream_result

        print(f"Agent: {collected_text}\n")
        history = result.all_messages()

if __name__ == "__main__":
    asyncio.run(main())

Conclusion

You've built a Pydantic AI agent that can interact with Gigasheet through Composio's Tool Router. With this setup, your agent can perform real Gigasheet actions through natural language. You can extend this further by:
  • Adding other toolkits like Gmail, HubSpot, or Salesforce
  • Building a web-based chat interface around this agent
  • Using multiple MCP endpoints to enable cross-app workflows (for example, Gmail + Gigasheet for workflow automation)
This architecture makes your AI agent "agent-native", able to securely use APIs in a unified, composable way without custom integrations.

How to build Gigasheet MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Gigasheet MCP?

With a standalone Gigasheet MCP server, the agents and LLMs can only access a fixed set of Gigasheet tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Gigasheet and many other apps based on the task at hand, all through a single MCP endpoint.

Can I use Tool Router MCP with Pydantic AI?

Yes, you can. Pydantic AI fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Gigasheet tools.

Can I manage the permissions and scopes for Gigasheet while using Tool Router?

Yes, absolutely. You can configure which Gigasheet scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

How safe is my data with Composio Tool Router?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Gigasheet data and credentials are handled as safely as possible.

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.