Skip to content

Commit 72dfb3b

Browse files
committed
feat!: Make server-tool name separator configurable
The default separator for combining server names and tool names has been changed from '--' to '__'. This is a breaking change for users who relied on the hardcoded separator in tool_config.json or other integrations. The separator can now be configured using the SERVER_TOOLNAME_SEPERATOR environment variable. It must be at least 2 characters long and contain only letters, numbers, '-', and '_'. Invalid values will fall back to the default '__'.
1 parent d2d7d7d commit 72dfb3b

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,18 @@ Example `config/tool_config.json`:
121121
```json
122122
{
123123
"tools": {
124-
"unique-server-key1--tool-name-from-server": {
124+
"unique-server-key1__tool-name-from-server": {
125125
"enabled": true,
126126
"displayName": "My Custom Tool Name",
127127
"description": "A more user-friendly description."
128128
},
129-
"another-sse-server--another-tool": {
129+
"another-sse-server__another-tool": {
130130
"enabled": false
131131
}
132132
}
133133
}
134134
```
135-
- Keys are in the format `<server_key>--<original_tool_name>`.
135+
- Keys are in the format `<server_key><separator><original_tool_name>`, where `<separator>` is the value of the `SERVER_TOOLNAME_SEPERATOR` environment variable (defaults to `__`).
136136
- `enabled`: (Optional, default: `true`) Set to `false` to hide this tool from clients connecting to the proxy.
137137
- `displayName`: (Optional) Override the tool's name in client UIs.
138138
- `description`: (Optional) Override the tool's description.
@@ -174,10 +174,10 @@ Example `config/tool_config.json`:
174174
export TOOLS_FOLDER=/srv/mcp_tools
175175
```
176176
177-
- **`SERVER_TOOLNAME_SEPERATOR`**: (Optional) Defines the separator used to combine the server name and tool name when generating the unique key for tools (e.g., `server-key--tool-name`). This key is used internally and in the `tool_config.json` file.
178-
- Default: `--`.
177+
- **`SERVER_TOOLNAME_SEPERATOR`**: (Optional) Defines the separator used to combine the server name and tool name when generating the unique key for tools (e.g., `server-key__tool-name`). This key is used internally and in the `tool_config.json` file.
178+
- Default: `__`.
179179
- Must be at least 2 characters long and contain only letters (a-z, A-Z), numbers (0-9), hyphens (`-`), and underscores (`_`).
180-
- If the provided value is invalid, the default (`--`) will be used, and a warning will be logged.
180+
- If the provided value is invalid, the default (`__`) will be used, and a warning will be logged.
181181
```bash
182182
export SERVER_TOOLNAME_SEPERATOR="___" # Example: using triple underscore
183183
```

README_ZH.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,18 @@
122122
```json
123123
{
124124
"tools": {
125-
"unique-server-key1--tool-name-from-server": {
125+
"unique-server-key1__tool-name-from-server": {
126126
"enabled": true,
127127
"displayName": "我的自定义工具名称",
128128
"description": "一个更友好的描述。"
129129
},
130-
"another-sse-server--another-tool": {
130+
"another-sse-server__another-tool": {
131131
"enabled": false
132132
}
133133
}
134134
}
135135
```
136-
- 键的格式为 `<server_key>--<original_tool_name>`
136+
- 键的格式为 `<server_key><separator><original_tool_name>`,其中 `<separator>``SERVER_TOOLNAME_SEPERATOR` 环境变量的值(默认为 `__`
137137
- `enabled`: (可选, 默认: `true`) 设置为 `false` 以向连接到代理的客户端隐藏此工具。
138138
- `displayName`: (可选) 在客户端 UI 中覆盖工具的名称。
139139
- `description`: (可选) 覆盖工具的描述。
@@ -175,10 +175,10 @@
175175
export TOOLS_FOLDER=/srv/mcp_tools
176176
```
177177

178-
- **`SERVER_TOOLNAME_SEPERATOR`**: (可选) 定义用于组合服务器名称和工具名称以生成工具唯一键的分隔符(例如 `server-key--tool-name`)。此键在内部和 `tool_config.json` 文件中使用。
179-
- 默认值:`--`
178+
- **`SERVER_TOOLNAME_SEPERATOR`**: (可选) 定义用于组合服务器名称和工具名称以生成工具唯一键的分隔符(例如 `server-key__tool-name`)。此键在内部和 `tool_config.json` 文件中使用。
179+
- 默认值:`__`
180180
- 必须至少包含 2 个字符,且只能包含字母(a-z, A-Z)、数字(0-9)、连字符(`-`)和下划线(`_`)。
181-
- 如果提供的值无效,将使用默认值(`--`)并记录警告。
181+
- 如果提供的值无效,将使用默认值(`__`)并记录警告。
182182
```bash
183183
export SERVER_TOOLNAME_SEPERATOR="___" # 示例:使用三个下划线
184184
```

public/tools.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const saveToolConfigButton = document.getElementById('save-tool-config-button');
44
// const saveToolStatus = document.getElementById('save-tool-status'); // Removed: Declared in script.js
55
// Note: Assumes currentToolConfig and discoveredTools variables are globally accessible from script.js or passed.
66
// Note: Assumes triggerReload function is globally accessible from script.js or passed.
7-
let serverToolnameSeparator = '--'; // Default separator
7+
let serverToolnameSeparator = '__'; // Default separator
88

99
// --- Tool Configuration Management ---
1010
async function loadToolData() {
@@ -33,7 +33,7 @@ async function loadToolData() {
3333
}
3434

3535
const envResult = await envResponse.json(); // Parse environment info
36-
serverToolnameSeparator = envResult.serverToolnameSeparator || '--'; // Update separator
36+
serverToolnameSeparator = envResult.serverToolnameSeparator || '__'; // Update separator
3737
console.log(`Using server toolname separator from backend: "${serverToolnameSeparator}"`);
3838

3939
renderTools(); // Render using both discovered and configured data

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface ProxySettings {
4747
stdioToolCallRetryDelayBaseMs?: number;
4848
}
4949

50-
export const DEFAULT_SERVER_TOOLNAME_SEPERATOR = '--';
50+
export const DEFAULT_SERVER_TOOLNAME_SEPERATOR = '__'; // Changed default separator
5151
export const SERVER_TOOLNAME_SEPERATOR_ENV_VAR = 'SERVER_TOOLNAME_SEPERATOR';
5252

5353
export interface Config {

0 commit comments

Comments
 (0)