Skip to main content

Overview

buntime.sh is designed for AI agents to write and execute code autonomously. This guide shows how to integrate buntime.sh with popular AI platforms including Claude, GPT, and custom agents via MCP (Model Context Protocol) or function calling.

Why AI Agents Need buntime.sh

AI agents can write code, but they can’t test it themselves. With buntime.sh, your AI can:
  • ✅ Execute code and see real results
  • ✅ Iterate on bugs with actual error messages
  • ✅ Build multi-file projects that persist across messages
  • ✅ Run web servers and preview them
  • ✅ Work with databases without external setup

Claude Integration

Using MCP (Model Context Protocol)

Claude Desktop and other MCP-compatible clients can use buntime.sh as a tool:
mcp-config.json
Install the MCP server:
Now Claude can execute code directly:

Using Function Calling

Provide buntime.sh as a function in your Claude API calls:

OpenAI GPT Integration

Using Function Calling

Custom Agent Integration

LangChain

Vercel AI SDK

Session Management Strategies

One Session Per Conversation

Best for AI assistants where context persists across messages:

One Session Per Task

Best for independent tasks without shared context:

Error Handling for AI

Help your AI understand and fix errors:

Prompt Engineering Tips

System Prompt Template

Encourage Good Practices

Real-World Example: Data Analysis Agent

Security Considerations

Important security notes:
  • Never pass untrusted user code directly to buntime.sh
  • Validate and sanitize AI-generated code
  • Set appropriate timeouts to prevent abuse
  • Monitor resource usage for anomalies
  • Use separate API keys for production and development
  • Review execution logs regularly

Best Practices

Create one session per conversation to maintain context and file state across multiple code executions.
Use shorter timeouts (10-30s) for quick tasks to prevent runaway code from consuming resources.
Check exitCode, stdout, and stderr to help the AI understand what happened and iterate if needed.
Review code for dangerous patterns before execution, especially in production environments.
Delete sessions when conversations end to free resources and minimize costs.

Examples & Resources

Claude MCP Server

Official MCP server for Claude integration

GPT Function Example

Complete GPT function calling example

LangChain Tool

LangChain integration example

Agent Templates

Pre-built agent templates

Next Steps

Multi-file Projects

Build complex applications with AI

Web Apps

Create web servers with preview URLs

SDK Reference

Explore the TypeScript SDK

API Reference

View complete API documentation