start is the default mb command, meaning:

mb start [options]

is identical to

mb [options]

Running mb by itself, without any options, will start up the API on port 2525. It will also spin up this website on http://localhost:2525/, giving you accurate documentation for the version of mountebank you're running, as the official site only contains the latest docs. The following options are available:

Option Description Default
--port 2525 The port to run the main mountebank server on 2525
--host mbserver.local The hostname to bind the main mountebank server to all hosts
--datadir .mbdb The root directory for persisting all imposter changes. When used, mountebank will start all imposters saved in the directory initially and persist all operations to disk in real time, significantly reducing the memory footprint.

This option allows you to scale imposters with multiple processes (running on multiple hosts behind a load balancer to avoid port collision), with the state of all processes synced in real time. All mountebank processes will need to share the same volume.

Without this option, all configuration will be in memory. Keeping everything in memory can be a significant performance hit when there is a lot of test data, for example, during proxy recording.
--impostersRepository=./impostersRepo.js Use a custom database instead of the built-in file-based data store that datadir creates (when both are used, impostersRepository takes precedence). Creating a custom database option is not documented and requires looking at the code, but the community have created (or are creating) options. See community extensions for examples.
--configfile imposters.ejs If present, mountebank will load the contents of the specified file. See below for details.

If both the datadir and configfile options are used, mountebank will initially load all imposters from the datadir and then add all from the configfile. This means that when the same imposter port is saved in both places, what is in the datadir will be immediately overwritten by what's in the configfile!

N/A
--formatter path/to/module Historically, mountebank supported EJS templating when using the configfile option, and was limited to saving all configuration in a single file when calling mb save. For backwards compatibility, that remains the default option, even though EJS has subsequently made breaking changes.

A custom formatter allows you to save test data in whatever format you want (including in ways that convert between other service virtualization products). See below for more details. In the context of mb start, the formatter will be used to parse the configfile.

mountebank-formatters
--noParse By default, mountebank will render config files through EJS templating to allow modularizing rich configuration. Use this flag if you aren't using templating and have special character sequences in your configuration that cause rendering errors. false
--logfile mb.log The file for mountebank to store the logs in mb.log
--loglevel debug The logging level, one of debug, info, warn, error info
--nologfile Prevent logging to the filesystem false
--log Advanced logging configuration, when you want to customize the log formats. While you can pass the JSON string on the command line, it's easier to put it in the rcfile. If you pass log, the simpler logging configuration options (loglevel, logfile, nologfile) will be ignored.

You can set the format to "json" to log all fields as JSON, or set it to a string to customize the format. The supported fields are:

  • %level
  • %timestamp
  • %message
{
  "level": "info",
  "transports": {
    "console": {
      "colorize": true,
      "format": "%level: %message"
    },
    "file": {
      "path": "mb.log",
      "format": "json"
    }
  }
}
--allowInjection mountebank supports JavaScript injection for predicates, stub responses, behavior decoration, wait behavior functions and tcp request resolution, but they are disabled by default. Including this parameter will enable them.

Note that allowing injection means that an attacker can run random code on the machine running mb. Please see the security page for tips on securing your system.

false
--localOnly Only accept requests from localhost. You should ALWAYS do this when running mountebank with allowInjection directly on your developer machine, but will need to use ipWhitelist otherwise (or if running in Docker), false
--ipWhitelist A pipe-delimited string of remote IP addresses to whitelist (local IP addresses will always be allowed). Any request to the primary mb socket or an imposter socket that isn't whitelisted will be dropped. *, representing all IP addresses
--origin A safe origin for CORS requests. Use the flag multiple times to enable multiple origins. false, which disables CORS to prevent CSRF attacks.
--protofile File to load custom protocol implementations from. protocols.json
--rcfile .mbrc The run commands file containing startup configuration. The rcfile format is a JSON-equivalent representation of the command line option. For example, the following command line is very complex:
mb --port 3000 --allowInjection --origin 'http://first.com' --origin 'http://second.com' \
--log '{ "level": "warn", "transports": { "console": { "format": "json" } } }'
You could simplify it by putting the configuration in a file and running
mb start --rcfile .mbrc
The file .mbrc would look like the following:
{
  "port": 3000,
  "allowInjection": true,
  "origin": ["http://first.com", "http://second.com"],
  "log": {
    "level": "warn",
    "transports": {
      "console": {
        "format": "json"
      }
    }
  }
}
When the same option is listed in both the rcfile and the command line, the command line option takes precedence.
N/A
--debug Include a matches array with each stub in the body of a GET imposter response for debugging why a particular stub did or did not match a request. Every time a response from the stub is used, a match will be added containing the request, the response configuration, the actual generated response (even if it is proxied), and the overall processing time. false
--pidfile The file where the process id is stored for the mb stop command mb.pid
--apikey myapikey An optional API key. When this is provided, the Mountebank API will require that the x-api-key header be supplied with a matching key. null
--version Print the version out to the console and exit. N/A
--help Show help for the command N/A