Skip to content

Commit 0a99c4f

Browse files
authored
Update TrafficRoute MCP (#87)
1 parent 9baa976 commit 0a99c4f

14 files changed

Lines changed: 181 additions & 274 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ MCP Server列表 与 **[火山引擎大模型生态广场](https://www.volcengin
7575

7676
- **[CDN MCP](https://github.com/volcengine/mcp-server/tree/main/server/mcp_server_cdn)**:火山引擎 CDN 智能分析助手。
7777
- **[边缘计算节点 MCP](https://github.com/volcengine/mcp-server/tree/main/server/mcp_server_veen)**:申请、配置、查阅在边缘计算节点,包括虚拟机、镜像、裸金属,及对应的网络配置。
78-
- **[Traffic Route MCP](https://github.com/volcengine/mcp-server/tree/main/server/mcp_server_traffic_route)**:各种类型的 DNS 节点链路配置。
7978

8079

8180
### **大数据**
@@ -101,6 +100,7 @@ MCP Server列表 与 **[火山引擎大模型生态广场](https://www.volcengin
101100

102101
- **[证书中心 MCP](https://github.com/volcengine/mcp-server/tree/main/server/mcp_server_certificate_center)**:通过自然语言驱动管理证书服务。
103102
- **[域名服务 MCP](https://github.com/volcengine/mcp-server/tree/main/server/mcp_server_domain_service)**:通过自然语言高效查询并注册域名。
103+
- **[TrafficRoute MCP](https://github.com/volcengine/mcp-server/tree/main/server/mcp_server_traffic_route)**:各种类型的 DNS 节点链路配置。
104104

105105

106106
### **管理与治理**

server/mcp_server_traffic_route/README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ v0.1
88

99
### Short Description
1010

11-
The DNS routing service that allows users to configure DNS rules to ensure that requests from clients reach the desired service nodes.
11+
Support for configuring DNS routing rules to ensure that requests from clients reach the desired service nodes.
1212

1313
### Long Description
1414

15-
The DNS routing service that allows users to configure DNS rules to ensure that requests from clients reach the desired service nodes.
15+
The DNS routing service that allows users to configure DNS routing rules to ensure that requests from clients reach the desired service nodes.
1616

1717
## Category
1818

@@ -26,20 +26,15 @@ DNS,Domain
2626

2727
This MCP Server product provides the following Tools (capabilities):
2828

29-
### Tool 1: list-zones
29+
### Tool 1: list_zones
3030

3131
List DNS on TrafficRoute.
3232

33-
### Tool 2: create-zone
33+
### Tool 2: create_zone
3434

35-
Add a domain.
36-
After adding, you can use `create-record` to add DNS record.
35+
Add a domain configuration.
3736

38-
### Tool 3: create-record
39-
40-
Add a DNS record.
41-
42-
### Tool 4: list-records
37+
### Tool 3: list_records
4338

4439
Get all records of the specific DNS.
4540

@@ -89,8 +84,8 @@ Use a client to interact with the server:
8984
"mcp-server-traffic-route"
9085
],
9186
"env": {
92-
"VOLC_ACCESSKEY": "<Your-Volcengine-AK>",
93-
"VOLC_SECRETKEY": "<Your-Volcengine-SK>"
87+
"VOLCENGINE_ACCESS_KEY": "Your Volcengine AK",
88+
"VOLCENGINE_SECRET_KEY": "Your Volcengine SK"
9489
}
9590
}
9691
}

server/mcp_server_traffic_route/README_zh.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ v0.1
88

99
### 短描述
1010

11-
TrafficRoute 用于配置 DNS 规则,以确保终端请求能够正确快捷到达对应的服务节点
11+
支持对各种类型的 DNS 节点链路进行配置
1212

1313
### 长描述
1414

15-
TrafficRoute 用于配置 DNS 规则,以确保终端请求能够正确快捷到达对应的服务节点。
15+
TrafficRoute 用于配置 DNS 链路规则,以确保终端请求能够正确快捷到达对应的服务节点。
1616

1717
## 分类
1818

@@ -26,20 +26,15 @@ DNS,Domain
2626

2727
本 MCP Server 产品提供以下 Tools (工具/能力):
2828

29-
### Tool 1: list-zones
29+
### Tool 1: list_zones
3030

3131
获取在 TrafficRoute 上的解析域名列表。
3232

33-
### Tool 2: create-zone
33+
### Tool 2: create_zone
3434

35-
添加域名。
36-
添加完毕后,后续可以通过 `create-record` 工具来添加解析。
35+
添加域名配置。
3736

38-
### Tool 3: create-record
39-
40-
给指定域名增加解析记录。
41-
42-
### Tool 4: list-records
37+
### Tool 3: list_records
4338

4439
获取域名的全部解析记录列表。
4540

@@ -89,8 +84,8 @@ uv run mcp-server-traffic-route -t sse
8984
"mcp-server-traffic-route"
9085
],
9186
"env": {
92-
"VOLC_ACCESSKEY": "<Your-Volcengine-AK>",
93-
"VOLC_SECRETKEY": "<Your-Volcengine-SK>"
87+
"VOLCENGINE_ACCESS_KEY": "Your Volcengine AK",
88+
"VOLCENGINE_SECRET_KEY": "Your Volcengine SK"
9489
}
9590
}
9691
}

server/mcp_server_traffic_route/nodejs/src/tools/tr/all.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ export const trafficRouteTools: IProxyToolModel[] = [
3636
name: 'create-record',
3737
description: '给指定域名增加解析记录。',
3838
args: {
39-
ZID: z.number(),
40-
Host: z.string(),
41-
Type: z.string(),
42-
Value: z.string(),
43-
TTL: z.number().default(600).optional(),
39+
ZID: z.number().describe('关联的域名 ID'),
40+
Host: z.string().describe('主机名'),
41+
Type: z.string().describe('解析记录类型'),
42+
Value: z.string().describe('解析记录值'),
43+
TTL: z.number().default(600).optional().describe('生存时间,单位为秒'),
4444
Weight: z.number().default(1).optional().describe('权重'),
4545
},
4646
action: 'CreateRecord',
@@ -54,8 +54,8 @@ export const trafficRouteTools: IProxyToolModel[] = [
5454
RecordID: z.string().describe('解析记录 ID'),
5555
Host: z.string().describe('域名'),
5656
Line: z.string(),
57-
Type: z.string(),
58-
Value: z.string(),
57+
Type: z.string().describe('解析记录类型'),
58+
Value: z.string().describe('解析记录值'),
5959
TTL: z.number().default(600).optional(),
6060
Weight: z.number().default(1).optional().describe('权重'),
6161
},
@@ -67,7 +67,7 @@ export const trafficRouteTools: IProxyToolModel[] = [
6767
name: 'list-records',
6868
description: '获取域名的全部解析记录列表。',
6969
args: {
70-
ZID: z.number()
70+
ZID: z.number().describe('关联的域名 ID')
7171
},
7272
action: 'ListRecords',
7373
service: trafficRouteService,

server/mcp_server_traffic_route/nodejs/src/utils/tools.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ const store = {
119119
services: {} as Record<string, Service>
120120
}
121121

122+
/**
123+
* Gets the access key ID and secret key from environment variables.
124+
*/
125+
function aksk() {
126+
return {
127+
ak: process.env.VOLCENGINE_ACCESS_KEY ?? process.env.VOLC_ACCESS_KEY_ID,
128+
sk: process.env.VOLCENGINE_SECRET_KEY ?? process.env.VOLC_ACCESS_KEY_SECRET,
129+
}
130+
}
131+
122132
/**
123133
* Generates the tool result by text.
124134
* @param value The input text to convert.
@@ -180,9 +190,10 @@ export function registerService(key: string | undefined, service: Service | Serv
180190
}
181191

182192
const obj = new Service(service);
183-
if (process.env.VOLC_ACCESS_KEY_ID && process.env.VOLC_ACCESS_KEY_SECRET) {
184-
obj.setAccessKeyId(process.env.VOLC_ACCESS_KEY_ID);
185-
obj.setSecretKey(process.env.VOLC_ACCESS_KEY_SECRET);
193+
const { ak, sk } = aksk();
194+
if (ak && sk) {
195+
obj.setAccessKeyId(ak);
196+
obj.setSecretKey(sk);
186197
}
187198

188199
store.services[key] = obj;
@@ -194,13 +205,14 @@ export function registerService(key: string | undefined, service: Service | Serv
194205
* Update credential of each service.
195206
*/
196207
export function batchUpdateAccessKey() {
197-
if (!process.env.VOLC_ACCESS_KEY_ID || !process.env.VOLC_ACCESS_KEY_SECRET) return;
208+
const { ak, sk } = aksk();
209+
if (!ak || !sk) return;
198210
for (const key in store.services) {
199211
if (typeof key !== 'string') continue;
200212
const service = store.services[key];
201213
if (service instanceof Service) {
202-
service.setAccessKeyId(process.env.VOLC_ACCESS_KEY_ID);
203-
service.setSecretKey(process.env.VOLC_ACCESS_KEY_SECRET);
214+
service.setAccessKeyId(ak);
215+
service.setSecretKey(sk);
204216
}
205217
}
206218
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import os
22

33
def get_ak():
4-
s = os.getenv("VOLC_ACCESSKEY")
4+
s = os.getenv("VOLCENGINE_ACCESS_KEY")
55
if (s is None):
66
s = os.getenv("VOLC_ACCESS_KEY_ID")
77
return s
88

99
def get_sk():
10-
s = os.getenv("VOLC_SECRETKEY")
10+
s = os.getenv("VOLCENGINE_SECRET_KEY")
1111
if (s is None):
1212
s = os.getenv("VOLC_ACCESS_KEY_SECRET")
1313
return s

server/mcp_server_traffic_route/python/vcloud/base/base_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# coding:utf-8
2-
from src.base.base_trait import BaseTrait # Modify it if necessary
2+
from vcloud.base.base_trait import BaseTrait # Modify it if necessary
33

44

55
class BaseService(BaseTrait):
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
from vcloud.base.base_service import BaseService
22
from .config import *
3-
from ...base.aksk import get_ak, get_sk
3+
import os
4+
5+
class TrafficRouteAPI(BaseService):
46

5-
class VeenedgeAPI(BaseService):
67
def __init__(self):
8+
if os.getenv("VOLCENGINE_REGION") is None:
9+
region = "cn-north-1"
10+
else:
11+
region = os.getenv("VOLCENGINE_REGION")
12+
713
super().__init__(
8-
ak=get_ak(),
9-
sk=get_sk(),
14+
ak=os.getenv("VOLCENGINE_ACCESS_KEY"),
15+
sk=os.getenv("VOLCENGINE_SECRET_KEY"),
16+
region=region,
1017
service_info_map=service_info_map,
1118
)
1219
self.set_api_info(api_info)

0 commit comments

Comments
 (0)