Token导航 LogoToken导航TokenDH.com
MCP Redfish Python logo
运维云端stdio官方级别未说明来源级核验

MCP Redfish Python

MCP Server

一个基于Model Context Protocol (MCP)和AI聊天机器人的智能Redfish服务器管理系统,提供自然语言命令接口和工具集成功能。

工具数

0

提示词数

0

GitHub Stars

1

资源数

0
自然语言处理PythonClaudeClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

devidasjadhav

提供方

devidasjadhav

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -r requirements.txt

详细介绍

红鱼MCP项目

一个使用模型上下文协议(MCP)和人工智能聊天机器人的智能Redfish服务器管理系统。

概述

该项目提供了一个AI驱动的界面,用于通过自然语言命令管理支持Redfish的服务器。它包括:

  • 聊天机器人界面:Redfish操作的交互式人工智能助手
  • MCP服务器:用于工具集成的模型上下文协议服务器
  • Redfish工具:Redfish操作的直接API工具
  • 模拟服务器:开发测试环境

快速开始

  1. 设置Redfish模拟服务器 (参见 用户指南 详情)
  2. 安装依赖项 并设置API密钥
  3. 启动MCP服务器运行聊天机器人

项目结构

├── src/
│   └── redfish_mcp/          # Main source code package
│       ├── __init__.py       # Package initialization
│       ├── chatbot.py        # AI-powered chatbot interface
│       ├── redfish_mcp_server.py  # MCP server implementation
│       └── redfish_tool.py   # Redfish API tool functions
├── tests/                    # Test files
│   └── test_chatbot.py       # Chatbot functionality tests
├── docs/                     # Documentation
│   ├── DSP0266_1.23.0.md     # Redfish specification docs
│   └── DSP0268_2025.3.md     # Additional Redfish docs
├── scripts/                  # Utility scripts
│   └── mock_redfish_server.py  # Mock Redfish server for testing
├── AGENTS.md                 # Development guidelines for AI agents
└── README.md                 # This file

用户指南

先决条件

  • Python 3.8+
  • Anthropic API密钥(用于聊天机器人功能)
  • Redfish模拟服务器(用于测试)

安装

  1. 克隆存储库
   git clone 
   cd redfish-mcp-project
  1. 安装 Python 依赖项
   pip install -r requirements.txt
  1. 配置环境
   # Copy the example configuration
   cp .env.example .env

   # Edit .env with your settings
   nano .env  # or your preferred editor
  1. 设置所需的API密钥
   # Either in .env file or environment variable
   export ANTHROPIC_API_KEY="your-anthropic-api-key-here"

设置Redfish模拟服务器

出于测试目的,请使用官方DMTF Redfish模拟服务器:

  1. 克隆Redfish模拟服务器
   git clone https://github.com/DMTF/Redfish-Mockup-Server.git
   cd Redfish-Mockup-Server
  1. 启动模拟服务器
   python3 redfishMockupServer.py -D public-rackmount1 -S

这将启动服务器 http://localhost:8000 随着 public-rackmount1 模型数据。

运行系统

1.启动MCP服务器

MCP服务器提供工具集成功能:

cd /path/to/redfish-mcp-project
PYTHONPATH=. python3 -m src.redfish_mcp.redfish_mcp_server

您应该看到如下输出:

╭─ FastMCP 2.0 ──────────────────────────────────────────────────────────────╮
│                                                                            │
│        _ __ ___ ______           __  __  _____________    ____    ____     │
│       _ __ ___ / ____/___ ______/ /_/  |/  / ____/ __ \  |___ \  / __ \    │
│      _ __ ___ / /_  / __ `/ ___/ __/ /|_/ / /   / /_/ /  ___/ / / / / /    │
│     _ __ ___ / __/ / /_/ (__  ) /_/ /  / / /___/ ____/  /  __/_/ /_/ /     │
│    _ __ ___ /_/    \__,_/____/\__/_/  /_/\____/_/      /_____(_)____/      │
│                                                                            │
│                                                                            │
│                                                                            │
│    🖥️  Server name:     Redfish MCP Server                                  │
│    📦 Transport:       STDIO                                               │
│                                                                            │
│    📚 Docs:            https://gofastmcp.com                               │
│    🚀 Deploy:          https://fastmcp.cloud                               │
│                                                                            │
│    🏎️  FastMCP version: 2.11.3                                              │
│    🤝 MCP version:     1.12.4                                              │
│                                                                            │
╰────────────────────────────────────────────────────────────────────────────╯

[12/13/25 23:30:30] INFO     Starting MCP server 'Redfish MCP Server' with transport 'stdio'

2.运行聊天机器人

在单独的终端中,启动AI驱动的聊天机器人:

cd /path/to/redfish-mcp-project
export ANTHROPIC_API_KEY="your-anthropic-api-key-here"
PYTHONPATH=. python3 -m src.redfish_mcp.chatbot

交互示例:

Intelligent Redfish Chatbot ready! Type 'quit' or 'exit' to end the conversation.
I can help with Redfish server management using intelligent reasoning.

You: List the available Redfish endpoints

Bot: I'll help you list the available Redfish endpoints. Let me query the service root.

[Tool Call: list_endpoints]
Available Redfish endpoints from http://127.0.0.1:8000/redfish/v1:
- AccountService: /redfish/v1/AccountService
- CertificateService: /redfish/v1/CertificateService
- Chassis: /redfish/v1/Chassis
- ComponentIntegrity: /redfish/v1/ComponentIntegrity
- EventService: /redfish/v1/EventService
- KeyService: /redfish/v1/KeyService
- Managers: /redfish/v1/Managers
- Registries: /redfish/v1/Registries
- SessionService: /redfish/v1/SessionService
- Systems: /redfish/v1/Systems
- Tasks: /redfish/v1/TaskService
- UpdateService: /redfish/v1/UpdateService

You: Tell me about the systems

Bot: The user is asking about systems. I should query the Systems endpoint to get information about the computer systems available.

[Tool Call: get_endpoint_data]
{"@odata.id": "/redfish/v1/Systems", "@odata.type": "#ComputerSystemCollection.ComputerSystemCollection", "Members": [{"@odata.id": "/redfish/v1/Systems/437XR1138R2"}], "Members@odata.count": 1, "Name": "Computer System Collection"}

You: quit

直接测试工具

您还可以在没有AI界面的情况下测试单个工具:

# List endpoints
PYTHONPATH=. python3 -c "from src.redfish_mcp.redfish_tool import list_endpoints; print(list_endpoints.invoke({}))"

# Get system information
PYTHONPATH=. python3 -c "from src.redfish_mcp.redfish_tool import get_endpoint_data; print(get_endpoint_data.invoke({'endpoint_url': '/Systems'}))"

运行测试

# Run all tests
pytest tests/

# Run specific test
pytest tests/test_chatbot.py

架构细节(供贡献者使用)

系统架构

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   User Input    │───▶│   Chatbot AI     │───▶│   Tool Calls    │
│                 │    │  (Anthropic)     │    │                 │
└─────────────────┘    └──────────────────┘    └─────────────────┘
                                                        │
                                                        ▼
┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   MCP Server    │◀──▶│   Tool Router    │───▶│  Redfish API    │
│  (FastMCP)      │    │                  │    │  (HTTP/REST)    │
└─────────────────┘    └──────────────────┘    └─────────────────┘

组件详情

1.Redfish客户端(src/redfish_mcp/client.py)

  • 目的:所有Redfish操作的共享HTTP客户端
  • 技术:请求具有会话管理的库
  • 功能:

- 集中式HTTP请求处理 - 错误处理和响应处理 - URL构建和验证 - 连接池和超时管理

2.配置(src/redfish_mcp/config.py)

  • 目的:基于环境的配置管理
  • 技术:Python环境变量
  • 功能:

- Redfish服务器设置(URL、超时、SSL) - 身份验证凭据(未来) - AI模型配置 - 日志记录设置(未来)

3.聊天机器人(src/redfish_mcp/chatbot.py)

  • 目的:Redfish操作的自然语言界面
  • 技术:郎链+人物克劳德
  • 功能:

- 用自然语言处理用户查询 - 确定适当的红鱼操作 - 通过MCP协议调用工具 - 维护对话上下文

4.MCP服务器(src/redfish_mcp/redfish_mcp_server.py)

  • 目的:通过模型上下文协议公开Redfish工具
  • 技术:FastMCP框架
  • 功能:

- 注册Redfish工具 - 处理工具调用 - 管理与AI模型的通信

5.红鱼工具(src/redfish_mcp/redfish_tool.py)

  • 目的:用于Redfish操作的LangChain工具包装器
  • 技术:LangChain工具+RedfishClient
  • 可用工具:

- list_endpoints():发现可用的Redfish端点 - get_endpoint_data():从特定端点检索数据 - patch_resource():通过PATCH更新资源 - post_action():通过POST执行操作

6.模拟服务器(scripts/mock_redfish_server.py)

  • 目的:开发和测试环境
  • 技术:Flask web服务器
  • 功能:提供模拟Redfish API响应

数据流

  1. 用户查询 → 聊天机器人接收自然语言输入
  2. 人工智能处理 → Claude分析查询并确定工具调用
  3. 工具执行 → MCP服务器将调用路由到适当的Redfish工具
  4. API调用 → 工具向Redfish端点发出HTTP请求
  5. 响应 → 结果通过MCP返回→ AI → User

配置

应用程序支持通过环境变量和 .env 文件夹。创建 .env 从提供的模板中选择文件:

cp .env.example .env

环境变量

Redfish服务器设置:

  • REDFISH_BASE_URL:Redfish服务器URL(默认值: http://127.0.0.1:8000/redfish/v1)
  • 请求超时:HTTP请求超时(秒)(默认值: 30)
  • VERIFY_SSL:是否验证SSL证书(默认值: true)

身份验证:

  • REDFISH_用户名:Redfish身份验证的用户名(可选)
  • REDFISH密码:Redfish身份验证密码(可选)

弹性设置:

  • 启用重试:启用带回退的自动重试(默认值: true)
  • 可启用断路器:启用断路器保护(默认值: true)
  • 最大重试次数:最大重试次数(默认值: 3)
  • RETRY_BASE_DELAY:重试之间的基本延迟(秒)(默认值: 1.0)
  • 重试_最大延迟:重试之间的最大延迟(秒)(默认值: 30.0)
  • 断路器阈值:开路前故障(默认值: 5)
  • 断路器超时:恢复超时(秒)(默认值: 60.0)

AI配置:

  • ANTHROPIC_API_键:聊天机器人功能所需
  • 人向模型:要使用的Claude模型(默认值: claude-3-5-haiku-20241022)

登录中:

  • LOG_LEVEL:日志记录级别(调试、信息、警告、错误、严重)(默认值: INFO)
  • 日志文件:可选日志文件路径

MCP服务器:

  • MCP_SERVER_NAME:服务器显示名称(默认值: Redfish MCP Server)
  • MCP_SERVER_版本:服务器版本(默认值: 1.0.0)
  • MCP运输:传输协议(默认值: stdio)

配置验证

应用程序在启动时验证配置,如果缺少所需的设置或设置无效,应用程序将退出并显示明确的错误消息。

示例.env文件:

# Redfish Server Configuration
REDFISH_BASE_URL=http://your-redfish-server:8000/redfish/v1
REQUEST_TIMEOUT=30
VERIFY_SSL=true

# Authentication (leave empty if not required)
REDFISH_USERNAME=
REDFISH_PASSWORD=

# Resilience Configuration
ENABLE_RETRY=true
ENABLE_CIRCUIT_BREAKER=true
MAX_RETRY_ATTEMPTS=3
RETRY_BASE_DELAY=1.0
RETRY_MAX_DELAY=30.0
CIRCUIT_BREAKER_THRESHOLD=5
CIRCUIT_BREAKER_TIMEOUT=60.0

# AI Configuration
ANTHROPIC_API_KEY=your-anthropic-api-key-here
ANTHROPIC_MODEL=claude-3-5-haiku-20241022

# Logging Configuration
LOG_LEVEL=INFO
LOG_FILE=

# MCP Server Configuration
MCP_SERVER_NAME=Redfish MCP Server
MCP_SERVER_VERSION=1.0.0
MCP_TRANSPORT=stdio

错误处理

  • 网络错误:HTTP超时和连接失败
  • API错误:端点无效,身份验证失败
  • JSON错误:请求/响应数据格式错误
  • 工具错误:参数无效或工具特定故障

测试策略

  • 单元测试:单个工具功能
  • 集成测试:端到端工具链
  • 模仿测试:隔离组件测试
  • 现场测试:使用模拟服务器进行完整的系统验证

发展

代理商.md 获取开发指南、编码标准和构建/测试命令。

贡献

  1. 遵循AGENTS.md中的编码标准
  2. 添加新功能的测试
  3. 根据需要更新文档
  4. 在提交更改之前运行测试
  5. 使用模拟和真实的Redfish服务器进行测试

/home/dev/workspace/mcp/test/README.md

目录标签

目录标签

自然语言处理PythonClaude服务器管理本地部署AI聊天机器人Redfish协议工具集成

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP