Skip to content

Commit 8f33a75

Browse files
authored
fix: add /mcp-servers prefix & add lint rules (#149)
* fix(gateway): 修正 MCP Server 路径设置及相关调用逻辑 - 将 MCP Server 配置路径改为 /mcp-servers/ 前缀 - 修复 AdpAIGatewayOperator 和 ApsaraGatewayOperator 中路径设置错误 - 删除前端 ApiProductLinkApi 中对特定源路径的硬编码处理 - 移除 McpDetail 页面中针对路径的特殊拼接逻辑 - 保持路径配置统一,避免前端和后端路径不一致问题 * test hooks * chore(workflow): disable ESLint checks in frontend lint workflow Disabled ESLint execution in both main and create check summary jobs while preserving the TypeScript type check. The ESLint steps are commented out rather than removed entirely for potential future re-enablement.
1 parent 7bf5f5e commit 8f33a75

File tree

15 files changed

+112
-53
lines changed

15 files changed

+112
-53
lines changed

.github/workflows/frontend-lint.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ jobs:
7070
- name: Install dependencies
7171
run: npm install --legacy-peer-deps # Using legacy-peer-deps to handle React 19 compatibility
7272

73-
- name: Run ESLint
74-
run: npm run lint
75-
# No continue-on-error - let it fail naturally
73+
# - name: Run ESLint
74+
# run: npm run lint
75+
# # No continue-on-error - let it fail naturally
7676

7777
- name: Run TypeScript type check
7878
run: npm run type-check
@@ -113,9 +113,9 @@ jobs:
113113
- name: Install dependencies
114114
run: npm install --legacy-peer-deps # Using legacy-peer-deps to handle React 19 compatibility
115115

116-
- name: Run ESLint
117-
run: npm run lint
118-
# No continue-on-error - let it fail naturally
116+
# - name: Run ESLint
117+
# run: npm run lint
118+
# # No continue-on-error - let it fail naturally
119119

120120
- name: Create check summary
121121
if: always()

.husky/pre-commit

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env sh
2+
3+
# 检查前端子目录的 diff 文件
4+
echo "🔍 Linting frontend diff files..."
5+
cd himarket-web/himarket-frontend && npx lint-staged
6+
7+
# 检查管理后台子目录的 diff 文件
8+
echo "🔍 Linting admin diff files..."
9+
cd ../himarket-admin && npx lint-staged
10+

himarket-server/src/main/java/com/alibaba/himarket/service/gateway/AdpAIGatewayOperator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ private String convertToMCPConfig(
325325

326326
// 设置 MCP Server 配置
327327
MCPConfigResult.MCPServerConfig serverConfig = new MCPConfigResult.MCPServerConfig();
328-
serverConfig.setPath("/" + data.getName());
328+
serverConfig.setPath("/mcp-servers/" + data.getName());
329329

330330
// 获取网关实例访问信息并设置域名信息
331331
List<DomainResult> domains = getGatewayAccessDomains(data.getGwInstanceId(), config);

himarket-server/src/main/java/com/alibaba/himarket/service/gateway/ApsaraGatewayOperator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private String convertToMCPConfig(
195195

196196
// 设置MCP Server配置
197197
MCPConfigResult.MCPServerConfig serverConfig = new MCPConfigResult.MCPServerConfig();
198-
serverConfig.setPath("/" + data.getName());
198+
serverConfig.setPath("/mcp-servers/" + data.getName());
199199

200200
// 获取网关实例访问信息并设置域名信息
201201
List<DomainResult> domains = getGatewayAccessDomains(gwInstanceId, config);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
build/
3+
dist/
4+
**/*.min.js
5+
**/*-min.js
6+
**/*.bundle.js
7+
tailwind.config.js
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": false,
5+
"printWidth": 80,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"bracketSpacing": true,
9+
"arrowParens": "avoid"
10+
}
Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
1-
import js from '@eslint/js'
2-
import globals from 'globals'
3-
import reactHooks from 'eslint-plugin-react-hooks'
4-
import reactRefresh from 'eslint-plugin-react-refresh'
1+
// import js from '@eslint/js'
2+
import globals from "globals";
3+
import reactHooks from "eslint-plugin-react-hooks";
4+
import reactRefresh from "eslint-plugin-react-refresh";
5+
import tseslint from "typescript-eslint";
6+
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
57

68
export default [
9+
...tseslint.configs.recommended,
10+
eslintPluginPrettierRecommended,
711
{
8-
ignores: ['dist'],
9-
},
10-
js.configs.recommended,
11-
{
12-
files: ['**/*.{js,jsx}'],
12+
files: ["**/*.{js,jsx,ts,tsx}"],
1313
plugins: {
14-
'react-hooks': reactHooks,
15-
'react-refresh': reactRefresh,
16-
},
17-
languageOptions: {
18-
ecmaVersion: 2020,
19-
globals: globals.browser,
20-
parserOptions: {
21-
ecmaVersion: 'latest',
22-
ecmaFeatures: { jsx: true },
23-
sourceType: 'module',
24-
},
14+
"react-hooks": reactHooks,
15+
"react-refresh": reactRefresh,
2516
},
2617
rules: {
2718
...reactHooks.configs.recommended.rules,
28-
'react-refresh/only-export-components': [
29-
'warn',
19+
"react-refresh/only-export-components": [
20+
"warn",
3021
{ allowConstantExport: true },
3122
],
32-
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
23+
// 允许在 effect 中调用异步函数,只要状态更新在异步回调中
24+
"react-hooks/set-state-in-effect": "off",
25+
},
26+
languageOptions: {
27+
globals: globals.browser,
3328
},
3429
},
35-
]
30+
];

himarket-web/himarket-admin/package.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,27 @@
5151
"eslint": "^9.30.1",
5252
"eslint-plugin-react-hooks": "^5.2.0",
5353
"eslint-plugin-react-refresh": "^0.4.20",
54+
"eslint-config-prettier": "^10.1.8",
55+
"eslint-plugin-prettier": "^5.5.4",
56+
"lint-staged": "^16.2.7",
57+
"prettier": "^3.7.4",
5458
"express": "^4.21.2",
5559
"globals": "^16.3.0",
5660
"path": "^0.12.7",
5761
"postcss": "^8.5.6",
5862
"tailwindcss": "^3.4.17",
5963
"typescript": "^5.6.3",
6064
"url": "^0.11.4",
65+
"typescript-eslint": "^8.35.1",
6166
"vite": "^4.5.14"
67+
},
68+
"lint-staged": {
69+
"*.{js,jsx,ts,tsx}": [
70+
"eslint --fix",
71+
"prettier --write"
72+
],
73+
"*.{css,scss,json,md}": [
74+
"prettier --write"
75+
]
6276
}
63-
}
77+
}

himarket-web/himarket-admin/src/components/api-product/ApiProductLinkApi.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,6 @@ export function ApiProductLinkApi({ apiProduct, linkedService, onLinkedServiceUp
190190
const baseUrl = `${domain.protocol}://${formattedDomain}`;
191191
let fullUrl = `${baseUrl}${path || '/'}`;
192192

193-
if (apiProduct.mcpConfig?.meta?.source === 'ADP_AI_GATEWAY' ||
194-
apiProduct.mcpConfig?.meta?.source === 'APSARA_GATEWAY') {
195-
fullUrl = `${baseUrl}/mcp-servers${path || '/'}`;
196-
}
197-
198193
if (protocolType === 'SSE') {
199194
// 仅生成SSE配置,不追加/sse
200195
const sseConfig = {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
build/
3+
dist/
4+
**/*.min.js
5+
**/*-min.js
6+
**/*.bundle.js
7+
tailwind.config.js

0 commit comments

Comments
 (0)