Local Development
Learn how to develop custom integrations for Tracecat locally.
We recommend installing uv, which is a fast Python package and project manager, before starting this tutorial.
Interested in contributing to the official Tracecat Registry? Check out the contributing guide on GitHub for more information.
All accepted contributions are then maintained by the Tracecat team!
Prerequisites
- A local Tracecat Docker Compose deployment
- Python 3.12
- A python package manager (e.g. pip or uv)
- (Recommended) A new isolated Python environment
Linting
You can safely skip this section if you do not need automatic linting and formatting. This setup, however, is required for contributors.
Tracecat uses ruff and pre-commit hooks for linting and formatting code.
The easiest way to set up both ruff and pre-commit is to cd
into the custom-integrations-starter-kit
directory, add the following .pre-commit-config.yaml
file:
Then run the following commands:
The pre-commit hooks will run automatically when you commit code to your local repository. Linting helps keep code consistent according to best practices.
Integrations Starter Kit
The recommended way to start developing custom integrations is to use the integrations starter kit.
Create new repo
The first step is to create a new repo from the custom-integrations-starter-kit template.
Install package and tracecat_registry
The starter kit is a Python package with a pyproject.toml
file.
To install it, run the following command:
This -e
flag installs the package in editable mode, which allows you to make changes to the package and have them reflected immediately.
The .[dev]
flag installs the development dependencies, which includes the tracecat
and tracecat_registry
[Python packages].
Find out more about the tracecat_registry
package below.
Setup development environment
The final step is to link the local registry to your local Tracecat instance. Step-by-step instructions are available in the development environment section below.
Tracecat Registry
tracecat_registry
requires tracecat
to be installed.
For advanced users, you can install tracecat
and tracecat_registry
manually with the following commands:
Installing tracecat_registry
will give you access to the tc
CLI, which is used to validate your templates before syncing and running them in Tracecat.
It also includes the tracecat_registry
package, which contains necessary imports for building Tracecat Python UDFs.
Validation CLI
We highly recommend using this CLI to validate your templates before syncing and running them in Tracecat.
This will save you a lot of time debugging syntax issues.
To check if your templates are valid, run the following command:
Local testing
registry.register
, Annotated
, Doc
, and RegistrySecret
are used to convert your Python function arguments into Tracecat action inputs.
They do not affect the function’s behavior in Python. You can continue using the function as normal in your scripts and tests.
Development Environment
This tutorial assumes you have a local Tracecat Docker Compose deployment.
This is for local development only.
For production, please sync your custom integrations into Tracecat from a secure remote repository (e.g. GitHub, GitLab). Check out the custom integrations tutorial for more information.
You can point Tracecat to your local registry by setting the following environment variables in your .env
file:
Don’t forget to restart Tracecat:
Action templates and Python UDFs will be hot loaded into your Tracecat instance. Changes in your local registry are automatically reflected in Tracecat. No sync is required.
Was this page helpful?