Skip to main content

MCP Server for Tencent Cloud TKE

Project description

腾讯云 TKE MCP Server(中文版)

腾讯云容器服务(TKE) Model Context Protocol (MCP) 服务器,提供标准化的TKE集群管理接口。

功能特性

  • 集群只读查询:查询集群列表、状态、规格、端点、kubeconfig、节点池
  • 动态工具加载:支持通过McpAPI YAML文件自动生成MCP工具
  • CodeBuddy Skill:支持通过 Skill 方式使用,无需安装 MCP Server
  • 模拟模式支持:在没有腾讯云凭证时使用模拟响应
  • 完整参数验证:严格的输入参数验证和错误处理

工具列表(Tools)

动态工具(通过McpAPI文件自动生成)

API 版本 2018-05-25

工具名称 功能说明
DescribeClusters 查询集群列表
DescribeClusterStatus 查看集群状态列表
DescribeClusterLevelAttribute 查询集群规格
DescribeClusterKubeconfig 获取集群kubeconfig
DescribeClusterEndpoints 查询集群访问端点
DescribeClusterEndpointStatus 查询集群端点状态

API 版本 2022-05-01

工具名称 功能说明
DescribeNodePools 查询节点池列表

所有工具均为只读查询操作,不包含任何写操作。

快速开始

1. 准备腾讯云凭证

  • 登录 腾讯云控制台,进入「访问管理」→「访问密钥」获取 SecretIdSecretKey

2. 配置环境变量

export TENCENTCLOUD_SECRET_ID=你的SecretId
export TENCENTCLOUD_SECRET_KEY=你的SecretKey

3. 安装

# 从PyPI安装
pip install tke-mcp-server

# 或从源码安装
pip install .

4. 启动服务器

# 直接运行
uv run tke-mcp-server

# 或通过Python模块
python -m mcp_server_tke

5. Claude Desktop 配置

编辑 claude_desktop_config.json(Mac 默认路径 ~/Library/Application Support/Claude/claude_desktop_config.json),加入:

{
  "mcpServers": {
    "tencent-tke": {
      "command": "uv",
      "args": ["run", "tke-mcp-server"],
      "env": {
        "TENCENTCLOUD_SECRET_ID": "你的SecretId",
        "TENCENTCLOUD_SECRET_KEY": "你的SecretKey"
      }
    }
  }
}

CodeBuddy Skill 方式使用

除 MCP Server 外,还提供 CodeBuddy Skill 方式,无需安装 MCP,直接在 CodeBuddy 中使用。

安装依赖

pip install tencentcloud-sdk-python-tke

配置凭证(AKSK)

支持两种方式配置腾讯云凭证:

方式一:环境变量(推荐)

export TENCENTCLOUD_SECRET_ID=你的SecretId
export TENCENTCLOUD_SECRET_KEY=你的SecretKey

设置后 Skill 会自动读取,无需额外传参。

方式二:命令行参数

在使用 /tke 时,要求 CodeBuddy 传入 --secret-id--secret-key 参数,例如:

/tke 帮我查一下广州地域的集群 --secret-id xxx --secret-key xxx

优先级:命令行参数 > 环境变量。如果同时配置,命令行参数会覆盖环境变量。

安装 Skill

# 复制到用户级 Skill 目录(全局生效)
cp -r skill/tke/ ~/.codebuddy/skills/tke/

# 或复制到项目级目录(仅当前项目生效)
cp -r skill/tke/ <你的项目>/.codebuddy/skills/tke/

使用

在 CodeBuddy 中输入 /tke 后跟需求,或直接提 TKE 相关问题自动触发。

详见 skill/tke/README.md

开发贡献

开发工具安装

npm install -g --registry=https://mirrors.tencent.com/npm @tencent/codebuddy-cli

项目结构

tke-mcp/
├── src/mcp_server_tke/          # 主源代码目录
│   ├── __init__.py             # 模块入口点
│   ├── server.py               # MCP服务器主逻辑
│   ├── tool_tke.py             # TKE静态工具实现
│   ├── client.py               # 腾讯云客户端封装
│   ├── mcpapi_loader.py        # McpAPI YAML文件加载器
│   ├── dynamic_tool_handler.py # 动态工具处理器
│   └── mcpapi/                 # 动态工具定义文件
├── openapi/                    # 云API导出的OpenAPI源文件
├── tests/                      # 单元测试
├── skill/tke/                  # CodeBuddy Skill
├── docs/                       # 文档
└── pyproject.toml              # Python项目配置

AI 辅助扩展开发

添加新工具

有两种方式添加新工具:

1. 静态工具(在代码中实现)

  1. tool_tke.py 中添加新函数
  2. server.pyhandle_list_tools() 中添加工具定义
  3. handle_call_tool() 中添加调用逻辑

2. 动态工具(通过YAML文件)

  1. 使用CodeBuddy CLI的/yunapiCommand,可以将云API转成MCP。
/yunapi openapi/tke_2018-05-25_DescribeClusterKubeconfig.json

测试

# 运行所有测试
python -m unittest discover tests/

# 运行特定测试
python -m unittest tests/test_tool_tke.py
python -m unittest tests/test_mcp_integration.py

构建包

# 使用hatch构建
hatch build

许可证

MIT License,详见 LICENSE 文件。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tke_mcp_server-0.0.9.tar.gz (99.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tke_mcp_server-0.0.9-py3-none-any.whl (37.9 kB view details)

Uploaded Python 3

File details

Details for the file tke_mcp_server-0.0.9.tar.gz.

File metadata

  • Download URL: tke_mcp_server-0.0.9.tar.gz
  • Upload date:
  • Size: 99.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.3

File hashes

Hashes for tke_mcp_server-0.0.9.tar.gz
Algorithm Hash digest
SHA256 8f519fbfacd8eacebdcca03120bd7b70ec60e47eb0c07b4b503d0a43cd18b482
MD5 9495b2ac9299b9805fed061ff7513957
BLAKE2b-256 1f51ba02786ce281ff1249a5f12cd3b93b27285395ace3db5219799f54a6ae0b

See more details on using hashes here.

File details

Details for the file tke_mcp_server-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for tke_mcp_server-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 97015fb4ee9931ce905f9e43f654230eb0b5bdc9635178f7c93f4edc8885352f
MD5 4a4a975da36ccc3a41e697d96fad639e
BLAKE2b-256 e0a6e2a6e014ad0297a1d0623e638ef5a0364de3da6e9ada77aff31c0e7f0f39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page