RM

rlopez133/mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

20 stars 14 forks 质量 46 趋势 10

本指南将带你了解如何设置演示中的MCP服务器+Claude Desktop部分,重点是利用Claude Desktop与你的Ansible自动化平台和OpenShift交互......

概览

本指南将带你了解如何设置演示中的MCP服务器+Claude Desktop部分,重点是如何利用Claude Desktop与你的Ansible自动化平台和OpenShift集群环境交互。 确保你安装了以下设备。 - Ansible 自动化平台(AAP)环境 - 一个支持 OpenShift 虚拟化的 OpenShift 集群 - 在您的笔记本上安装了 Claude 桌面(最佳效果需 Pro Plan)- 笔记本上安装了 Python 3.10 或更高版本 - 确保您已通过 OpenShift 集群认证(例如导出 kubeconfig) 安装 uv 并搭建你的 Python 项目和环境。 安装 jbang,用于使用 Kubernetes MCP 服务器时。(jbang 需要全局安装,建议使用自制安装模式。如果你本地安装(curl 模式),Claude 就无法访问它。) 重启终端,确保UV和jbang命令现在可用。

概述(AI 翻译)

概述

本指南将带你了解如何设置演示中的MCP服务器+Claude Desktop部分,重点是如何利用Claude Desktop与你的Ansible自动化平台和OpenShift集群环境交互。

先修条件

确保你安装了以下设备。

必修

  • Ansible 自动化平台(AAP)环境
  • 一个支持 OpenShift 虚拟化的 OpenShift 集群
  • 在您的笔记本上安装了Claude桌面(最佳效果需购买专业版)
  • 在你的笔记本上安装了Python 3.10或更高版本
  • 确保你已通过 OpenShift 集群认证(例如导出 kubeconfig)

第一步:设置你的笔记本电脑环境

安装uv,并搭建你的Python项目和环境。

安装 jbang,用于使用 Kubernetes MCP 服务器时。(jbang 需要全局安装,建议使用自制安装模式。如果你本地安装(curl 模式),Claude 就无法访问它。)

重启终端,确保uv和jbang命令现在可用。

第二步:创建并设置你的项目

步骤3 构建您的Ansible自动化控制器MCP服务器

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Setup of the Environment for the AI Powered Ansible & OpenShift Automation with Model Context Protocols (MCP) Servers

Overview

This guide will walk you through setting up the MCP Servers + Claude Desktop portions of the demo that focused on using Claude Desktop to interact with your Ansible Automation Platform and OpenShift Cluster environments.

Prerequisites

Ensure you have the following installed.

Required

  • An Ansible Automation Platform (AAP) environment
  • An OpenShift Cluster with OpenShift Virtualization
  • Claude Desktop installed on your laptop (Pro Plan required for best results)
  • Python 3.10 or higher installed on your laptop
  • Ensure you are authenticated with your OpenShift cluster (e.g. exporting kubeconfig)

Step One: Setup your laptop environment

Install uv and setup your Python project and environment.

curl -LsSf https://astral.sh/uv/install.sh | sh

Install jbang which will be used when using the Kubernetes MCP Server. (jbang needs to be installed globally, recommend using the homebrew install pattern. If you install it locally (the curl pattern), Claude won’t be able to access it).

Restart your terminal to ensure that the uv and jbang command are now available.

Step Two: Create and Setup your Project

# Create a new directory for our project
uv init ansible
cd ansible

# Create virtual environment and activate it
uv venv
source .venv/bin/activate

# Install dependencies
uv add "mcp[cli]" httpx

# Create our server file
touch ansible.py

Step 3 Building your Ansible Automation Controller MCP Server

This is the MCP Server I used to interact with my automation controller. Feel free to copy/paste this into your ansible.py file.

Note: to connect to self-signed SSL, use edit the async client to be https.AsyncClient(verify=False)

import os
import httpx
from mcp.server.fastmcp import FastMCP
from typing import Any

# Environment variables for authentication
AAP_URL = os.getenv("AAP_URL")
AAP_TOKEN = os.getenv("AAP_TOKEN")

if not AAP_TOKEN:
    raise ValueError("AAP_TOKEN is required")

# Headers for API authentication
HEADERS = {
    "Authorization": f"Bearer {AAP_TOKEN}",
    "Content-Type": "application/json"
}

# Initialize FastMCP
mcp = FastMCP("ansible")

async def make_request(url: str, method: str = "GET", json: dict = None) -> Any:
    """Helper function to make authenticated API requests to AAP."""
    async with httpx.AsyncClient() as client:
        response = await client.request(method, url, headers=HEADERS, json=json)
    if response.status_code not in [200, 201]:
        return f"Error {response.status_code}: {response.text}"
    return response.json() if "application/json" in response.headers.get("Content-Type", "") else response.text

@mcp.tool()
async def list_inventories() -> Any:
    """List all inventories in Ansible Automation Platform."""
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →