Plugin SDK

The Plugin SDK (@allternit/plugin-sdk) is a universal runtime for authoring plugins once and deploying them across multiple surfaces. It defines a single plugin contract, then adapts that contract to Model Context Protocol (MCP) servers, HTTP APIs, terminal/CLI workflows, editor extensions, and the native Allternit runtime.

Overview

Use the Plugin SDK when you want to:
  • Package domain logic as a reusable plugin with a typed manifest.
  • Expose plugin functions over MCP, HTTP, or a command-line interface.
  • Build plugins that degrade gracefully when host capabilities differ.
  • Run the same plugin inside the Allternit platform and on external surfaces.

Installation

For global CLI usage:
Requires Node.js 18 or later.

Quick start

Create a plugin from the CLI

Programmatic usage

Key concepts

Plugin manifest

Every plugin declares its identity, required host capabilities, and exposed functions through a PluginManifest. The manifest is the contract that adapters use to expose the plugin on each surface.

PluginHost interface

PluginHost is the universal runtime contract passed to a plugin during initialization. It abstracts the underlying platform so plugin code can use LLM completions, tools, UI rendering, storage, and logging without knowing which surface is running it.

Adapters

Adapters map the universal plugin contract to a specific surface. The SDK ships with adapters for the most common deployment patterns. Each adapter implements the Adapter interface:

Plugin lifecycle

Plugins follow a simple lifecycle:
  1. Register — Add the plugin to a PluginRegistry.
  2. Initialize — The adapter calls plugin.initialize(host).
  3. Execute — The adapter routes incoming requests to plugin.execute(functionName, params, context).
  4. Destroy — The adapter calls plugin.destroy() on shutdown.

Running a plugin

As an MCP server

Configure an MCP client to point at the generated server command.

As an HTTP API

Call the API:
The HTTP adapter also supports WebSocket execution and Server-Sent Events for streaming results.

In the Allternit runtime

From a terminal script

Utility helpers

The SDK exports helpers for manifest validation, manifest loading, and plugin packaging.

Error handling

Adapters return structured ExecutionResult objects. Check result.success before reading result.content or result.data.