腾讯云 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. 准备腾讯云凭证
- 登录 腾讯云控制台,进入「访问管理」→「访问密钥」获取
SecretId与SecretKey
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 相关问题自动触发。
开发贡献
开发工具安装
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. 静态工具(在代码中实现)
- 在
tool_tke.py中添加新函数 - 在
server.py的handle_list_tools()中添加工具定义 - 在
handle_call_tool()中添加调用逻辑
2. 动态工具(通过YAML文件)
- 使用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 文件。
Metadata
Release files for tke-mcp-server 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tke_mcp_server-0.0.9.tar.gz | 99.8 kB | Without provenance | Details for tke_mcp_server-0.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tke_mcp_server-0.0.9-py3-none-any.whl | Python 3 | none | any | Details for tke_mcp_server-0.0.9-py3-none-any.whl |
Total release size: 137.7 kB
Release files / tke_mcp_server-0.0.9.tar.gz
| Download URL | tke_mcp_server-0.0.9.tar.gz |
|---|---|
| Size | 99.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f519fbfacd8eacebdcca03120bd7b70ec60e47eb0c07b4b503d0a43cd18b482
|
|
BLAKE2b-256 checksum How to use checksums |
1f51ba02786ce281ff1249a5f12cd3b93b27285395ace3db5219799f54a6ae0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.3
|
Release files / tke_mcp_server-0.0.9-py3-none-any.whl
| Download URL | tke_mcp_server-0.0.9-py3-none-any.whl |
|---|---|
| Size | 37.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97015fb4ee9931ce905f9e43f654230eb0b5bdc9635178f7c93f4edc8885352f
|
|
BLAKE2b-256 checksum How to use checksums |
e0a6e2a6e014ad0297a1d0623e638ef5a0364de3da6e9ada77aff31c0e7f0f39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.3
|
Security for tke-mcp-server 0.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.