In# CodeAct MCP

A Python proof of concept implementation inspired by Anthropic's engineering blog and CodeAct agent pattern.

Overview

The Problem

Traditional MCP implementations suffer from token inefficiency:

  • Context overload: Tool definitions consume excessive tokens before the model processes requests
  • Result duplication: Intermediate outputs pass through the model repeatedly, bloating context usage

A simple workflow processing data between two services can consume 150,000+ tokens by passing intermediate results through the model.

The Solution

CodeAct MCP implements the CodeAct pattern where agents generate executable Python code instead of JSON tool calls:

  1. Agent generates code to interact with MCP tools
  2. Code executes in an isolated sandbox
  3. Data processing happens locally in the sandbox
  4. Only summaries return to the LLM context

Result: Significant token reduction and more dynamic and flexible workflow

Core Stack

  • LangGraph: AI agent orchestration using the ReAct pattern
  • Daytona: Secure sandbox execution environment
  • MCP: Model Context Protocol for tool integrationspiration

What it does

How we built it

Challenges we ran into

Accomplishments that we're proud of

What we learned

What's next for CodeAct-MCP

Built With

  • daytona
  • langchain
  • langraph
Share this project:

Updates