Skip to content


Users familiar with Python will feel at home with Mpl. Mpl supports syntax and basic types as in Python. Further, some unique language extensions and capabilities make Mpl more potent for the target use cases. We will learn those in subsequent sections. Below is a peek into what a typical interactive user session in Mpl repl looks like.

Mpl is available on Linux, MacOs and Windoes. mpl can be launched on any modern terminal. mpl -h prints supported command line options.

> mpl
mpl> x = "fruit"
mpl> x + " is good for you"
"fruit is good for you"

For a typical trouble shooting session, one can issue Mpl "commands" on repl and assign the output to a variable. That variable (typically a Json document) is available as input to next command. More details in subsequent section. For commands (in mpl they start with !) convenient command completion options is available as user types.

> ./mpl -i '{"site":""}'
mpl> x = ! k8s list-pods --namespace "customer1"
mpl> print x[0].status

Mpl interpreter in batch mode is invoked with mpl file in shell.

> mpl <file>


Mpl suppoprts types such as Number, String, Boolean, Json, Time, and Duration. Note that, unlike other languages, Mpl has Json, Time, and Duration as first-class built-in types. Refer to the 'types' section for details on each type.


  1. Simple variable: A simple variable in Mpl can be defined similar to python Python. e.g.,

    x = 2

    The value of x is 2.

  2. Indexed variable: Mpl support intuitive indexed variable to access values in JSON documents. Users can create JSON documents via the keyword json followed by a valid JSON text. To access any field in the document, one can use syntax like x.y[1]["a"] or in more convenient dotted notation, x.y[1].a. e.g.,

    x = json {"b", [1, 3]}
    output is: 1.


In addition to simple assignment of 'rhs' variable to 'lhs', 'rhs' can be an expression. Expression can be composed of basic opertors like +, -, *, / and builtin operators like 'len' and methods. For full documentation of methods supported for each type, refer to 'types' section. Examples:

Example 1: Simple arithmetic

x = 20
y = x + x / 10

output is: 12

Example 2: Simple string transformation

x = "Blue"
x.lower() + "dot"

output is: "bluedot"


Mpl supports Python like if-else branching syntax. The comparison expression can be on any Mpl supported data types. The supported compare operators are ==, !=, >, <, >=, <= and in. In addition if not statement supported. e.g.,

x = "cat"
if x == "cat":
  x = "white"
  x = "black"     
Here vlaue of x will be "white".
The conditional expression can be chained by && and || operators. Unix like wildcard match, specified in backtick, is also supported. e.g.,

x = "cat"
y = "dog"
if x == `*c` && y == "dog":
  x = "cat-or-dog"
  x = "nopet"     

Here vlaue of x will be "cat-or-dog".

The in operator find existance of value in arrays or a key in object. e.g.,

x = json ["a", "b", {"c": 1, "d":2}]
if "a" in x && "c" in x[2]:
  res = true

Here vlaue of res will be true.


Mpl supports for loop syntax with simple loops over integer or iterables (like Json doc). Note that Python's indentation rule for the loop block applies. For example in following simple loop:

x = 2
for i in x:
   print i

output is:

As a shortcut, if indexing variable i is not needed, in Mpl, for x: is a valid statement to loop for x times. Also break and continue are supported, shown below.

For iterables like Json array, value will be assigned as Json value of iterable. Refer to Json type section for more details on Json.

x = json [2, 3, 5]
for val in x:
   if val == 5:
   print val

output is:

In case of Json object, index variable, i, is assigned to key of map (sub document). e.g.,

x = json {"a":1, "b":2, "c":5 }
for i in x:
   print i

output is:



Mpl supports Python like function definition. Functions have read only access to all variables from calling scope. At this time, unlike Python, Mpl functions can return only one variable. e.g.,

def add():
    x = x + 1
    return x
x = 1
y = add()

output is:


Example 2:

def add(x):
    a = 10
    if a == 10:
       x = x + 2
       x = x + 4
    return x
p = 23
y = add(p)

output is: