TuxCare ePortal MCP服务器
用于与TuxCare ePortal API集成的模型上下文协议(MCP)服务器。该服务器提供MCP工具,用于通过ePortal API管理服务器、提要、注册密钥、补丁集和用户。
特性
- 服务器管理:使用高级筛选列出、注册和注销服务器
- 饲料管理:创建、修改和删除提要
- 密钥管理:管理服务器注册的注册密钥
- 补丁集管理:列出并管理patchset部署
- 用户管理:列出ePortal用户
- 服务器标记:设置和管理服务器标记
- 灵活的身份验证:支持基本身份验证和API密钥
安装选项
选项1:NPM全局安装(推荐)
# Install globally from npm
npm install -g tuxcare-eportal-mcp
# Verify installation
tuxcare-eportal-mcp --help选项2:NPX(无需安装)
# Run directly with npx
npx tuxcare-eportal-mcp --help
# Use in MCP configuration with npx
npx tuxcare-eportal-mcp --url https://your-eportal.com --auth-type basic --username admin --password secret选项3:GitHub安装
# Install directly from GitHub
npm install -g github:Revmagi/tuxcare-eportal-mcp
# Or clone and install locally
git clone https://github.com/Revmagi/tuxcare-eportal-mcp.git
cd tuxcare-eportal-mcp
npm install
npm run build
npm link配置指南
配置方法
您可以通过三种方式配置MCP服务器:
- 配置文件 (建议用于永久设置)
- 命令行参数 (适用于测试和Claude Code)
- 环境变量 (适用于集装箱化部署)
方法1:配置文件
创建JSON格式的配置文件:
基本身份验证示例(config.json):
{
"eportal_url": "https://your-eportal.com",
"auth": {
"type": "basic",
"username": "admin",
"password": "your-password"
}
}API密钥验证示例(config.json):
{
"eportal_url": "https://your-eportal.com",
"auth": {
"type": "api_key",
"api_key": "your-api-key",
"header_name": "X-Api-Key"
}
}配置文件位置
服务器按以下顺序查找配置文件:
- 指定的路径:
--config /path/to/config.json - 当前目录:
./config.json - 主目录:
~/.tuxcare-eportal-mcp/config.json - 系统目录:
/etc/tuxcare-eportal-mcp/config.json
方法2:命令行参数
您可以通过命令行参数传递所有配置:
# Basic authentication
tuxcare-eportal-mcp \
--url https://your-eportal.com \
--auth-type basic \
--username admin \
--password your-password
# API key authentication
tuxcare-eportal-mcp \
--url https://your-eportal.com \
--auth-type api_key \
--api-key your-api-key \
--header-name X-Api-Key方法3:环境变量
设置安全配置的环境变量:
export TUXCARE_EPORTAL_URL="https://your-eportal.com"
export TUXCARE_AUTH_TYPE="basic"
export TUXCARE_USERNAME="admin"
export TUXCARE_PASSWORD="your-password"
# Or for API key
export TUXCARE_AUTH_TYPE="api_key"
export TUXCARE_API_KEY="your-api-key"
export TUXCARE_HEADER_NAME="X-Api-Key"MCP客户端配置
Claude代码配置
方法1:使用配置文件
- 在项目目录中创建配置文件:
{
"eportal_url": "https://your-eportal.com",
"auth": {
"type": "basic",
"username": "admin",
"password": "your-password"
}
}- 添加到您的Claude Code MCP设置中:
{
"mcpServers": {
"tuxcare-eportal": {
"command": "npx",
"args": ["tuxcare-eportal-mcp", "--config", "./config.json"]
}
}
}方法2:使用命令行参数(无配置文件)
基本身份验证:
{
"mcpServers": {
"tuxcare-eportal": {
"command": "npx",
"args": [
"tuxcare-eportal-mcp@1.0.4",
"--url", "https://your-eportal.com",
"--auth-type", "basic",
"--username", "admin",
"--password", "your-password"
]
}
}
}API密钥验证:
{
"mcpServers": {
"tuxcare-eportal": {
"command": "npx",
"args": [
"tuxcare-eportal-mcp@1.0.4",
"--url", "https://your-eportal.com",
"--auth-type", "api_key",
"--api-key", "your-api-key"
]
}
}
}带有自定义标头的API密钥:
{
"mcpServers": {
"tuxcare-eportal": {
"command": "npx",
"args": [
"tuxcare-eportal-mcp@1.0.4",
"--url", "https://your-eportal.com",
"--auth-type", "api_key",
"--api-key", "your-api-key",
"--header-name", "X-API-Key"
]
}
}
}方法3:使用环境变量(最安全)
基本身份验证:
{
"mcpServers": {
"tuxcare-eportal": {
"command": "npx",
"args": ["tuxcare-eportal-mcp@1.0.4"],
"env": {
"TUXCARE_EPORTAL_URL": "https://your-eportal.com",
"TUXCARE_AUTH_TYPE": "basic",
"TUXCARE_USERNAME": "admin",
"TUXCARE_PASSWORD": "your-password"
}
}
}
}API密钥验证:
{
"mcpServers": {
"tuxcare-eportal": {
"command": "npx",
"args": ["tuxcare-eportal-mcp@1.0.4"],
"env": {
"TUXCARE_EPORTAL_URL": "https://your-eportal.com",
"TUXCARE_AUTH_TYPE": "api_key",
"TUXCARE_API_KEY": "your-api-key"
}
}
}
}带有自定义标头的API密钥:
{
"mcpServers": {
"tuxcare-eportal": {
"command": "npx",
"args": ["tuxcare-eportal-mcp@1.0.4"],
"env": {
"TUXCARE_EPORTAL_URL": "https://your-eportal.com",
"TUXCARE_AUTH_TYPE": "api_key",
"TUXCARE_API_KEY": "your-api-key",
"TUXCARE_HEADER_NAME": "X-API-Key"
}
}
}
}继续dev配置
添加到您的 continue.json:
{
"mcpServers": {
"tuxcare-eportal": {
"command": "npx",
"args": ["tuxcare-eportal-mcp", "--config", "./config.json"]
}
}
}临床配置
添加到MCP设置中:
{
"mcpServers": {
"tuxcare-eportal": {
"command": "tuxcare-eportal-mcp",
"args": [
"--url", "https://your-eportal.com",
"--auth-type", "basic",
"--username", "admin",
"--password", "your-password"
]
}
}
}通用MCP客户端配置
对于任何MCP客户端,请使用以下格式:
{
"mcpServers": {
"tuxcare-eportal": {
"command": "tuxcare-eportal-mcp",
"args": ["--config", "/path/to/config.json"]
}
}
}配置设置命令
快速设置命令
以交互方式生成配置文件:
# Create config file with prompts
npx tuxcare-eportal-mcp --setup
# Create config file with basic auth
npx tuxcare-eportal-mcp --setup --url https://your-eportal.com --auth-type basic
# Create config file with API key
npx tuxcare-eportal-mcp --setup --url https://your-eportal.com --auth-type api_key测试配置
验证您的配置是否有效:
# Test with config file
tuxcare-eportal-mcp --config ./config.json --test
# Test with command line args
tuxcare-eportal-mcp --url https://your-eportal.com --auth-type basic --username admin --password secret --test可用工具
服务器管理
list_servers:列出具有筛选选项的服务器register_host:注册新主机unregister_host:按主机名、IP或服务器ID注销主机bulk_unregister_hosts:批量注销非活动主机set_server_tags:为服务器设置标签
饲料管理
list_feeds:列出所有订阅源create_feed:创建或修改提要delete_feed:删除提要
密钥管理
list_keys:列出注册密钥create_key:创建或修改注册密钥delete_key:删除注册密钥
补丁集管理
list_patchsets:列出饲料和产品的零件集manage_patchsets:启用、禁用或管理patchset部署
用户管理
list_users:列出所有ePortal用户
工具使用示例
列出服务器
// List all servers
await callTool("list_servers", {});
// List servers with filtering
await callTool("list_servers", {
hostname: "web%",
tag: "env:production",
limit: 50
});
// Get server count only
await callTool("list_servers", {
only_count: true
});注册主机
await callTool("register_host", {
key: "production-key",
hostname: "web-server-01"
});管理补丁集
// Enable a patchset
await callTool("manage_patchsets", {
patchset: "K20240101_01",
feed: ["main", "staging"],
action: "enable",
product: "kernel"
});
// Enable all patchsets up to a specific one
await callTool("manage_patchsets", {
patchset: "K20240101_01",
feed: ["main"],
action: "enable-upto",
product: "kernel"
});设置服务器标签
await callTool("set_server_tags", {
server_id: "abc123",
tags: "env:production;team:platform;ubuntu"
});认证
基本身份验证
{
"auth": {
"type": "basic",
"username": "your-username",
"password": "your-password"
}
}API密钥验证
{
"auth": {
"type": "api_key",
"api_key": "your-api-key",
"header_name": "X-Api-Key"
}
}安全最佳实践
- 从不提交凭据 到版本控制
- 使用环境变量 敏感数据
- 限制文件权限 在配置文件上:
chmod 600 config.json - 使用API密钥 尽可能使用密码
- 轮换凭据 定期
- 使用HTTPS 适用于所有ePortal连接
故障排除
常见问题
连接错误
# Test connection
curl -v https://your-eportal.com/api/v1/servers
# Check DNS resolution
nslookup your-eportal.com身份验证失败
# Test basic auth
curl -u username:password https://your-eportal.com/api/v1/servers
# Test API key
curl -H "X-Api-Key: your-key" https://your-eportal.com/api/v1/servers配置问题
# Validate configuration file
npx tuxcare-eportal-mcp --config ./config.json --validate
# Show current configuration
npx tuxcare-eportal-mcp --config ./config.json --show-config调试模式
启用调试日志记录:
# Debug mode
DEBUG=tuxcare:* tuxcare-eportal-mcp --config ./config.json
# Verbose output
tuxcare-eportal-mcp --config ./config.json --verbose错误处理
服务器提供全面的错误处理:
- 身份验证错误:清除凭证问题的消息
- API错误:来自ePortal API的详细错误消息
- 验证错误:输入验证,并显示有用的错误消息
- 网络错误:超时和连接错误处理
发展
设置
git clone https://github.com/Revmagi/tuxcare-eportal-mcp.git
cd tuxcare-eportal-mcp
npm install构建
npm run build发展模式
npm run dev测试
npm test代码检查
npm run lint
npm run lint:fix贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 如果适用,添加测试
- 运行linting和测试
- 提交拉取请求
许可证
MIT许可证-请参阅 许可证 文件以获取详细信息。
支持
- 问题:
- 文档: Tuxcare文档
- ePortal API:请参阅ePortal API文档,了解API的详细参考资料
版本历史记录
- 1.0.0:具有完整ePortal API支持的初始版本
