Skip to content

Commit 045ccd6

Browse files
authored
Updating the filter expression description for the tools (#6)
# Updating the filter expression description for the tools ## Changes * Updating the filter expression description for the tools that need it. Each API endpoint will define the supported fields in the description and examples * The common query language expressions and operators are defined now in a separate resource * Adding a default non-root user to the container definition --------- Signed-off-by: S3B4SZ17 <sebastian.zumbado@sysdig.com>
1 parent 4d5f4a4 commit 045ccd6

File tree

18 files changed

+353
-138
lines changed

18 files changed

+353
-138
lines changed

.github/workflows/helm_test.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,20 @@ name: Lint & Test helm chart
44
on:
55
pull_request:
66
branches:
7-
- main
8-
- develop
9-
- feature/**
10-
- release/**
11-
- hotfix/**
7+
- beta
128
paths:
139
- 'charts/**'
1410
push:
1511
branches:
1612
- main
17-
- develop
18-
- feature/**
19-
- release/**
20-
- hotfix/**
13+
- beta
2114
paths:
2215
- 'charts/**'
16+
workflow_call:
17+
workflow_dispatch:
2318

2419
concurrency:
25-
group: '${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
20+
group: 'helm-test-${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
2621
cancel-in-progress: true
2722

2823
jobs:

.github/workflows/publish.yaml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- main
8+
- beta
89
paths:
910
- pyproject.toml
1011
- Dockerfile
@@ -15,7 +16,7 @@ on:
1516
workflow_dispatch:
1617

1718
concurrency:
18-
group: '${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
19+
group: 'publish-${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
1920
cancel-in-progress: true
2021

2122
jobs:
@@ -44,7 +45,7 @@ jobs:
4445
- name: Extract version
4546
id: extract_version
4647
run: |
47-
VERSION=$(grep 'version =' pyproject.toml | sed -e 's/version = "\(.*\)"/\1/')-$(echo $GITHUB_SHA | cut -c1-7)
48+
VERSION=$(grep 'version =' pyproject.toml | sed -e 's/version = "\(.*\)"/\1/')
4849
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
4950
TAG=v$(grep 'version =' pyproject.toml | sed -e 's/version = "\(.*\)"/\1/')
5051
echo "TAG=$TAG" >> "$GITHUB_OUTPUT"
@@ -84,23 +85,34 @@ jobs:
8485
runs-on: ubuntu-latest
8586
needs: push_to_registry
8687
steps:
87-
- name: Check out the repo
88+
- name: Check out repository
8889
uses: actions/checkout@v4
90+
with:
91+
ref: ${{ github.sha }} # required for better experience using pre-releases
92+
fetch-depth: '0' # Required due to the way Git works, without it this action won't be able to find any or the correct tags
8993

9094
- name: Get tag version
9195
id: semantic_release
92-
uses: anothrNick/github-tag-action@1.73.0
96+
uses: anothrNick/github-tag-action@1.71.0
9397
env:
9498
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9599
DEFAULT_BUMP: "patch"
96-
TAG_CONTEXT: ${{ (github.base_ref != 'main') && 'branch' || 'repo' }}
100+
TAG_CONTEXT: 'repo'
101+
WITH_V: true
97102
PRERELEASE_SUFFIX: "beta"
98-
PRERELEASE: ${{ (github.base_ref != 'main') && 'true' || 'false' }}
99-
DRY_RUN: false
100-
INITIAL_VERSION: ${{ needs.push_to_registry.outputs.tag }}
103+
PRERELEASE: ${{ (github.base_ref == 'beta') && 'true' || (github.base_ref == 'main') && 'false' || (github.base_ref == 'integration') && 'false' || 'true' }}
101104

102105
- name: Summary
103106
run: |
104107
echo "## Release Summary
105108
- Tag: ${{ steps.semantic_release.outputs.tag }}
106109
- Docker Image: ghcr.io/sysdiglabs/sysdig-mcp-server:v${{ needs.push_to_registry.outputs.version }}" >> $GITHUB_STEP_SUMMARY
110+
111+
test_helm_chart:
112+
name: Test Helm Chart
113+
needs: push_to_registry
114+
permissions:
115+
contents: read # required for actions/checkout
116+
pull-requests: write # required for creating a PR with the chart changes
117+
uses: ./.github/workflows/helm_test.yaml
118+
secrets: inherit

.github/workflows/test.yaml

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,6 @@
22
name: Test
33

44
on:
5-
push:
6-
branches:
7-
- main
8-
- develop
9-
- feature/**
10-
- release/**
11-
- hotfix/**
12-
paths:
13-
- pyproject.toml
14-
- Dockerfile
15-
- '*.py'
16-
- tests/**
17-
- tools/**
18-
- utils/**
195
pull_request:
206
paths:
217
- pyproject.toml
@@ -25,9 +11,10 @@ on:
2511
- tools/**
2612
- utils/**
2713
workflow_call:
14+
workflow_dispatch:
2815

2916
concurrency:
30-
group: '${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
17+
group: 'tests-${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
3118
cancel-in-progress: true
3219

3320
jobs:
@@ -59,18 +46,18 @@ jobs:
5946
- name: Run Unit Tests
6047
run: make test
6148

62-
pre_release:
63-
name: Tag Release
49+
check_version:
50+
name: Check Version
6451
runs-on: ubuntu-latest
6552
needs: test
6653
permissions:
6754
contents: write # required for creating a tag
6855
steps:
69-
- name: Check out the repo
56+
- name: Check out repository
7057
uses: actions/checkout@v4
7158
with:
72-
ref: ${{ github.head_ref }} # checkout the correct branch name
73-
fetch-depth: 0
59+
ref: ${{ github.sha }} # required for better experience using pre-releases
60+
fetch-depth: '0' # Required due to the way Git works, without it this action won't be able to find any or the correct tags
7461

7562
- name: Extract current version
7663
id: pyproject_version
@@ -80,15 +67,15 @@ jobs:
8067
8168
- name: Get tag version
8269
id: semantic_release
83-
uses: anothrNick/github-tag-action@1.73.0
70+
uses: anothrNick/github-tag-action@1.71.0
8471
env:
8572
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8673
DEFAULT_BUMP: "patch"
87-
TAG_CONTEXT: ${{ (github.base_ref != 'main') && 'branch' || 'repo' }}
74+
TAG_CONTEXT: 'repo'
75+
WITH_V: true
8876
PRERELEASE_SUFFIX: "beta"
89-
PRERELEASE: ${{ (github.base_ref != 'main') && 'true' || 'false' }}
77+
PRERELEASE: ${{ (github.base_ref == 'beta') && 'true' || (github.base_ref == 'main') && 'false' || (github.base_ref == 'integration') && 'false' || 'true' }}
9078
DRY_RUN: true
91-
INITIAL_VERSION: ${{ steps.pyproject_version.outputs.TAG }}
9279

9380
- name: Compare versions
9481
run: |

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ COPY --from=builder --chown=app:app /app/app_config.yaml /app
3333

3434
RUN pip install /app/sysdig_mcp_server.tar.gz
3535

36+
USER 1001:1001
37+
3638
ENTRYPOINT ["sysdig-mcp-server"]

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [Description](#description)
88
- [Quickstart Guide](#quickstart-guide)
99
- [Available Tools](#available-tools)
10+
- [Available Resources](#available-resources)
1011
- [Requirements](#requirements)
1112
- [UV Setup](#uv-setup)
1213
- [Configuration](#configuration)
@@ -124,6 +125,13 @@ Get up and running with the Sysdig MCP Server quickly using our pre-built Docker
124125

125126
</details>
126127

128+
### Available Resources
129+
130+
- Sysdig Secure Vulnerability Management Overview:
131+
- VM documentation based on the following [url](https://docs.sysdig.com/en/sysdig-secure/vulnerability-management/)
132+
- Sysdig Filter Query Language Instructions:
133+
- Sysdig Filter Query Language for different API endpoint filters
134+
127135
## Requirements
128136

129137
### UV Setup

charts/sysdig-mcp/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ type: application
2020
# This is the chart version. This version number should be incremented each time you make changes
2121
# to the chart and its templates, including the app version.
2222
# Versions are expected to follow Semantic Versioning (https://semver.org/)
23-
version: 0.1.1
23+
version: 0.1.2
2424

2525
# This is the version number of the application being deployed. This version number should be
2626
# incremented each time you make changes to the application. Versions are not expected to
2727
# follow Semantic Versioning. They should reflect the version the application is using.
2828
# It is recommended to use it with quotes.
29-
appVersion: "0.1.1"
29+
appVersion: "v0.1.2"

charts/sysdig-mcp/values.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ image:
88
repository: ghcr.io/sysdiglabs/sysdig-mcp-server
99
pullPolicy: IfNotPresent
1010
# Overrides the image tag whose default is the chart appVersion.
11-
tag: "v0.1.1-e789d6e"
11+
tag: "v0.1.2"
1212

1313
imagePullSecrets: []
1414
nameOverride: ""
@@ -46,13 +46,11 @@ podLabels: {}
4646
podSecurityContext: {}
4747
# fsGroup: 2000
4848

49-
securityContext: {}
50-
# capabilities:
51-
# drop:
52-
# - ALL
53-
# readOnlyRootFilesystem: true
54-
# runAsNonRoot: true
55-
# runAsUser: 1000
49+
securityContext:
50+
readOnlyRootFilesystem: false
51+
runAsNonRoot: true
52+
runAsUser: 1001
53+
runAsGroup: 1001
5654

5755
service:
5856
type: ClusterIP

main.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"""
44

55
import os
6-
import asyncio
6+
import signal
7+
import sys
8+
import logging
79
from dotenv import load_dotenv
810

911
# Application config loader
@@ -12,28 +14,49 @@
1214
# Register all tools so they attach to the MCP server
1315
from utils.mcp_server import run_stdio, run_http
1416

17+
# Set up logging
18+
logging.basicConfig(
19+
format="%(asctime)s-%(process)d-%(levelname)s- %(message)s",
20+
level=os.environ.get("LOGLEVEL", "ERROR"),
21+
)
22+
log = logging.getLogger(__name__)
23+
1524
# Load environment variables from .env
1625
load_dotenv()
1726

1827
app_config = get_app_config()
1928

2029

30+
def handle_signals():
31+
def signal_handler(sig, frame):
32+
log.info(f"Received signal {sig}, shutting down...")
33+
os._exit(0)
34+
35+
signal.signal(signal.SIGINT, signal_handler)
36+
signal.signal(signal.SIGTERM, signal_handler)
37+
signal.signal(signal.SIGHUP, signal_handler)
38+
39+
2140
def main():
2241
# Choose transport: "stdio" or "sse" (HTTP/SSE)
42+
handle_signals()
2343
transport = os.environ.get("MCP_TRANSPORT", app_config["mcp"]["transport"]).lower()
24-
print("""
44+
log.info("""
2545
▄▖ ▌▘ ▖ ▖▄▖▄▖ ▄▖
2646
▚ ▌▌▛▘▛▌▌▛▌ ▛▖▞▌▌ ▙▌ ▚ █▌▛▘▌▌█▌▛▘
2747
▄▌▙▌▄▌▙▌▌▙▌ ▌▝ ▌▙▖▌ ▄▌▙▖▌ ▚▘▙▖▌
2848
▄▌ ▄▌
2949
""")
3050
if transport == "stdio":
3151
# Run MCP server over STDIO (local)
32-
asyncio.run(run_stdio())
52+
run_stdio()
3353
else:
3454
# Run MCP server over streamable HTTP by default
3555
run_http()
3656

3757

3858
if __name__ == "__main__":
39-
main()
59+
try:
60+
sys.exit(main())
61+
except KeyboardInterrupt:
62+
os._exit(0)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "sysdig-mcp-server"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
description = "Sysdig MCP Server"
55
readme = "README.md"
66
requires-python = ">=3.12"

tests/conftest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
from fastmcp import FastMCP
77

88

9+
class MockMCP(FastMCP):
10+
"""
11+
Mock class for FastMCP
12+
"""
13+
14+
pass
15+
16+
917
def util_load_json(path):
1018
"""
1119
Utility function to load a JSON file from the given path.
@@ -42,8 +50,8 @@ def mock_ctx():
4250
Returns:
4351
Context: A mocked Context object with 'fastmcp' tags.
4452
"""
45-
fastmcp: FastMCP = FastMCP(
46-
name="Test",
53+
54+
fastmcp: MockMCP = MockMCP(
4755
tags=["sysdig", "mcp", "stdio"],
4856
)
4957
ctx = Context(fastmcp=fastmcp)

0 commit comments

Comments
 (0)