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).
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:
-
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
-
Install required Python packages: pip install langchain langchain-anthropic anthropic aiohttp
-
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"
-
Run the agent CLI (as documented by the project): python cli.py
-
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
PPTAgent
An Agentic Framework for Reflective PowerPoint Generation
CoexistAI
CoexistAI is a modular, developer-friendly research assistant framework . It enables you to build, search, summarize, and automate research workflows using LLMs, web search, Reddit, YouTube, and mapping tools—all with simple MCP tool calls or API calls or Python functions.
mcp-playground
A Streamlit-based chat app for LLMs with plug-and-play tool support via Model Context Protocol (MCP), powered by LangChain, LangGraph, and Docker.
MIST
MCP server empowering AI assistants with real-world capabilities: Gmail, Calendar, Tasks, Git integration, and note management. Bridges AI assistants to external services through standardized protocol with secure authentication.
mcp-agent-tool-adapter
Transforms MCP tools into collaborative, reasoning agents using modern agent frameworks.
repo-stargazer
Talk to your starred github repositories