Quick Start

Get a plugin running in under five minutes.

1. Install the SDK

pip install kbs-plugin-sdk-python

2. Create a plugin

Create my_plugin.py:

import asyncio
import logging
from kbs_plugin_sdk import PluginHandler, PluginServer, PluginRequest, PluginResponse

logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s")

class MyPlugin(PluginHandler):
    async def handle(self, request: PluginRequest) -> PluginResponse:
        body = f"path={list(request.path)} method={request.method}".encode()
        return PluginResponse(body=body, status_code=200, content_type="text/plain")

async def main():
    server = PluginServer(MyPlugin()).with_address("0.0.0.0:50051")
    await server.serve()

asyncio.run(main())

3. Run it

python my_plugin.py

You will see:

WARNING Starting plugin server WITHOUT TLS on 0.0.0.0:50051 — insecure, do not use in production
INFO Plugin server started on 0.0.0.0:50051

The TLS warning is expected for local development. See Usage → TLS to enable TLS for production.

What happens next

KBS connects to your plugin over gRPC. When a request comes in for your plugin's registered path, KBS calls Handle on your server and forwards the response back to the original HTTP client.

See Usage for the full API reference.