Skip to main content

Overview

Use the Code MCP server from your ATXP-powered agent to run code in a variety of languages in a sandboxed environment.

Example prompts

  • “Run the following python code: print(‘Hello, world!’)”
  • “What is the result of this javascript code: console.log(‘Hello, world!’);”
  • “What is the result of this Scheme code: (display ‘Hello, world!)”

Tools

Take in code and execute it in a sandbox. The output will be the result of the code execution. An example of how it can be used would be to run code generated by a LLM in a safe environment.

Arguments

Accepts a JSON object with the following properties:
string
required
The code to execute. It will be executed in a sandbox.
string
The programming language to use for execution (e.g., javascript, python, typescript, etc.). Default is typescript.

Response

Returns a JSON object with the following properties:
string
The status of the code execution. Returns “success” when the code is executed successfully.
string
The output of the code execution.
number
The exit code of the code execution.

Usage

1

Define the Code service

Create a reusable service configuration that points to the MCP server and standardizes how you pass arguments and read results. This lets your agent easily interact with the Code tools in a consistent manner.
2

Create an ATXP client

Create a client using an ATXP account by importing the ATXP client SDK and other dependencies.
3

Use the Code service in your agent

Call the Code tool by passing your natural‑language instruction as the argument the getArguments method.Read the response using the getResult method.
You should see the result of the code printed in your console.