← Back to Pull requests

[DNM] feat: skills over MCP #73

Open
Cali0707 opened this pull request with 1863 lines diff across 115 files
View on GitHub
Cali0707 Cali0707 commented on Dec 02, 2026 20:58 UTC
Author

This moves our skills to being server over MCP.

Note that this is a hacky proof of concept branch! It needs cleanup before being mergeable.

Diff: 1863 lines (+1626 / -237) across 115 files Reviewer: matzew Review duration: 3083m
All Vouch review confidence checks passed
Residual risk 0.08 = Change Risk (0.72) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.72 · 1863 lines diff across 115 files
0.72
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.89 · 5 substantive comment(s)
0.89
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
89%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.400
Mass File Touch mass_file_touch
0.080
Real PR Conversation Timeline
9 items
openshift-ci[bot] openshift-ci[bot] commented on Dec 02, 2026 20:59 UTC
Bot

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: <a href="https://github.com/openshift/agentic-skills/pull/73#" title="Author self-approved">Cali0707</a>

The full list of commands accepted by this bot can be found here.

The pull request process is described here

<details >
Needs approval from an approver in each of these files:

  • ~~OWNERS~~ [Cali0707]
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":[]} -->

    openshift-ci[bot] openshift-ci[bot] commented on Dec 02, 2026 21:16 UTC
    Bot

    @Cali0707: all tests passed!

    Full PR test history. Your PR dashboard.

    <details>

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.
    </details>
    <!-- test report -->

    matzew matzew commented on code on Dec 03, 2026 13:31 UTC
    Code Review
    pkg/docs/docs.go:1
    @@ -0,0 +1,80 @@
    +// Package docs runs basic read-only commands against a documentation directory.
    +package docs
    +
    +import (
    +	"bytes"
    +	"context"
    +	"errors"
    +	"fmt"
    +	"os"
    +	"os/exec"
    +	"path/filepath"
    +	"time"
    +)
    +
    +// DirectoryEnv configures the working directory for documentation commands.
    +const DirectoryEnv = "DOCS_DIR"
    +
    +// Runner executes ls and grep with the configured documentation directory as cwd.
    +type Runner struct {
    +	directory string
    +}
    +
    +// Result includes command output and its exit code. In particular, grep returns
    +// exit code 1 when no lines match; this is a command result, not a runner error.
    +type Result struct {
    +	Stdout   string `json:"stdout"`
    +	Stderr   string `json:"stderr"`
    +	ExitCode int    `json:"exitCode"`
    +}
    +
    +// New reads DOCS_DIR and checks that it points to an existing directory.
    +func New() (*Runner, error) {
    +	directory := os.Getenv(DirectoryEnv)
    +	if directory == "" {
    +		return nil, fmt.Errorf("%s must be set", DirectoryEnv)
    +	}
    +	directory, err := filepath.Abs(directory)
    +	if err != nil {
    +		return nil, fmt.Errorf("resolve %s: %w", DirectoryEnv, err)
    +	}
    +	info, err := os.Stat(directory)
    +	if err != nil {
    +		return nil, fmt.Errorf("open docs directory: %w", err)
    +	}
    +	if !info.IsDir() {
    +		return nil, fmt.Errorf("docs path %q is not a directory", directory)
    +	}
    +	return &Runner{directory: directory}, nil
    +}
    +
    +// Run accepts only the exact command names ls and grep. Arguments are passed
    +// directly to the executable, never through a shell: substitutions, redirections,
    +// and command chaining are not interpreted. Arguments retain the command's normal
    +// path semantics; setting cwd does not provide filesystem confinement.
    +func (r *Runner) Run(ctx context.Context, command string, args []string) (Result, error) {
    +	if command != "ls" && command != "grep" {
    +		return Result{}, fmt.Errorf("unsupported docs command %q: use ls or grep", command)
    +	}
    +	ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
    +	defer cancel()
    +
    +	cmd := exec.CommandContext(ctx, command, args...)
    +	cmd.Dir = r.directory

    Could we make DOCS_DIR a filesystem boundary before exposing this over HTTP? cmd.Dir sets the working directory, but caller-supplied ls and grep arguments can still reach files elsewhere that the server process can read. A docs-specific list/read/search interface could confine access to the corpus, including when resolving symlinks.

    matzew matzew commented on code on Dec 03, 2026 13:31 UTC
    Code Review
    pkg/docs/docs.go:1
    @@ -0,0 +1,80 @@
    +// Package docs runs basic read-only commands against a documentation directory.
    +package docs
    +
    +import (
    +	"bytes"
    +	"context"
    +	"errors"
    +	"fmt"
    +	"os"
    +	"os/exec"
    +	"path/filepath"
    +	"time"
    +)
    +
    +// DirectoryEnv configures the working directory for documentation commands.
    +const DirectoryEnv = "DOCS_DIR"
    +
    +// Runner executes ls and grep with the configured documentation directory as cwd.
    +type Runner struct {
    +	directory string
    +}
    +
    +// Result includes command output and its exit code. In particular, grep returns
    +// exit code 1 when no lines match; this is a command result, not a runner error.
    +type Result struct {
    +	Stdout   string `json:"stdout"`
    +	Stderr   string `json:"stderr"`
    +	ExitCode int    `json:"exitCode"`
    +}
    +
    +// New reads DOCS_DIR and checks that it points to an existing directory.
    +func New() (*Runner, error) {
    +	directory := os.Getenv(DirectoryEnv)
    +	if directory == "" {
    +		return nil, fmt.Errorf("%s must be set", DirectoryEnv)
    +	}
    +	directory, err := filepath.Abs(directory)
    +	if err != nil {
    +		return nil, fmt.Errorf("resolve %s: %w", DirectoryEnv, err)
    +	}
    +	info, err := os.Stat(directory)
    +	if err != nil {
    +		return nil, fmt.Errorf("open docs directory: %w", err)
    +	}
    +	if !info.IsDir() {
    +		return nil, fmt.Errorf("docs path %q is not a directory", directory)
    +	}
    +	return &Runner{directory: directory}, nil
    +}
    +
    +// Run accepts only the exact command names ls and grep. Arguments are passed
    +// directly to the executable, never through a shell: substitutions, redirections,
    +// and command chaining are not interpreted. Arguments retain the command's normal
    +// path semantics; setting cwd does not provide filesystem confinement.
    +func (r *Runner) Run(ctx context.Context, command string, args []string) (Result, error) {
    +	if command != "ls" && command != "grep" {
    +		return Result{}, fmt.Errorf("unsupported docs command %q: use ls or grep", command)
    +	}
    +	ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
    +	defer cancel()
    +
    +	cmd := exec.CommandContext(ctx, command, args...)
    +	cmd.Dir = r.directory
    +	var stdout, stderr bytes.Buffer
    +	cmd.Stdout = &stdout

    Could we cap matches and output bytes as we collect them? A broad recursive search can buffer much of the bundled corpus in memory, and concurrent calls multiply that cost. It would help to tell clients when results were truncated.

    matzew matzew commented on code on Dec 03, 2026 13:31 UTC
    Code Review
    Containerfile.mcp:1
    @@ -0,0 +1,36 @@
    +ARG BUILDER_IMAGE=registry.redhat.io/ubi9/go-toolset:1.26
    +ARG BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal:latest
    +
    +FROM --platform=$BUILDPLATFORM ${BUILDER_IMAGE} AS builder
    +ARG TARGETOS=linux
    +ARG TARGETARCH
    +
    +USER 0
    +WORKDIR /workspace
    +ENV GOTOOLCHAIN=go1.26.11
    +
    +COPY go.mod go.sum ./
    +RUN go mod download
    +COPY . .
    +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
    +    go build -trimpath -o /workspace/skills-mcp ./cmd/skills-mcp
    +
    +FROM ${BASE_IMAGE}
    +
    +RUN microdnf install -y coreutils-single grep && microdnf clean all
    +
    +COPY --from=builder /workspace/skills-mcp /usr/local/bin/skills-mcp
    +COPY documentation/openshift-docs/docs/ /docs/openshift-docs/docs/
    +COPY documentation/kubernetes-docs/docs/ /docs/kubernetes-docs/docs/
    +COPY LICENSE /licenses/LICENSE
    +
    +ENV DOCS_DIR=/docs
    +WORKDIR /docs
    +USER 65532:65532
    +
    +LABEL distribution-scope="public" \
    +      url="https://github.com/openshift/agentic-skills" \
    +      io.modelcontextprotocol.server.name="io.github.openshift/agentic-skills"
    +
    +EXPOSE 8080
    +ENTRYPOINT ["/usr/local/bin/skills-mcp"]

    Could we build the MCP image in Prow and smoke-test it over HTTP? The current jobs cover the skills image, Python tests, and skill scanning. Starting this image, discovering a skill, reading a supporting file, and querying the packaged docs would cover the new delivery path. I’d also exercise a script-backed skill through the intended Claude setup before shipping.

    matzew matzew commented on code on Dec 03, 2026 13:31 UTC
    Code Review
    pkg/server/skills.go:1
    @@ -0,0 +1,144 @@
    +package server
    +
    +import (
    +	"bytes"
    +	"context"
    +	"crypto/sha256"
    +	"fmt"
    +	"io/fs"
    +	"mime"
    +	"net/http"
    +	"path"
    +	"unicode/utf8"
    +
    +	"github.com/modelcontextprotocol/go-sdk/extensions/skills"
    +	"github.com/modelcontextprotocol/go-sdk/mcp"
    +	"go.yaml.in/yaml/v3"
    +)
    +
    +func registerSkills(server *mcp.Server, files fs.FS) error {
    +	var entries []*skills.Skill
    +	err := fs.WalkDir(files, ".", func(name string, d fs.DirEntry, err error) error {
    +		if err != nil {
    +			return err
    +		}
    +		if d.IsDir() || d.Name() != "SKILL.md" {
    +			return nil
    +		}
    +		entry, err := registerSkill(server, files, path.Dir(name))
    +		if err != nil {
    +			return fmt.Errorf("load %s: %w", name, err)
    +		}
    +		entries = append(entries, entry)
    +		return nil
    +	})
    +	if err != nil {
    +		return err
    +	}
    +	return skills.Add(server, entries, &skills.ServerOptions{Limits: skills.BaselineLimits()})
    +}
    +
    +func registerSkill(server *mcp.Server, files fs.FS, directory string) (*skills.Skill, error) {
    +	contents, err := loadSkillFiles(files, directory)
    +	if err != nil {
    +		return nil, err
    +	}
    +	entry, err := buildSkillEntry(directory, contents)
    +	if err != nil {
    +		return nil, err
    +	}
    +	for _, file := range contents {
    +		registerSkillResource(server, entry, file)
    +	}
    +	return entry, nil
    +}
    +
    +type skillFile struct {
    +	name string
    +	data []byte
    +}
    +
    +func loadSkillFiles(files fs.FS, directory string) ([]skillFile, error) {
    +	var contents []skillFile
    +	err := fs.WalkDir(files, directory, func(name string, d fs.DirEntry, err error) error {
    +		if err != nil {
    +			return err
    +		}
    +		if d.IsDir() {
    +			return nil
    +		}
    +		data, err := fs.ReadFile(files, name)
    +		if err != nil {
    +			return err
    +		}
    +		contents = append(contents, skillFile{name: name, data: data})

    Do we expect to ship this through a Claude connector that scans skills? The argo-repo-audit bundle is about 4.5 MB and includes two JSON schemas over 1 MB each. That exceeds the scanned-skill limits of 100 KB per text file and 400 KB per skill.

    matzew matzew commented on code on Dec 03, 2026 13:31 UTC
    Code Review
    skills/documentation/openshift-docs/SKILL.md:1
    @@ -11,6 +11,18 @@ Search and read pre-generated OpenShift Container Platform documentation. Docs a
     
     ## Quick Start
     
    +### Access over MCP
    +
    +When loaded over MCP, use `docs_command` to access the documentation corpus on the
    +server. Start with `{"command":"ls","args":[]}` to discover its layout. When
    +`DOCS_DIR` points to this repository's `documentation/` directory, use:
    +
    +- List versions: `{"command":"ls","args":["openshift-docs/docs"]}`
    +- Search the index: `{"command":"grep","args":["-ni","networking","openshift-docs/docs/4.22/AGENTS.md"]}`
    +- Read a file: `{"command":"grep","args":["-n","^","openshift-docs/docs/4.22/networking/index.md"]}`

    Could this example use networking/networking_overview/understanding-networking.md? The packaged 4.22 corpus contains that page, and the current networking/index.md path is absent.

    matzew matzew commented on Dec 03, 2026 13:31 UTC
    Reviewer

    go:embed ties skill updates to an MCP server image rebuild. If MCP Lifecycle can deploy a new image digest independently of the RHOAI release, that may already give us the release cadence we want. Do we also need to update skills while keeping the server image fixed? That’s the case where a separate OCI bundle would help.

    Reviewers
    Assignees
    Cali0707 Cali0707
    Labels
    risk: low confidence: 89.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 71.5% (HIGH) · Higher = larger blast radius
    71.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.3% · Lower = rushed or shallow review
    89.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.7% · Safe to merge
    7.7%