Get the FREE Ultimate OpenClaw Setup Guide →

code-execution-with

Langchain agent that generates and executes Python code to interact with Airtable using the MCP code execution pattern from [Anthropic's blog](https://www.anthropic.com/engineering/code-execution-with-mcp).

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio shams858-code-execution-with-mcp python cli.py \
  --env ANTHROPIC_API_KEY="your-anthropic-api-key" \
  --env AIRTABLE_MCP_ENDPOINT="http://localhost:8000/mcp"

How to use

This MCP server implements a code-execution agent that uses the MCP pattern to generate and run Python code that interacts with Airtable through a sandboxed subprocess. The agent leverages the Claude-based generation flow to produce Python snippets that call an Airtable client against your local MCP server endpoint. The overall flow is: user request -> model generates Python code -> code runs in a sandboxed subprocess -> results are returned to the user. You can use it to query Airtable bases, tables, and records, then get structured results without leaking raw data into the prompt context.

To use, ensure the Airtable MCP server is running and accessible at http://localhost:8000/mcp, provide your Anthropic API key, and install the required Python packages. Interact with the agent by sending natural language queries like “List all my Airtable bases” or “Get records from table X where Status is Active.” The agent will generate code that uses the provided Airtable client to fetch data from the MCP endpoint and return a concise result back to you.

How to install

Prerequisites:

  • Python 3.8+ installed on your machine
  • Access to the Airtable MCP server at http://localhost:8000/mcp
  • Anthropic API key for the code-execution flow

Step-by-step installation:

  1. Create and activate a virtual environment (optional but recommended): python -m venv venv source venv/bin/activate # on UNIX or venv\Scripts\activate.bat on Windows

  2. Install required Python packages: pip install langchain langchain-anthropic anthropic aiohttp

  3. Set your API key and endpoint: export ANTHROPIC_API_KEY="your-anthropic-api-key"

    If needed, ensure the Airtable MCP server is reachable

    export AIRTABLE_MCP_ENDPOINT="http://localhost:8000/mcp"

  4. Run the agent CLI (as documented by the project): python cli.py

  5. Optionally verify access by performing a sample query once the server is up.

Additional notes

Notes and tips:

  • Ensure the Airtable MCP server is running and reachable at the configured endpoint (http://localhost:8000/mcp).
  • The agent’s generated code runs in a sandboxed subprocess for safety; avoid exposing sensitive credentials in prompts.
  • The ANTHROPIC_API_KEY must be set in the environment where you run the agent.
  • If you encounter connectivity issues, verify network access between the agent and the Airtable MCP server and confirm that the server accepts requests from the agent.
  • The workflow emphasizes processing data within generated code rather than passing large data back into the prompt context to maintain context efficiency.

Related MCP Servers

Sponsor this space

Reach thousands of developers