Build a Tool using Kubiya SDK
Use Kubiya's SDK to build tools that extend your Teammate's functionality
To build a tool for your AI Teammates, you can use the Kubiya SDK. In this page, we'll review:
how to get started with the Kubiya SDK
2 of the SDK's basic commands โ
init
andbundle
how you can use these commands to start building, testing, and using tools.
View the Kubiya SDK and its latest version on PyPi: https://pypi.org/project/kubiya-sdk/
Getting started with Kubiya SDK
To begin:
Start with a repo (if you're starting with a new repo, you'll want to make sure it has .gitignore in it)
Make sure the environment you're using โ whether it's a virtual environment or some other โ is activated.
Important: The Kubiya SDK requires a minimum Python version of 3.11 โ if youโre trying to download the SDK and getting errors, check your version first.
Start with uv pip install kubiya-sdk
or regular pip install kubiya-sdk
.
See that everything was installed โ it should be fast because itโs cached. Now, you have a Kubiya command line interface (CLI).
The CLI has a couple commands. The ones weโre going to talk about in this page are kubiya init
and kubiya bundle
.
Init Command: Creating all the files needed for tools
When running kubiya init
, it creates all of the files we need for tools โ shown through two example tools that you can examine and work off of.
After running kubiya init
, you'll notice that it creates a folder, called tools. In the tools folder, you'll find two tools, โfunction toolโ and โhello world toolโ.
Hello world tool โ prints โhelloโ. In its directory, it has the tool definition and everything you need to start with a regular Python tool. You can take it from there, understand how it works, test it, etc.
Function tool โ pretty much the same thing except itโs a decorator that wraps it, making it a little bit easier for people comfortable with Python. As of now (October 2024), a tool wrapped by a decorator must be a Python tool. The tool has a description, requirements, and more โ you can check it out and understand how it works. (The goal of this page is to share more about the init and bundle commands.)
Both of these tools work, so you can load them into Kubiya (as a source) and then execute them from Slack or Microsoft Teams.
Bundle Command: Running Discovery Locally
So far, we've established that we have 2 tools. But how can we know that for sure?
By running kubiya bundle
, which runs Kubiyaโs discovery engine locally.
The bundle command bundles whatever you have in your environment and creates a json file, called kubiya_bundle.json. (This is what happens in the regular discovery on the Kubiya platform, but running it locally allows you to shorten your feedback loops when developing and interating upon your tools.)
When running the bundle command, you can see the tools discovered as well as their arguments, secrets, environment variables, files, and importantly, errors โ in the example tools, there are none.
By running discovery locally via the kubiya bundle
command, you can surface errors more quickly and therefore iterate without pushing to git and going into the Kubiya UI.
Important Notes
Must run bundle command after changes
The file kubiya_bundle.json is critical because it is the file that's checked by discovery. So after you make changes, you must run the kubiya bundle
command in order to update the bundle file. If you don't, the changes you made will not appear when adding/syncing your source in the Kubiya platform.
If you have a bundle, you must re-bundle before syncing in order for changes to go through. Because the UI is actually only looking at the bundle file if you have one.
Location of the kubiya_bundle.json file
Bundle file โ must be in the parent directory of the repo/source link you give. If the bundle file is in the child directory, then you have to give the source URL to that same directory.
Last updated