Skip to content

ForestAdmin/mcp-server-airtable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Airtable MCP Server for Dust.tt

License: MIT Python 3.10+

A Model Context Protocol (MCP) server that connects Dust.tt AI agents to your Airtable bases. Query and analyze your Airtable data using natural language through Dust's AI assistants.

Features

  • 🔍 Automatic Schema Discovery: List bases, tables, and fields
  • 📊 Rich Querying: Filter, search, and retrieve records with Airtable formulas
  • 📈 Table Statistics: Get record counts and metadata
  • 📤 CSV Export: Export data for spreadsheet analysis
  • 🔒 Secure: Token-based authentication with rate limiting
  • ☁️ Easy Deployment: Deploy to Heroku or Vercel in minutes
  • 🤖 Dust.tt Compatible: Fully compatible with MCP over SSE protocol

Quick Start

Prerequisites

  • Python 3.10 or higher
  • An Airtable account with a Personal Access Token
  • (Optional) A Heroku or Vercel account for deployment

Local Development

  1. Clone and setup:
cd mcp-server-airtable
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
  1. Configure environment:
export AIRTABLE_ACCESS_TOKEN="patXXXXXXXXXXXXXX"  # Your Airtable Personal Access Token
export AIRTABLE_BASE_ID="appXXXXXXXXXXXX"        # Optional: default base
export MCP_AUTH_TOKEN=$(openssl rand -hex 32)     # For Dust.tt authentication
  1. Run the server:
cd src
uvicorn forestadmin_airtable_mcp.server_sse:app --host 0.0.0.0 --port 8000
  1. Test it:
curl http://localhost:8000/health

Deployment

See DUST_INTEGRATION.md for complete deployment and Dust.tt integration instructions.

Quick Deploy to Heroku

Deploy

heroku create your-app-name
heroku config:set AIRTABLE_ACCESS_TOKEN=patXXXXXXX
heroku config:set MCP_AUTH_TOKEN=$(openssl rand -hex 32)
git push heroku main

Quick Deploy to Vercel

vercel deploy --prod
# Then set environment variables in Vercel dashboard

Available Tools

The server exposes 9 MCP tools for Airtable interaction:

Tool Description
list_bases List all accessible Airtable bases
get_base_schema Get complete schema (tables, fields, views)
list_tables List tables in a base
list_fields Show fields in a table with types
list_records Query records with filtering
get_record Get a specific record by ID
search_records Search records by text
get_table_info Get table statistics
export_records_csv Export records as CSV

Usage Examples

With Dust.tt

Once configured in Dust.tt, you can ask your AI agent:

  • "Show me all my Airtable bases"
  • "What tables are in my CRM base?"
  • "List all contacts with status 'Active'"
  • "Search for customers mentioning 'urgent'"
  • "Export the last 100 orders as CSV"

Airtable Filter Formulas

The server supports Airtable's filter formula syntax:

// Simple comparison
{Status} = 'Active'

// Date range
AND(IS_AFTER({Date}, '2024-01-01'), IS_BEFORE({Date}, '2024-12-31'))

// Text search
FIND('keyword', {Description})

// Multiple conditions
AND({Priority} = 'High', {Status} != 'Done')

// Complex formulas
OR(
  AND({Status} = 'Pending', {Amount} > 1000),
  {Priority} = 'Urgent'
)

Configuration

Environment Variables

Variable Required Description
AIRTABLE_ACCESS_TOKEN Yes Airtable Personal Access Token (create at airtable.com/create/tokens)
AIRTABLE_BASE_ID No Default base ID (can specify in tool calls)
MCP_AUTH_TOKEN Yes Bearer token for Dust.tt authentication

Creating an Airtable Personal Access Token

  1. Go to https://airtable.com/create/tokens
  2. Click "Create new token"
  3. Give it a name (e.g., "Dust MCP Server")
  4. Add scopes:
    • data.records:read (required)
    • schema.bases:read (required)
  5. Add access to specific bases
  6. Copy the token (starts with pat)

API Endpoints

  • GET / - Health check with server info
  • GET /health - Detailed health status
  • GET /sse - SSE connection for MCP protocol
  • POST /sse - JSON-RPC tool execution

Rate Limiting

Airtable API has rate limits (5 requests/second per base). This server implements:

  • Automatic retry with exponential backoff
  • Request throttling
  • Configurable max records limits

Security

IMPORTANT: Version 1.0+ includes critical security fixes. See SECURITY.md for details.

Security Features

  • Bearer token authentication on all MCP endpoints (v1.0+)
  • Formula injection prevention with input sanitization (v1.0+)
  • Input validation for all Airtable IDs and field names (v1.0+)
  • Rate limiting (30 requests/minute per IP) (v1.0+)
  • Audit logging for all operations (v1.0+)
  • Confirmation required for destructive operations (v1.0+)
  • Error message sanitization to prevent information disclosure (v1.0+)
  • Environment-based secret management
  • Secure credential handling

Quick Security Setup

  1. Generate authentication token:

    openssl rand -hex 32
  2. Set environment variables:

    export MCP_AUTH_TOKEN="YOUR_GENERATED_TOKEN"
    export AIRTABLE_ACCESS_TOKEN="YOUR_AIRTABLE_TOKEN"
    export DEBUG_MODE="false"  # Never set to true in production
  3. Use authentication in requests:

    curl -X POST http://server:8000/sse \
      -H "Authorization: Bearer YOUR_MCP_AUTH_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{"method":"tools/list","id":1}'

For complete security documentation, see SECURITY.md

Architecture

┌─────────────────────────────────────┐
│       Dust.tt AI Agent              │
└──────────────┬──────────────────────┘
               │ HTTPS + Bearer Token
┌──────────────▼──────────────────────┐
│    MCP Server (Heroku/Vercel)       │
│  - FastAPI application              │
│  - MCP protocol (SSE)               │
│  - 9 Airtable tools                 │
└──────────────┬──────────────────────┘
               │ HTTPS + PAT
┌──────────────▼──────────────────────┐
│         Airtable API                │
│  - Bases, Tables, Records           │
└─────────────────────────────────────┘

Development

Running Tests

pip install -r requirements-dev.txt
pytest

Code Quality

# Format
black src/

# Lint
ruff check src/

# Type check
mypy src/

Troubleshooting

"Airtable client not initialized"

  • Check that AIRTABLE_ACCESS_TOKEN is set correctly
  • Verify the token has necessary scopes

Rate limit errors

  • Reduce max_records in queries
  • Add delays between requests
  • Check Airtable API status

"Base not found"

  • Verify the base ID starts with app
  • Check token has access to the base
  • List bases first with list_bases tool

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Related Projects

Support


Built with ❤️ by Forest Admin

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published