feat(tekton): add Tekton toolset with pipeline and task management#892
feat(tekton): add Tekton toolset with pipeline and task management#892nader-ziada merged 2 commits intocontainers:mainfrom
Conversation
|
/hold Need reviews from tekton people |
README.md
Outdated
| - **Uninstall** a Helm release in the current or provided namespace. | ||
| - **🔧 Tekton**: Tekton-specific operations that complement generic Kubernetes resource management. | ||
| - **Pipeline**: Start a Tekton Pipeline by creating a PipelineRun. | ||
| - **PipelineRun**: Restart a PipelineRun with the same spec, or bulk-delete PipelineRuns with selectors. |
There was a problem hiding this comment.
This PR does not have bulk-delete implemented, maybe a missed commit ?
There was a problem hiding this comment.
Many actions can be done with general tools which are already implemented in this MCP server. If you think we will need some special delete function, then we can add it 👍
There was a problem hiding this comment.
Maybe we can start here with an eval task to see if it is needed?
| } | ||
|
|
||
| logs := "" | ||
| for _, step := range tr.Status.Steps { |
There was a problem hiding this comment.
we should get logs for sidecars as well
README.md
Outdated
|
|
||
| <summary>tekton</summary> | ||
|
|
||
| > **Note**: Generic CRUD operations (list, get, create, update, delete) for Tekton resources (Pipeline, PipelineRun, Task, TaskRun) are available via the `core` toolset's `resources_list`, `resources_get`, `resources_create_or_update`, and `resources_delete` tools using `apiVersion: tekton.dev/v1`. |
There was a problem hiding this comment.
https://github.com/containers/kubernetes-mcp-server/blob/main/pkg/toolsets/core/resources.go#L115
don't think resources_delete supports bulk deletion using label selectors
3f6be06 to
77551d2
Compare
| "github.com/containers/kubernetes-mcp-server/pkg/toolsets/tekton" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) |
There was a problem hiding this comment.
test should be grouped via testify/suite, like:
type TektonSuite struct {
suite.Suite
}|
/hold #917 should be merged first |
pkg/toolsets/tekton/taskrun.go
Outdated
| req := params.KubernetesClient.CoreV1().Pods(namespace).GetLogs(tr.Status.PodName, &corev1.PodLogOptions{ | ||
| Container: step.Container, | ||
| }) | ||
| stream, err := req.Stream(params.Context) |
There was a problem hiding this comment.
io.ReadAll reads without bound. A chatty step could return hundreds of MB, hitting LLM context limits or OOMing the server.
Suggest capping per step:
const maxStepLogBytes = 1 << 20 // 1 MB per step
bytes, err := io.ReadAll(io.LimitReader(stream, maxStepLogBytes))There was a problem hiding this comment.
I didn't look at how it is done directly in the kubernetes mcp server though, but we could re-use code/way of doing.
|
#917 was merged, I think we need to rebase this one now. |
77551d2 to
0d002a3
Compare
|
@manusa the PR is rebased |
8c4d0f2 to
55db285
Compare
|
/run-mcpchecker tekton |
mcpchecker MCP Evaluation ResultsCommit:
|
|
/run-mcpchecker tekton |
1 similar comment
|
/run-mcpchecker tekton |
mcpchecker MCP Evaluation ResultsCommit:
|
| req := params.CoreV1().Pods(namespace).GetLogs(podName, &corev1.PodLogOptions{ | ||
| Container: container, | ||
| }) | ||
| stream, err := req.Stream(params.Context) |
There was a problem hiding this comment.
The log stream should be closed with defer immediately after the error check:
stream, err := req.Stream(params.Context)
if err != nil {
fmt.Fprintf(sb, "[%s: %s] error retrieving logs: %v\n", kind, name, err)
return
}
defer stream.Close()Currently stream.Close() is called manually after io.ReadAll (line 167), but if ReadAll panics the stream leaks. Using defer is the standard Go idiom and is safer.
manusa
left a comment
There was a problem hiding this comment.
Impressive results 🎉 ✅
I've added a few comments for your consideration
55db285 to
46651f6
Compare
|
@ksimon1 can you check why the build is failing on this one ? |
46651f6 to
f012e51
Compare
|
@manusa, @Cali0707, @waveywaves, @vdemeester can you please review this PR? |
nader-ziada
left a comment
There was a problem hiding this comment.
@ksimon1 great work, but one small comment:
When adding a new toolset, you also need to update internal/tools/update-readme/main.go to include the import:
_ "github.com/containers/kubernetes-mcp-server/pkg/toolsets/tekton"
so you can then run make update-readme-tools to regenerate the toolsets tables in README.md and docs/configuration.md.
the new tekton tool set will require its packages. This commit add the tekton pipelines package Code was assisted by Cursor AI. Signed-off-by: Karel Simon <ksimon@redhat.com>
Introduces a new `tekton` toolset exposing 5 domain-specific tools: - tekton_pipeline_start: start a Pipeline (with optional typed params) - tekton_pipelinerun_restart: restart an existing PipelineRun - tekton_task_start: start a Task (with optional typed params) - tekton_taskrun_restart: restart an existing TaskRun - tekton_taskrun_logs: fetch logs from a TaskRun's underlying pod Generic CRUD operations for Tekton resources remain available via the core toolset's resources_* tools. The params argument on start tools supports string, array, and object Tekton parameter types. Includes unit tests, snapshot tests, and README documentation. Code was assisted by Cursor AI. Signed-off-by: Karel Simon <ksimon@redhat.com>
f012e51 to
24a48c1
Compare
|
@nader-ziada it should be fixed now |
thanks @ksimon1 LGTM |
Summary
This PR introduces a new
tektontoolset tokubernetes-mcp-server, exposing domain-specific Tekton operations that go beyond what the genericcoretoolset'sresources_*tools provide. This functionality is required for new Kubevirt functionality.Toolset (
pkg/toolsets/tekton)5 tools are exposed:
tekton_pipeline_starttekton_pipelinerun_restarttekton_task_starttekton_taskrun_restarttekton_taskrun_logsThe
tekton_pipeline_startandtekton_task_starttools accept an optionalparamsargument — a JSON object where values can be strings, arrays of strings, or objects (map of string to string), matching all three TektonParamTypevariants.Generic CRUD operations (list, get, create, update, delete) for Tekton resources remain available via the
coretoolset'sresources_*tools usingapiVersion: tekton.dev/v1.Eval tasks (
evals/tasks/tekton)9 declarative eval tasks validated against a live OpenShift cluster (9/9 passed, 27/27 assertions):
create-tekton-pipeline,create-tekton-taskget-tekton-pipeline,list-tekton-pipelines,list-tekton-pipelinerunsdelete-tekton-pipelinerun,restart-tekton-pipelinerunstart-tekton-pipeline,start-tekton-taskSetup scripts handle a known OpenShift Pipelines quirk: the Tekton Results operator adds
results.tekton.dev/taskrunfinalizers to TaskRuns, which can block namespace termination between tasks. The scripts actively remove these finalizers to ensure clean teardown.The
tektonsuite is registered in bothclaude-codeandopenai-agenteval configurations.Test plan
go test ./pkg/toolsets/tekton/...— all passgo test ./pkg/mcp/...— all pass