Secure Development with Python Plugin


To use the plugin in a Google Colab notebook or a Databricks notebook, follow the steps below:

  1. Install the plugin.

    pip install -U mais
  2. Create a new Manifest API Token for MAIS. This links the notebook to your Manifest account for policy enforcement and model tracking.

    1. Navigate to Settings > API Tokens. This can be found under the section "Account":

    2. Create a token with at least the following scopes

  3. In Google Colab, add your Manifest API key.

    1. Add your MANIFEST_API_KEY as a Google Colab secret

    2. Assign your secret to the api_token variable.

      ``python
      api_token = userdata.get('MANIFEST_API_KEY')
      ``
  4. In Databricks, add your Manifest API key

    1. Ensure your Databricks environment has a secret scope and key configured with Manifest API Key as a value: https://docs.databricks.com/aws/en/security/secrets/?language=Secrets%C2%A0utility%C2%A0%28dbutils.secrets%29#create-a-secret
    2. Assign your secret to the api_token variable:
      api_token = dbutils.secrets.get(scope="mais", key="api-token")

  5. Import and initialize the plugin. After successful initialization, MAIS will scan and analyze every cell before its execution, separately.

    from mais import MAIS
    m = MAIS(api_token=api_token)

    To enable debug-level logging during initialization, pass verbosity="DEBUG". This is useful for troubleshooting detection issues or inspecting the calls MAIS makes to the Manifest API.

    from mais import MAIS
    m = MAIS(api_token=api_token, verbosity="DEBUG")

  6. Register your custom model to your Manifest inventory using the register_model function. All parameters are required: model name, model version, supplier, and country.

    m.register_model("model_name", "model_version", "supplier", "country")

    For example:

    m.register_model("my_custom_model", "1.0", "Acme", "USA")
  7. Generate the SBOM. This will automatically generate an AI Bill of Materials (AIBOM) showing all model dependencies and risks.

    m.create_sbom()

    Your Manifest dashboard will now show the new model with complete risk analysis, compliance status, and security documentation - demonstrating full AI governance in action.


Direct Python Usage

MAIS isn't limited to Jupyter — you can use it directly from any Python script, CI job, or service. Instantiating MAIS() outside of a notebook automatically installs script-mode hooks that mirror the per-cell behavior you get in Jupyter:

  • One-shot scan of your entry script (__main__) at construction time.
  • Per-module import hook (sys.meta_path finder) that analyzes the source of each first-party module you import before it executes. Stdlib and site-packages modules are skipped automatically — only your user code is scanned.
from mais import MAIS

# Instantiating MAIS in a regular script automatically:
#   1. Reads and analyzes the running script's source.
#   2. Installs an import hook so every user module you import next
#      gets analyzed before it runs (just like a Jupyter cell).
m = MAIS(api_token="<manifest-api-token>", verbosity="DEBUG")

from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("moonshotai/Kimi-K2-Instruct")

from datasets import load_dataset
dataset = load_dataset("ProlificAI/social-reasoning-rlhf")

# Methods like register_model() and create_sbom() work without any
# extra plumbing — MAIS uses the cached script source automatically.
m.register_model("my_custom_model", "1.0", "Acme", "USA")
m.create_sbom(path=".", publish=False)

# Need to detach the import hook (e.g. in tests)?
m.uninstall()

Expected output (truncated):

MAIS [DEBUG]: Found dataset loading call: load_dataset('ProlificAI/social-reasoning-rlhf')
MAIS [DEBUG]: Datasets found: [{'title': 'ProlificAI/social-reasoning-rlhf', ...}]
MAIS [DEBUG]: Custom model registration → POST https://api.manifestcyber.com/v1/model-analysis/custom
MAIS [DEBUG]: Model '<id>' registered successfully
✅ SBOM Created — sbom.json written at .

Example

Example #1: Risk assessment of a model registered in your organization’s inventory


Example #2: Risk Assessment of model not found in inventory