From 09b834f070f2f75c42f78c70ce5587169fab7106 Mon Sep 17 00:00:00 2001 From: Mladen Todorovic Date: Fri, 31 Oct 2025 11:55:16 +0100 Subject: [PATCH] Setup GitHub repository --- .github/CODE_OF_CONDUCT.md | 3 ++ .github/CONTRIBUTING.md | 71 ++++++++++++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 7 ++++ .gitignore | 10 +++++ README.md | 41 ++++++++++++++++++ cmd/stackrox-mcp/main.go | 16 +++++++ cmd/stackrox-mcp/main_test.go | 13 ++++++ go.mod | 17 ++++++++ go.sum | 25 +++++++++++ 9 files changed, 203 insertions(+) create mode 100644 .github/CODE_OF_CONDUCT.md create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .gitignore create mode 100644 README.md create mode 100644 cmd/stackrox-mcp/main.go create mode 100644 cmd/stackrox-mcp/main_test.go create mode 100644 go.mod create mode 100644 go.sum diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..a26685e --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# Code of Conduct + +The Stackrox code of conduct can be found [here](https://stackrox.io/code-conduct). diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..b1c3e24 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,71 @@ +# Contributing to StackRox MCP + +Thank you for your interest in contributing to StackRox MCP! This document provides guidelines and instructions for contributing to the project. + +## Development Guidelines + +### Code Quality Standards + +All code must pass the following checks before being merged: + +- **Formatting:** Run `go fmt ./...` to format your code +- **Linting:** Run `golint ./...` to check for style issues +- **Vetting:** Run `go vet ./...` to check for suspicious constructs +- **Testing:** All tests must pass with `go test ./...` + +These checks are automatically run in CI for all pull requests. + +### Testing + +- Write unit tests for all new functionality +- Aim for 80% code coverage +- All error paths tested +- Run tests with coverage: + ```bash + go test -cover ./... + ``` +- Generate detailed coverage report: + ```bash + go test -coverprofile=coverage.out ./... + go tool cover -html=coverage.out + ``` + +## Pull Request Guidelines + +### Creating a PR + +- **Title:** + - The title of your PR should be clear and descriptive. + - It should be short enough to fit into the title box. + - **PR addresses JIRA ticket:** `ROX-1234: Add feature ABC` + - **Otherwise use conventional commit style:** `(): ` + - Types: `fix`, `docs`, `test`, `refactor`, `chore`, `ci` + - Example: `fix(builds): Fix builds for ABC architecture` + +- **Description:** + - Describe the motivation for this change, or why some things were done a certain way. + - Focus on what cannot be extracted from the code, e.g., alternatives considered and dismissed (and why), performance concerns, non-evident edge cases. + +- **Validation:** + - Provide information that can help the PR reviewer test changes and validate they are correct. + - In some cases, it will be sufficient to mention that unit tests are added and they cover the changes. + - In other cases, testing may be more complex, and providing steps on how to set up and test everything will be very valuable for reviewers. + +### Merging a PR + +- Make sure that **all CI statuses are green**. +- Always use `Squash and merge` as the merging mode (default). +- Double-check that the title of the commit ("subject line") is **your PR title**, followed by the PR number prefixed with a `#` in parentheses. +- Merge commit message example: `ROX-1234: Add feature ABC (#5678)`. +- The body of the commit message should be empty. If GitHub pre-populates it, delete it. + +## Code Review Process + +- All PRs require at least one approval before merging +- Address all reviewer comments and suggestions +- Keep PRs focused and reasonably sized +- Respond to feedback in a timely manner + +## License + +By contributing to StackRox MCP, you agree that your contributions will be licensed under the Apache License 2.0. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..a09dd44 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ +### Description + + + +### Validation + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..93e797a --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# IDE and editor files +.vscode/ +.idea/ +.DS_Store + +# Test coverage output +/*.out + +# Build output +/stackrox-mcp diff --git a/README.md b/README.md new file mode 100644 index 0000000..f912428 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# StackRox MCP + +## Project Overview + +StackRox MCP is a Model Context Protocol (MCP) server that provides AI assistants with access to StackRox. + +## Quick Start + +Clone the repository: +```bash +git clone https://github.com/stackrox/stackrox-mcp.git +cd stackrox-mcp +``` + +Build the project: +```bash +go build -o stackrox-mcp ./cmd/stackrox-mcp +``` + +Run the server: +```bash +./stackrox-mcp +``` + +## How to Run Tests + +Run all unit tests: +```bash +go test ./... +``` + +Run tests with coverage: +```bash +go test -cover ./... +``` + +Generate detailed coverage report: +```bash +go test -coverprofile=coverage.out ./... +go tool cover -html=coverage.out +``` diff --git a/cmd/stackrox-mcp/main.go b/cmd/stackrox-mcp/main.go new file mode 100644 index 0000000..efb7af0 --- /dev/null +++ b/cmd/stackrox-mcp/main.go @@ -0,0 +1,16 @@ +package main + +import ( + "github.com/rs/zerolog" + "github.com/rs/zerolog/log" +) + +func setupLogging() { + zerolog.SetGlobalLevel(zerolog.InfoLevel) +} + +func main() { + setupLogging() + + log.Info().Msg("Starting Stackrox MCP server") +} diff --git a/cmd/stackrox-mcp/main_test.go b/cmd/stackrox-mcp/main_test.go new file mode 100644 index 0000000..da7d878 --- /dev/null +++ b/cmd/stackrox-mcp/main_test.go @@ -0,0 +1,13 @@ +package main + +import ( + "testing" + + "github.com/rs/zerolog" + "github.com/stretchr/testify/assert" +) + +func TestSetupLogging(t *testing.T) { + setupLogging() + assert.Equal(t, zerolog.InfoLevel, zerolog.GlobalLevel()) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1ea4908 --- /dev/null +++ b/go.mod @@ -0,0 +1,17 @@ +module github.com/stackrox/stackrox-mcp + +go 1.24 + +require ( + github.com/rs/zerolog v1.33.0 + github.com/stretchr/testify v1.11.1 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/sys v0.12.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..d2d5a0d --- /dev/null +++ b/go.sum @@ -0,0 +1,25 @@ +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=