MCPcopy Index your code
hub / github.com/engineer-man/piston

github.com/engineer-man/piston @pkgs

Chat with this repo
repository ↗ · DeepWiki ↗ · release pkgs ↗ · + Follow
38 symbols 53 edges 25 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

engineer-man piston Piston

A high performance general purpose code execution engine.

<a href="https://github.com/engineer-man/piston/commits/master">
<img src="https://img.shields.io/github/last-commit/engineer-man/piston.svg?style=for-the-badge&logo=github&logoColor=white"
     alt="GitHub last commit">
<a href="https://github.com/engineer-man/piston/issues">
<img src="https://img.shields.io/github/issues/engineer-man/piston.svg?style=for-the-badge&logo=github&logoColor=white"
     alt="GitHub issues">
<a href="https://github.com/engineer-man/piston/pulls">
<img src="https://img.shields.io/github/issues-pr-raw/engineer-man/piston.svg?style=for-the-badge&logo=github&logoColor=white"
     alt="GitHub pull requests">

AboutPublic APIGetting StartedUsageSupported LanguagesPrinciplesSecurityLicense


About

Piston is a high performance general purpose code execution engine. It excels at running untrusted and possibly malicious code without fear from any harmful effects.

It's used in numerous places including: * EMKC Challenges, * EMKC Weekly Contests, * Engineer Man Discord Server, * I Run Code (Discord Bot) bot as well as 1300+ other servers and 100+ direct integrations.

To get it in your own server, go here: https://emkc.org/run.

Public API

  • Requires no installation and you can use it immediately.
  • Reference the Versions/Execute sections below to learn about the request and response formats.

When using the public Piston API, use the base URL:

https://emkc.org/api/v1/piston

GET

https://emkc.org/api/v1/piston/versions

POST

https://emkc.org/api/v1/piston/execute

Important Note: The Piston API is rate limited to 5 requests per second. If you have a need for more requests than that and it's for a good cause, please reach out to me (EngineerMan#0001) on Discord so we can discuss potentially getting you an unlimited key.

Getting Started

Host System Package Dependencies

  • Docker
  • Docker Compose
  • Node JS

After system dependencies are installed, clone this repository:

# clone and enter repo
git clone https://github.com/engineer-man/piston

Installation

  • docker-compose up

CLI Usage

  • cli/execute [language] [file path] [args]

Usage

CLI

lxc/execute [language] [file path] [args]

API

To use the API, it must first be started. Please note that if root is required to access LXC then the API must also be running as root. To start the API, run the following:

cd api
./start

For your own local installation, the API is available at:

http://127.0.0.1:2000

Versions Endpoint

GET /versions This endpoint will return the supported languages along with the current version and aliases. To execute code for a particular language using the /execute endpoint, either the name or one of the aliases must be provided.

HTTP/1.1 200 OK
Content-Type: application/json

[
    {
        "name": "awk",
        "aliases": ["awk"],
        "version": "1.3.3"
    },
    {
        "name": "bash",
        "aliases": ["bash"],
        "version": "4.4.20"
    },
    {
        "name": "c",
        "aliases": ["c"],
        "version": "7.5.0"
    }
]

Execute Endpoint

POST /execute This endpoint requests execution of some arbitrary code. - language (required) The language to use for execution, must be a string and supported by Piston (see list below). - source (required) The source code to execute, must be a string. - stdin (optional) The text to pass as stdin to the program. Must be a string or left out of the request. - args (optional) The arguments to pass to the program. Must be an array or left out of the request.

{
    "language": "js",
    "source": "console.log(process.argv)",
    "stdin": "",
    "args": [
        "1",
        "2",
        "3"
    ]
}

A typical response upon successful execution will contain the language, version, output which is a combination of both stdout and stderr but in chronological order according to program output, as well as separate stdout and stderr.

HTTP/1.1 200 OK
Content-Type: application/json

{
    "ran": true,
    "language": "js",
    "version": "12.13.0",
    "output": "[ '/usr/bin/node',\n  '/tmp/code.code',\n  '1',\n  '2',\n  '3' ]",
    "stdout": "[ '/usr/bin/node',\n  '/tmp/code.code',\n  '1',\n  '2',\n  '3' ]",
    "stderr": ""
}

If a problem exists with the request, a 400 status code is returned and the reason in the message key.

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
    "message": "Supplied language is not supported by Piston"
}

Supported Languages

python,php,node

License

Piston is licensed under the MIT license.

Core symbols most depended-on inside this repo

toString
called by 6
api/src/runtime.js
step
called by 2
cli/commands/execute.js
get_package_list
called by 2
api/src/ppman/routes.js
safe_call
called by 2
api/src/executor/job.js
make_default_config
called by 1
api/src/config.js
get_package
called by 1
api/src/ppman/routes.js
install
called by 1
api/src/ppman/package.js
prime
called by 1
api/src/executor/job.js

Shape

Method 16
Function 14
Class 8

Languages

TypeScript79%
Java5%
C#5%
Kotlin3%
Go3%
C++3%

Modules by API surface

api/src/executor/job.js8 symbols
api/src/runtime.js6 symbols
api/src/ppman/package.js6 symbols
api/src/ppman/routes.js5 symbols
packages/mono/6.12.0/test.cs2 symbols
packages/java/15.0.2/test.java2 symbols
packages/kotlin/1.4.31/test.kt1 symbols
packages/go/1.16.2/test.go1 symbols
packages/gcc/10.2.0/test.cpp1 symbols
packages/gcc/10.2.0/test.c1 symbols
cli/index.js1 symbols
cli/commands/execute.js1 symbols

For agents

$ claude mcp add piston \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact