OpenShift MCP Server

io.github.sanjaypsachdev由 GitHub 账号 sanjaypsachdev 发布v1.2.0更新于 Oct 24, 2026

OpenShift/Kubernetes cluster management via the oc CLI for MCP clients

概览

AI 生成的概览

通过 oc 命令行让 AI 助手管理 OpenShift/Kubernetes 集群:查看、创建、修改、删除资源,部署应用、扩缩容并读取日志。

可以做什么
  • 登录集群,并列出 API 资源、解释资源结构与字段文档
  • 读取、描述、创建、应用、修补和删除 OpenShift/Kubernetes 资源
  • 从 Git 仓库以 S2I 构建部署应用,并调整工作负载副本数
  • 获取 Pod 与构建日志,支持日志采样与错误模式分析
  • 通过 OLM、Helm 或直接清单安装 Operator
  • 以 MCP 资源读取集群信息、项目列表与应用模板,并提供排障提示词
适用场景
适合让助手直接操作或排查 OpenShift、Kubernetes 集群的场景,例如从 Git 部署应用、扩缩容、查看 Pod 日志或诊断异常资源,而不必由用户手动执行 oc 命令。
运行要求
以 stdio 在本地运行(npm 包经 npx,或 OCI 镜像经 podman)。需要 Node.js 20+、已安装并配置好的 oc 命令行,以及访问 OpenShift 集群的网络。可选环境变量 OPENSHIFT_CONTEXT 与 OPENSHIFT_NAMESPACE 用于设置默认上下文和命名空间。集群凭据通过 oc_login 工具提供。
安装前请注意
该服务器可创建、应用、修补、扩缩容和删除集群资源并安装 Operator,改动会真实生效,且以已认证用户的 RBAC 权限执行。集群令牌或用户名密码会传给 oc_login 工具;建议使用最小权限的服务账号令牌、定期轮换并在结束后登出。另提供 HTTP/SSE 模式,若对外暴露需做好防护。

安装

在 SourceWeft 中

  1. 打开 控制台中的 OpenShift MCP Server,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

OpenShift MCP Server

[CI Pipeline] [CodeQL] [License: MIT] [Node.js Version] [TypeScript] [OpenShift] [Kubernetes] [MCP] [Test Coverage] [Tests] [npm version] [npm downloads] [Docker] [PRs Welcome] [Maintenance]

A Model Context Protocol (MCP) server that provides AI assistants with comprehensive OpenShift/Kubernetes cluster management capabilities through the oc command-line interface.

Demo Video

Watch the oc-new-app tool deploy a complete Spring Boot application from GitHub to OpenShift:

https://github.com/user-attachments/assets/f4bace3f-755b-462f-8a8a-680e4dc02129

Features

  • Cluster Information: Access comprehensive cluster status, nodes and configuration via MCP resources
  • Resource Description: Describe any resource with multiple output formats including human-readable summaries
  • Complete Resource Management: Create, read, update, delete, and patch all OpenShift/Kubernetes resources
  • Application Deployment: Deploy applications from Git repositories with S2I builds and automatic route creation
  • Operator Management: Install operators via OLM, Helm, or direct manifests
  • Cluster Operations: Scaling, monitoring, troubleshooting and management
  • Build Operations: Start and monitor OpenShift builds
  • Scaling Operations: Scale deployments, replicasets and statefulsets
  • Logging: Retrieve logs from pods and builds
  • Multi-Transport Support: STDIO and HTTP/SSE transports for different integration scenarios
  • Comprehensive Testing: 99 unit tests ensuring production reliability
  • Rich Error Handling: Detailed troubleshooting guidance and actionable error messages
  • Troubleshooting Prompts: Interactive troubleshooting guides for common OpenShift scenarios
  • Log Sampling: Sample and analyze pod logs with intelligent pattern detection and context

Prerequisites

  • Node.js 20+
  • OpenShift CLI (oc) installed and configured
  • Access to an OpenShift cluster

Installation

bash
git clone https://github.com/sanjaypsachdev/mcp-server-openshift.gitcd mcp-server-openshiftnpm installnpm run build

Configuration

Add to your MCP client configuration:

Claude Desktop / Cursor

json
{  "mcpServers": {    "openshift": {      "command": "node",      "args": ["/path/to/mcp-server-openshift/dist/index.js"],      "env": {        "OPENSHIFT_CONTEXT": "your-context-name",        "OPENSHIFT_NAMESPACE": "your-default-namespace"      }    }  }}

HTTP/SSE Transport (Remote Access)

bash
# Start HTTP servernpm run start:http
# Connect via MCP remotenpx -y mcp-remote http://localhost:3000/sse --transport sse-only

Tools

Authentication & Access

  • oc_login - Securely log into OpenShift clusters using token or username/password authentication

API Discovery & Documentation

  • oc_api_resources - List all available API resources in the cluster with categorization
  • oc_explain - Explain resource schemas, fields, and API documentation

Core Resource Management

  • oc_get - Get OpenShift resources (pods, deployments, services, routes, etc.)
  • oc_create - Create OpenShift resources from manifests or templates
  • oc_apply - Apply YAML manifests with validation and conflict resolution
  • oc_delete - Delete resources with safety checks and confirmation options
  • oc_patch - Patch resources using strategic merge, JSON merge, or JSON patch operations
  • oc_describe - Describe resources with multiple output formats

Application Lifecycle

  • oc_new_app - Deploy applications from Git repositories with S2I builds
  • oc_scale - Scale deployments, deploymentconfigs, replicasets, and statefulsets
  • oc_logs - Get logs from pods, deployments, builds with filtering options

Advanced Operations

  • oc_install_operator - Install operators via OLM, Helm, or direct manifests

Resources

MCP Resources provide read-only access to cluster information:

  • openshift://cluster-info - Comprehensive cluster status, nodes, namespaces, and events
  • openshift://project-list - Detailed project information with quotas and usage statistics
  • openshift://app-templates - Application deployment templates and patterns

Prompts

Interactive troubleshooting and operational guidance:

  • troubleshoot-openshift-prompt - Comprehensive OpenShift troubleshooting guide for all resource types and cluster issues
  • monitoring-prompts - Monitoring and observability guidance for different scenarios

Sampling

Intelligent log analysis and pattern detection:

  • Pod Logs Sampling - Automatic log sampling with error pattern detection and context analysis

Usage Examples

Login to Cluster

bash
# Login with token (recommended)oc_login with server: "https://api.cluster.example.com:6443",         authMethod: "token",         token: "sha256~your-token-here"
# Login with username/passwordoc_login with server: "https://api.cluster.example.com:6443",         authMethod: "password",         username: "developer",         password: "your-password"

Discover API Resources

bash
# List all available API resourcesoc_api_resources
# List resources for specific API groupoc_api_resources with apiGroup: "apps"
# List only namespaced resourcesoc_api_resources with namespaced: true
# Explain a resource schemaoc_explain with resource: "deployment"
# Explain specific fieldoc_explain with resource: "pod", field: "spec.containers"

Deploy Application

bash
# Deploy Node.js app from GitHuboc_new_app with gitRepo: "https://github.com/sclorg/nodejs-ex.git"

Scale Application

bash
# Scale deployment to 3 replicasoc_scale with name: "my-app", replicas: 3

Patch Resource

bash
# Update deployment labelsoc_patch with resourceType: "deployment", name: "my-app",         patch: '{"metadata":{"labels":{"environment":"production"}}}'

Troubleshoot Issues

bash
# Get pod troubleshooting guidanceUse prompt: troubleshoot-openshift-promptArguments: issueType: "pod", resourceName: "my-app-12345", namespace: "my-project"
# Get deployment troubleshooting guidanceUse prompt: troubleshoot-openshift-promptArguments: issueType: "deployment", resourceName: "my-app", namespace: "my-project"
# Get general cluster troubleshooting guidanceUse prompt: troubleshoot-openshift-promptArguments: issueType: "cluster", symptoms: "nodes not ready"

Development

bash
# Setupnpm install
# Buildnpm run build
# Testnpm test
# Start (STDIO)npm start
# Start (HTTP)npm run start:http
# Development modenpm run dev

Transport Modes

STDIO (Default)

  • Direct MCP client integration
  • Lower latency
  • Recommended for local development

HTTP/SSE

  • Remote access capability
  • Web integration friendly
  • Container deployment ready

Architecture

src/├── index.ts              # Main server entry point├── tools/                # Tool implementations├── resources/            # MCP resources├── prompts/              # Interactive prompts├── sampling/             # Log sampling and analysis├── models/               # Zod validation schemas└── utils/                # OpenShift CLI wrapper

Security

Authentication Security

  • Token Authentication: Preferred method for automation and production use
  • Password Authentication: Available but token authentication is recommended
  • HTTPS Enforcement: All cluster connections must use HTTPS
  • URL Validation: Server URLs validated to prevent SSRF attacks
  • Private IP Blocking: Prevents connections to internal/metadata services

Operational Security

  • RBAC Compliance: Respects OpenShift RBAC permissions
  • No Credential Storage: Credentials are not stored or transmitted by the server
  • User Permissions: Executes with the same permissions as the authenticated user
  • Input Validation: Comprehensive validation of all inputs and parameters
  • Secure Defaults: Conservative security settings by default

Best Practices

  • Use Service Account Tokens: For automation and CI/CD pipelines
  • Regular Token Rotation: Rotate authentication tokens regularly
  • TLS Certificate Validation: Always validate TLS certificates in production
  • Least Privilege: Use accounts with minimal required permissions
  • Session Management: Use oc logout to clear credentials when done

License

MIT License - see LICENSE file for details.

来源:README.md,提交 0abad71

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.2.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分