docs/mcp-server.md
The Kubescape MCP (Model Context Protocol) Server enables AI assistants to query your Kubernetes cluster's security posture using natural language. It exposes Kubescape's vulnerability and configuration scan data through the MCP protocol.
The MCP server allows AI assistants (like Claude, ChatGPT, or custom AI tools) to:
Before using the MCP server, you need:
helm repo add kubescape https://kubescape.github.io/helm-charts/
helm repo update
helm upgrade --install kubescape kubescape/kubescape-operator \
--namespace kubescape \
--create-namespace \
--set capabilities.vulnerabilityScan=enable \
--set capabilities.configurationScan=enable
Wait for the operator to complete initial scans:
kubectl -n kubescape get vulnerabilitymanifests
kubectl -n kubescape get workloadconfigurationscans
kubescape mcpserver
The server starts and communicates via stdio, making it compatible with MCP-enabled AI tools.
The MCP server exposes the following tools to AI assistants:
list_vulnerability_manifestsDiscover available vulnerability manifests at image and workload levels.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
namespace | string | No | Filter by namespace |
level | string | No | Type of manifests: "image", "workload", or "both" (default) |
Example Response:
{
"vulnerability_manifests": {
"manifests": [
{
"type": "workload",
"namespace": "default",
"manifest_name": "deployment-nginx-nginx",
"image-level": false,
"workload-level": true,
"image-id": "sha256:abc123...",
"image-tag": "nginx:1.21",
"resource_uri": "kubescape://vulnerability-manifests/default/deployment-nginx-nginx"
}
]
}
}
list_vulnerabilities_in_manifestList all vulnerabilities (CVEs) found in a specific manifest.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
namespace | string | No | Namespace of the manifest (default: "kubescape") |
manifest_name | string | Yes | Name of the manifest |
Example Response:
[
{
"id": "CVE-2023-12345",
"severity": "High",
"description": "Buffer overflow in libfoo",
"fix": {
"versions": ["1.2.4"],
"state": "fixed"
}
}
]
list_vulnerability_matches_for_cveGet detailed information about a specific CVE in a manifest, including affected packages and fix information.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
namespace | string | No | Namespace of the manifest (default: "kubescape") |
manifest_name | string | Yes | Name of the manifest |
cve_id | string | Yes | CVE identifier (e.g., "CVE-2023-12345") |
list_configuration_security_scan_manifestsDiscover available security configuration scan results at the workload level.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
namespace | string | No | Filter by namespace (default: "kubescape") |
Example Response:
{
"configuration_manifests": {
"manifests": [
{
"namespace": "default",
"manifest_name": "deployment-nginx",
"resource_uri": "kubescape://configuration-manifests/default/deployment-nginx"
}
]
}
}
get_configuration_security_scan_manifestGet detailed configuration scan results for a specific workload, including failed controls and remediation guidance.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
namespace | string | No | Namespace of the manifest (default: "kubescape") |
manifest_name | string | Yes | Name of the configuration manifest |
run_framework_security_scanRun an on-demand, live Framework security scan (e.g. nsa, mitre) and return the failed resources along with the compliance score. Check the degraded flag in the response to ensure the scan fully completed (e.g. no control timeouts). Note that compliance_score is optional and may be omitted if the scan produces no framework summary. The failed_resources array is truncated at 100 entries; check truncated, total_failed, and returned_failed to understand if the list is partial.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
framework_name | string | Yes | Name of the framework to scan (e.g. nsa, mitre, cis-v1.23-t1.0.1) |
namespace | string | No | Namespace to scope the Framework scan (optional, defaults to cluster-wide if omitted) |
Example Response:
{
"compliance_score": 0,
"framework_name": "nsa",
"degraded": true,
"not_evaluated_controls": 8,
"total_controls": 24,
"total_failed": 5,
"returned_failed": 5,
"truncated": false,
"failed_resources": [{}, {}, {}, {}, {}]
}
run_rbac_security_scanRun an on-demand, live RBAC security scan (evaluating RBAC-related controls) and return the failed resources. The failed_resources array is truncated at 100 entries; check truncated, total_failed, and returned_failed to understand if the list is partial.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
namespace | string | No | Namespace to scope the RBAC scan (optional, defaults to cluster-wide if omitted) |
Example Response:
{
"degraded": false,
"not_evaluated_controls": 0,
"total_controls": 2,
"total_failed": 1,
"returned_failed": 1,
"truncated": false,
"failed_resources": [{}]
}
run_network_security_scanRun an on-demand, live Network security scan (evaluating network-related controls) and return the failed resources. The failed_resources array is truncated at 100 entries; check truncated, total_failed, and returned_failed to understand if the list is partial.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
namespace | string | No | Namespace to scope the Network scan (optional, defaults to cluster-wide if omitted) |
Example Response:
{
"degraded": false,
"not_evaluated_controls": 0,
"total_controls": 1,
"total_failed": 0,
"returned_failed": 0,
"truncated": false,
"failed_resources": []
}
scan_container_imageRun an on-demand container image vulnerability scan and return structured JSON containing deduplicated vulnerabilities, severity counts, and optional match details.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
image_name | string | Yes | Name of the remote container image to scan (e.g. "nginx:alpine") |
username | string | No | Username for registry authentication (optional) |
password | string | No | Password for registry authentication (optional) |
include_matches | boolean | No | Include detailed match location and package info for each vulnerability (optional, default: false) |
severity | string | No | Filter vulnerabilities by minimum severity (e.g. "Low", "Medium", "High", "Critical") |
Example Response:
{
"image": "nginx:alpine",
"total_vulnerabilities": 1,
"severities": {
"Critical": 1
},
"vulnerabilities": [
{
"id": "CVE-2023-12345",
"severity": "Critical",
"package": {
"name": "libssl",
"version": "1.1.1"
}
}
]
}
The MCP server also exposes resource templates for direct access to data:
kubescape://vulnerability-manifests/{namespace}/{manifest_name}
kubescape://configuration-manifests/{namespace}/{manifest_name}
Add to your Claude Desktop configuration (~/.config/claude/config.json on Linux or ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"kubescape": {
"command": "kubescape",
"args": ["mcpserver"]
}
}
}
For custom AI applications using the MCP SDK:
from mcp import Client
async with Client("kubescape", ["kubescape", "mcpserver"]) as client:
# List vulnerability manifests
result = await client.call_tool(
"list_vulnerability_manifests",
{"level": "workload"}
)
print(result)
Once connected, you can ask your AI assistant questions like:
Ensure the Kubescape operator has completed vulnerability scanning:
kubectl -n kubescape get vulnerabilitymanifests
If empty, check operator logs:
kubectl -n kubescape logs -l app=kubescape
Verify your kubeconfig is correctly configured:
kubectl get nodes
Check that you're running Kubescape v3.x or later:
kubescape version
scan_container_image tool accepts optional registry credentials (username and password). Be aware that parameters supplied to MCP tools may be retained in client conversation logs or model contexts depending on your client environment.scan_container_image tool validates image names as remote image references and rejects local file paths and scheme prefixes (such as dir:, file:, sbom:) to prevent unauthorized local filesystem access.KS_GRYPE_LISTING_URL environment variable to point to your internal Grype vulnerability database mirror listing URL.