Custom scripts via Kriten MCP
This blog explains how to integrate a custom Python script into Kriten and make it accessible to the AI Agent through Kriten MCP.
For more information, refer to the Kriten documentation at https://kriten.io.
In the lab, we have a topology consisting of 2 Arista spines, 4 leaf switches, and 1 border switch, all managed via CVaaS (the cloud version of CVP). We have created a Python health check script that retrieves inventory from CVaaS, connects to each Arista switch, gathers a set of health metrics, and reports them in JSON format.
The script is available in our public repository: https://github.com/kriten-io/kriten-community-toolkit within the "arista-health" directory.
The script requires 4 parameters to be set as environmental variables:
Tacacs credentials: USERNAME and PASSWORD;
CVaaS access details: CVP_URL and CVP_TOKEN;
Create a Runner (using Kriten UI):

The script only requires the additional Python package "requests"; all other dependencies are part of the standard library. For the demo, we will use the container image kubecodeio/ansible-13.3.0:0.1 from Docker Hub. We have provided 4 secrets, which will be accessible to the running script as environment variables. These secrets are obfuscated by Kriten in the UI or through the REST API.
Create a task
That step exposes aristahealth.py script as a task, which can be executed via UI or via Rest API by the authorized user.

The task requires selecting the "healthbeats" Runner configured earlier and specifying the command to run the script, including its path and any necessary parameters. If the script needs parameters at execution time, the OpenAPI schema (in JSON) can define these parameters for self-documentation. These parameters will be validated against the schema and, if validated successfully, will be passed to the running job as an EXTRA_VARS environment variable in JSON string format. Since this script doesn't need parameters, we will leave the schema empty.
That's all— the script is now onboarded and ready for execution. There were no changes to the original custom script; it can still be executed from the command line as before.
Please refer to the documentation for configuring RBAC. We will skip this step for now and execute it as the Kriten admin user (root).
Executing task

That would execute task and create Kubernetes Job.
Job result:

The result output is shortened due to the lengthy output from 6 Arista switches.
We now want to integrate it with MCP. Initially, the AI agent must connect to Kriten MCP using a static API token associated with a Kriten user. The AI agent can only access tasks that the user is authorized to "execute." Additionally, each task must include a description, and any required parameters must be specified in the task's OpenAPI schema.
We will employ OpenCode as the AI agent, which has been set up to access Kriten MCP. The API token belongs to the Kriten admin user (root), granting the AI agent permission to execute the arista-health task.
Let's examine which Kriten tasks are currently available for the Agent to execute.

Our custom script task is not yet available; we need to add a description using Schema, or the agent won't understand its function.

There's no need to restart anything; just reconnect the agent. Similarly, if the script is modified, the new version will be retrieved during execution.
Now, let's check the tasks available via Kriten MCP again:

As we can observe, the arista-health task is now accessible with the description we included in the Schema.
We can now request the Agent to execute arista-health and summarize the findings.

We have shown how an AI agent effectively interacted with a single task using Kriten MCP. By allowing more custom scripts to be accessible as tasks, we can create more complex scenarios, such as performing a health check and, if any issues are detected, raising a support ticket, sending a Slack message, and more.



