Extensions SDK for SoftwareONE Marketplace Platform
Project description
MPT Extension SDK
The MPT Extension SDK is an SDK for building extensions on the SoftwareONE Marketplace Platform (MPT).
Quick Start
-
Install the SDK:
pip install mpt-extension-sdk
-
Create your extension:
from mpt_extension_sdk.core.extension import Extension ext = Extension() @ext.events.listener("orders") def process_order(client, event): """Process order""" # Process your order logic here
-
Run the extension:
make run
Installation
Install with pip or your favorite PyPI package manager:
pip install mpt-extension-sdk
uv add mpt-extension-sdk
Prerequisites
- Python 3.12+
- Docker and Docker Compose (for development)
- Access to SoftwareONE Marketplace Platform API
- Environment variables configured (see Environment Variables)
Environment Variables
The SDK uses the following environment variables:
| Variable | Default | Example | Description |
|---|---|---|---|
EXT_WEBHOOKS_SECRETS |
- | {"PRD-1111-1111": "123qweasd3432234"} | Webhook secret of the Draft validation Webhook in SoftwareONE Marketplace for the product |
MPT_API_BASE_URL |
http://localhost:8000 |
https://portal.softwareone.com/mpt |
SoftwareONE Marketplace API URL |
MPT_API_TOKEN |
- | eyJhbGciOiJSUzI1N... | SoftwareONE Marketplace API Token |
MPT_PRODUCTS_IDS |
PRD-1111-1111 | PRD-1234-1234,PRD-4321-4321 | Comma-separated list of SoftwareONE Marketplace Product ID |
MPT_PORTAL_BASE_URL |
http://localhost:8000 |
https://portal.softwareone.com |
SoftwareONE Marketplace Portal URL |
MPT_ORDERS_API_POLLING_INTERVAL_SECS |
120 | 60 | Orders polling interval from the Software Marketplace API in seconds |
Example .env file:
EXT_WEBHOOKS_SECRETS={"PRD-1111-1111":"<webhook-secret-for-product>","PRD-2222-2222":"<webhook-secret-for-product>"}
MPT_API_BASE_URL=https://api.s1.show/public
MPT_API_TOKEN=<your-api-token>
MPT_PRODUCTS_IDS=PRD-1111-1111,PRD-2222-2222
MPT_PORTAL_BASE_URL=https://portal.s1.show
Core Components
Extension
The Extension class is the foundation of your MPT extension. It provides:
- Event Registry: Register event listeners for MPT platform events
- API Integration: Built-in Django Ninja API for REST endpoints
import logging
from http import HTTPStatus
from django.conf import settings
from mpt_extension_sdk.core.extension import Extension
from mpt_extension_sdk.core.security import JWTAuth
from mpt_extension_sdk.mpt_http.mpt import get_webhook
from mpt_extension_sdk.runtime.djapp.conf import get_for_product
logger = logging.getLogger(__name__)
ext = Extension()
@ext.events.listener("orders")
def process_order(client, event) -> None:
"""Process order events from MPT."""
logger.info(f"Processing {event.type}")
# Your logic here
def jwt_secret_callback(client, claims):
"""Retrieve webhook secret for JWT validation."""
return "your-webhook-secret"
@ext.api.post(
"/v1/orders/validate",
auth=JWTAuth(jwt_secret_callback),
)
def process_order_validation(request , order):
"""Start order process validation."""
# Your logic here
Pipeline Processing
The SDK includes a pipeline system for building complex processing workflows:
from mpt_extension_sdk.flows.context import Context
from mpt_extension_sdk.flows.pipeline import Pipeline
class ValidateOrderStep:
def process(self, client, context) -> None:
"""Validation Order Step"""
# Your logic here
class ProcessOrderStep:
def process(self, client, context) -> None:
"""Process Order Step"""
# Your logic here
# Build and run pipeline
pipeline = Pipeline(
ValidateOrderStep(),
ProcessOrderStep(),
)
CLI Commands
The SDK provides the swoext CLI for running and managing extensions:
Run Extension
Start the extension server:
swoext run [OPTIONS]
Options:
--bind ADDRESS- Bind address (default:0.0.0.0:8080)--debug- Enable debug mode--color / --no-color- Enable/disable colored output--reload- Enable auto-reload on code changes (development)
Example:
swoext run --bind 0.0.0.0:8080 --debug --reload
Run Event Consumer
Start the event consumer to process MPT events:
swoext run --events
Django Management Commands
Access Django management commands:
swoext django <command> [args]
Integrations
OpenTelemetry Integration
Built-in observability with OpenTelemetry:
- Distributed Tracing: Track requests across services
- Logging Instrumentation: Structured logging with trace context
Configuration:
# Enable Application Insights
USE_APPLICATIONINSIGHTS=true
APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=...
Migration Guide
API Version Change (February 2026)
The MPT Extension SDK now uses the standardized API path /public/v1/ instead of /v1/.
What Changed
- MPTClient now automatically appends
/public/v1/to the base URL - The
MPT_API_BASE_URLenvironment variable should not include any version path
Migration Steps
Before:
# Old configuration (deprecated)
export MPT_API_BASE_URL=https://api.example.com/v1
After:
# New configuration (recommended)
export MPT_API_BASE_URL=https://api.example.com
Backward Compatibility
The SDK maintains backward compatibility with old configurations:
- URLs with
/v1/or/v1will trigger a deprecation warning but continue to work - URLs with
/public/v1are also supported - All formats will produce the correct final URL:
https://api.example.com/public/v1/
Action Required: Update your MPT_API_BASE_URL configuration to remove any version path suffixes.
Development
For development setup, contribution guidelines, and advanced topics, see the README in the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mpt_extension_sdk-5.20.1.tar.gz.
File metadata
- Download URL: mpt_extension_sdk-5.20.1.tar.gz
- Upload date:
- Size: 34.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fbd4dd37b60399d8425b0640b5a8b1957239807da5b90f7f3e6a9e8850f3621
|
|
| MD5 |
3fd191c02213139fff4abff4c90b13a9
|
|
| BLAKE2b-256 |
0081f442b98ea32ca31c942436d3f6a9b2160a1a3b9c5332d78caa175be5e710
|
File details
Details for the file mpt_extension_sdk-5.20.1-py3-none-any.whl.
File metadata
- Download URL: mpt_extension_sdk-5.20.1-py3-none-any.whl
- Upload date:
- Size: 48.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cace07b6dee4c6049ed69bf61a18fc0d9041cc3830a29d7fff1b3e4e07b1cad2
|
|
| MD5 |
8ae4e10f518b00fcdd1d89a84cb138e0
|
|
| BLAKE2b-256 |
68966df6dfec9538d6548472b5c722da439842cb0e071096f29e3d92992e14c2
|