Skip to main content

Python SDK for building MIRASTACK agents — agentic workflow automation for platform engineering

Project description

mirastack-agents-sdk

Python SDK for building MIRASTACK agents — the external gRPC plugins that perform READ, MODIFY, and ADMIN actions on platform engineering systems. Agents are pure compute: they receive params via gRPC and use the EngineContext proxy to interact with the engine.

License: GNU AGPL v3 — see LICENSE.

Installation

pip install mirastack-agents-sdk

Quick Start

from mirastack_sdk import (
    Plugin, PluginInfo, PluginSchema, Action, IntentPattern,
    Permission, DevOpsStage, ExecuteRequest, ExecuteResponse,
    respond_map, serve,
)

class MyAgent(Plugin):
    def info(self) -> PluginInfo:
        return PluginInfo(
            name="my-agent",
            version="0.1.0",
            description="Example observability agent",
            actions=[
                Action(
                    id="query",
                    description="Query metrics for a service",
                    permission=Permission.READ,
                    stages=[DevOpsStage.OBSERVE],
                    input_params=[{"name": "service", "type": "string", "required": True}],
                ),
            ],
            intents=[
                IntentPattern(pattern=r"query.*metrics|show.*metrics", description="Query metrics", priority=1),
            ],
        )

    def schema(self) -> PluginSchema:
        return PluginSchema(actions=self.info().actions)

    async def execute(self, req: ExecuteRequest) -> ExecuteResponse:
        service = req.params.get("service", "")
        return respond_map({"service": service, "status": "ok"})

    async def health_check(self) -> None: pass

    async def config_updated(self, config: dict) -> None: pass

if __name__ == "__main__":
    serve(MyAgent())

Plugin Interface

class Plugin(ABC):
    def info(self) -> PluginInfo: ...
    def schema(self) -> PluginSchema: ...
    async def execute(self, req: ExecuteRequest) -> ExecuteResponse: ...
    async def health_check(self) -> None: ...
    async def config_updated(self, config: dict[str, str]) -> None: ...

Response Helpers

from mirastack_sdk import respond_map, respond_json, respond_error, respond_raw

return respond_map({"metric": 42.0, "service": "api"})   # typed dict response
return respond_json(my_dataclass)                         # any serialisable type
return respond_error("backend unavailable")               # error response
return respond_raw(b'{"raw": "json"}')                    # raw JSON passthrough

Agent-Specific Features

Actions — Tool Catalog Registration

Action(
    id="restart_service",
    description="Restart a Kubernetes deployment",
    permission=Permission.MODIFY,   # READ | MODIFY | ADMIN
    stages=[DevOpsStage.OPERATE],
    input_params=[
        {"name": "namespace",  "type": "string", "required": True},
        {"name": "deployment", "type": "string", "required": True},
    ],
    output_params=[{"name": "status", "type": "string"}],
)

Intent Patterns — Natural Language Routing

IntentPattern(
    pattern=r"restart.*deployment|rollout.*restart",
    description="Restart a Kubernetes deployment",
    priority=10,
)

Prompt Templates

from mirastack_sdk import PromptTemplate

PromptTemplate(
    name="my_agent_analysis",
    description="Analysis prompt contributed to the engine PromptTemplate Store",
    content="Analyse the following data: {{ data }}",
)

Engine Context

from mirastack_sdk import EngineContext

class MyAgent(Plugin):
    def set_engine_context(self, ctx: EngineContext) -> None:
        self._ctx = ctx

    async def execute(self, req: ExecuteRequest) -> ExecuteResponse:
        url   = await self._ctx.get_config("backend.url")
        await   self._ctx.cache_set("key", "value", ttl=300)
        val   = await self._ctx.cache_get("key")
        await   self._ctx.publish_result({"data": val})
        ok    = await self._ctx.request_approval("Proceed?", Permission.MODIFY)
        await   self._ctx.log_event("action_completed", {"action": "query"})

DateTime Utilities

Convert req.time_range to backend-specific formats — never parse time in a plugin:

from mirastack_sdk import datetimeutils

start = datetimeutils.format_epoch_seconds(req.time_range.start_epoch_ms)  # VictoriaMetrics
start = datetimeutils.format_epoch_micros(req.time_range.start_epoch_ms)   # VictoriaTraces
start = datetimeutils.format_rfc3339(req.time_range.start_epoch_ms)        # VictoriaLogs

SDK Components

Module Purpose
plugin.py Plugin ABC, PluginInfo, Action, IntentPattern, PromptTemplate
context.py EngineContext proxy — config, cache, publish, approval, audit log
respond.py respond_map, respond_json, respond_error, respond_raw helpers
serve.py gRPC server bootstrap — call serve(agent) from __main__
datetimeutils.py Time format converters for all MIRASTACK backends
gen/ Hand-written gRPC proto stubs (will be replaced by buf generate)

Environment Variables

Variable Default Description
MIRASTACK_ENGINE_ADDR localhost:50051 Engine gRPC address
MIRASTACK_PLUGIN_PORT 50052 Port this agent listens on

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mirastack_agents_sdk-1.3.0.tar.gz (36.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mirastack_agents_sdk-1.3.0-py3-none-any.whl (36.8 kB view details)

Uploaded Python 3

File details

Details for the file mirastack_agents_sdk-1.3.0.tar.gz.

File metadata

  • Download URL: mirastack_agents_sdk-1.3.0.tar.gz
  • Upload date:
  • Size: 36.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mirastack_agents_sdk-1.3.0.tar.gz
Algorithm Hash digest
SHA256 5ca74f311fa5e6dacd939e4ed3ade3ab0c39b4a809bef6686180b6698bad3ff0
MD5 c8cea06e5e27670d4f97e39639c587da
BLAKE2b-256 22bee9e262a22a3185ee7d6238c547e7f6296d6510adcc536fc86c26b79c86ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for mirastack_agents_sdk-1.3.0.tar.gz:

Publisher: release.yaml on mirastacklabs-ai/mirastack-agents-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mirastack_agents_sdk-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mirastack_agents_sdk-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 187198f487854f6ecdaeb07251dc27170bdff3dcb65e4ff10f3018d5b5b7efaa
MD5 d2b3fb6f6a2f87635a7ff421890d0684
BLAKE2b-256 8210c3bb362f3021b40a4b1dfc6e5ba059f835df606540af34c33661c0a791a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for mirastack_agents_sdk-1.3.0-py3-none-any.whl:

Publisher: release.yaml on mirastacklabs-ai/mirastack-agents-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page