Commit 02dfbda1 by Archer Committed by GitHub

update mcp server (#5076)

* update mcp server

* fix: action

* fix: dockerfile

* fix: dockerfile

* fix: dockerfile

* fix: dockerfile

* fix: dockerfile

* fix: dockerfile
parent 3ed3f2ad
...@@ -7,6 +7,16 @@ toc: true ...@@ -7,6 +7,16 @@ toc: true
weight: 787 weight: 787
--- ---
## 更新指南
### 1. 更新镜像:
- 更新 FastGPT 镜像 tag: v4.9.13
- 更新 FastGPT 商业版镜像 tag: v4.9.13
- mcp_server 无需更新
- Sandbox 无需更新
- AIProxy 无需更新
## 🚀 新增内容 ## 🚀 新增内容
......
...@@ -4,7 +4,7 @@ description: 'FastGPT V4.9.14 更新说明' ...@@ -4,7 +4,7 @@ description: 'FastGPT V4.9.14 更新说明'
icon: 'upgrade' icon: 'upgrade'
draft: false draft: false
toc: true toc: true
weight: 787 weight: 786
--- ---
......
...@@ -697,12 +697,12 @@ importers: ...@@ -697,12 +697,12 @@ importers:
projects/mcp_server: projects/mcp_server:
dependencies: dependencies:
'@fastgpt/global':
specifier: workspace:*
version: link:../../packages/global
'@modelcontextprotocol/sdk': '@modelcontextprotocol/sdk':
specifier: ^1.12.1 specifier: ^1.12.1
version: 1.12.2 version: 1.12.2
axios:
specifier: ^1.8.2
version: 1.8.4
chalk: chalk:
specifier: ^5.3.0 specifier: ^5.3.0
version: 5.4.1 version: 5.4.1
...@@ -719,15 +719,6 @@ importers: ...@@ -719,15 +719,6 @@ importers:
'@types/express': '@types/express':
specifier: ^5.0.1 specifier: ^5.0.1
version: 5.0.1 version: 5.0.1
nodemon:
specifier: ^3.1.9
version: 3.1.9
shx:
specifier: ^0.3.4
version: 0.3.4
typescript:
specifier: ^5.6.2
version: 5.8.2
projects/sandbox: projects/sandbox:
dependencies: dependencies:
...@@ -5994,9 +5985,6 @@ packages: ...@@ -5994,9 +5985,6 @@ packages:
ieee754@1.2.1: ieee754@1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
ignore-by-default@1.0.1:
resolution: {integrity: sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==}
ignore@5.3.2: ignore@5.3.2:
resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==}
engines: {node: '>= 4'} engines: {node: '>= 4'}
...@@ -6070,10 +6058,6 @@ packages: ...@@ -6070,10 +6058,6 @@ packages:
resolution: {integrity: sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==} resolution: {integrity: sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==}
engines: {node: '>=12'} engines: {node: '>=12'}
interpret@1.4.0:
resolution: {integrity: sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==}
engines: {node: '>= 0.10'}
intersection-observer@0.12.2: intersection-observer@0.12.2:
resolution: {integrity: sha512-7m1vEcPCxXYI8HqnL8CKI6siDyD+eIWSwgB3DZA+ZTogxk9I4CDnj4wilt9x/+/QbHI4YG5YZNmC6458/e9Ktg==} resolution: {integrity: sha512-7m1vEcPCxXYI8HqnL8CKI6siDyD+eIWSwgB3DZA+ZTogxk9I4CDnj4wilt9x/+/QbHI4YG5YZNmC6458/e9Ktg==}
...@@ -7535,11 +7519,6 @@ packages: ...@@ -7535,11 +7519,6 @@ packages:
resolution: {integrity: sha512-SQ3wZCExjeSatLE/HBaXS5vqUOQk6GtBdIIKxiFdmm01mOQZX/POJkO3SUX1wDiYcwUOJwT23scFSC9fY2H8IA==} resolution: {integrity: sha512-SQ3wZCExjeSatLE/HBaXS5vqUOQk6GtBdIIKxiFdmm01mOQZX/POJkO3SUX1wDiYcwUOJwT23scFSC9fY2H8IA==}
engines: {node: '>=6.0.0'} engines: {node: '>=6.0.0'}
nodemon@3.1.9:
resolution: {integrity: sha512-hdr1oIb2p6ZSxu3PB2JWWYS7ZQ0qvaZsc3hK8DR8f02kRzc8rjYmxAIvdz+aYC+8F2IjNaB7HMcSDg8nQpJxyg==}
engines: {node: '>=10'}
hasBin: true
non-layered-tidy-tree-layout@2.0.2: non-layered-tidy-tree-layout@2.0.2:
resolution: {integrity: sha512-gkXMxRzUH+PB0ax9dUN0yYF0S25BqeAYqhgMaLUFmpXLEk7Fcu8f4emJuOAY0V8kjDICxROIKsTAKsV/v355xw==} resolution: {integrity: sha512-gkXMxRzUH+PB0ax9dUN0yYF0S25BqeAYqhgMaLUFmpXLEk7Fcu8f4emJuOAY0V8kjDICxROIKsTAKsV/v355xw==}
...@@ -8055,9 +8034,6 @@ packages: ...@@ -8055,9 +8034,6 @@ packages:
proxy-from-env@1.1.0: proxy-from-env@1.1.0:
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
pstree.remy@1.1.8:
resolution: {integrity: sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==}
pump@3.0.2: pump@3.0.2:
resolution: {integrity: sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==} resolution: {integrity: sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==}
...@@ -8306,10 +8282,6 @@ packages: ...@@ -8306,10 +8282,6 @@ packages:
react: ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 react: ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
react-dom: ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 react-dom: ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
rechoir@0.6.2:
resolution: {integrity: sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==}
engines: {node: '>= 0.10'}
redis-errors@1.2.0: redis-errors@1.2.0:
resolution: {integrity: sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==} resolution: {integrity: sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==}
engines: {node: '>=4'} engines: {node: '>=4'}
...@@ -8651,16 +8623,6 @@ packages: ...@@ -8651,16 +8623,6 @@ packages:
resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}
engines: {node: '>=8'} engines: {node: '>=8'}
shelljs@0.8.5:
resolution: {integrity: sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==}
engines: {node: '>=4'}
hasBin: true
shx@0.3.4:
resolution: {integrity: sha512-N6A9MLVqjxZYcVn8hLmtneQWIJtp8IKzMP4eMnx+nqkvXoqinUPCbUFLp2UcWTEIUONhlk0ewxr/jaVGlc+J+g==}
engines: {node: '>=6'}
hasBin: true
side-channel-list@1.0.0: side-channel-list@1.0.0:
resolution: {integrity: sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==} resolution: {integrity: sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
...@@ -8699,10 +8661,6 @@ packages: ...@@ -8699,10 +8661,6 @@ packages:
simple-swizzle@0.2.2: simple-swizzle@0.2.2:
resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==}
simple-update-notifier@2.0.0:
resolution: {integrity: sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==}
engines: {node: '>=10'}
sisteransi@1.0.5: sisteransi@1.0.5:
resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}
...@@ -9127,10 +9085,6 @@ packages: ...@@ -9127,10 +9085,6 @@ packages:
resolution: {integrity: sha512-lbDrTLVsHhOMljPscd0yitpozq7Ga2M5Cvez5AjGg8GASBjtt6iERCAJ93yommPmz62fb45oFIXHEZ3u9bfJEA==} resolution: {integrity: sha512-lbDrTLVsHhOMljPscd0yitpozq7Ga2M5Cvez5AjGg8GASBjtt6iERCAJ93yommPmz62fb45oFIXHEZ3u9bfJEA==}
engines: {node: '>=14.16'} engines: {node: '>=14.16'}
touch@3.1.1:
resolution: {integrity: sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==}
hasBin: true
tr46@0.0.3: tr46@0.0.3:
resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==}
...@@ -9333,9 +9287,6 @@ packages: ...@@ -9333,9 +9287,6 @@ packages:
unbzip2-stream@1.4.3: unbzip2-stream@1.4.3:
resolution: {integrity: sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==} resolution: {integrity: sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==}
undefsafe@2.0.5:
resolution: {integrity: sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==}
underscore@1.13.7: underscore@1.13.7:
resolution: {integrity: sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g==} resolution: {integrity: sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g==}
...@@ -10167,7 +10118,7 @@ snapshots: ...@@ -10167,7 +10118,7 @@ snapshots:
'@babel/traverse': 7.26.10 '@babel/traverse': 7.26.10
'@babel/types': 7.26.10 '@babel/types': 7.26.10
convert-source-map: 2.0.0 convert-source-map: 2.0.0
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
gensync: 1.0.0-beta.2 gensync: 1.0.0-beta.2
json5: 2.2.3 json5: 2.2.3
semver: 6.3.1 semver: 6.3.1
...@@ -10219,7 +10170,7 @@ snapshots: ...@@ -10219,7 +10170,7 @@ snapshots:
'@babel/core': 7.26.10 '@babel/core': 7.26.10
'@babel/helper-compilation-targets': 7.26.5 '@babel/helper-compilation-targets': 7.26.5
'@babel/helper-plugin-utils': 7.26.5 '@babel/helper-plugin-utils': 7.26.5
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
lodash.debounce: 4.0.8 lodash.debounce: 4.0.8
resolve: 1.22.10 resolve: 1.22.10
transitivePeerDependencies: transitivePeerDependencies:
...@@ -10923,7 +10874,7 @@ snapshots: ...@@ -10923,7 +10874,7 @@ snapshots:
'@babel/parser': 7.26.10 '@babel/parser': 7.26.10
'@babel/template': 7.26.9 '@babel/template': 7.26.9
'@babel/types': 7.26.10 '@babel/types': 7.26.10
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
globals: 11.12.0 globals: 11.12.0
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -11394,7 +11345,7 @@ snapshots: ...@@ -11394,7 +11345,7 @@ snapshots:
'@eslint/eslintrc@2.1.4': '@eslint/eslintrc@2.1.4':
dependencies: dependencies:
ajv: 6.12.6 ajv: 6.12.6
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
espree: 9.6.1 espree: 9.6.1
globals: 13.24.0 globals: 13.24.0
ignore: 5.3.2 ignore: 5.3.2
...@@ -11482,7 +11433,7 @@ snapshots: ...@@ -11482,7 +11433,7 @@ snapshots:
'@humanwhocodes/config-array@0.11.14': '@humanwhocodes/config-array@0.11.14':
dependencies: dependencies:
'@humanwhocodes/object-schema': 2.0.3 '@humanwhocodes/object-schema': 2.0.3
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
minimatch: 3.1.2 minimatch: 3.1.2
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -11490,7 +11441,7 @@ snapshots: ...@@ -11490,7 +11441,7 @@ snapshots:
'@humanwhocodes/config-array@0.13.0': '@humanwhocodes/config-array@0.13.0':
dependencies: dependencies:
'@humanwhocodes/object-schema': 2.0.3 '@humanwhocodes/object-schema': 2.0.3
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
minimatch: 3.1.2 minimatch: 3.1.2
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -13051,7 +13002,7 @@ snapshots: ...@@ -13051,7 +13002,7 @@ snapshots:
'@typescript-eslint/type-utils': 6.21.0(eslint@8.56.0)(typescript@5.8.2) '@typescript-eslint/type-utils': 6.21.0(eslint@8.56.0)(typescript@5.8.2)
'@typescript-eslint/utils': 6.21.0(eslint@8.56.0)(typescript@5.8.2) '@typescript-eslint/utils': 6.21.0(eslint@8.56.0)(typescript@5.8.2)
'@typescript-eslint/visitor-keys': 6.21.0 '@typescript-eslint/visitor-keys': 6.21.0
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
eslint: 8.56.0 eslint: 8.56.0
graphemer: 1.4.0 graphemer: 1.4.0
ignore: 5.3.2 ignore: 5.3.2
...@@ -13071,7 +13022,7 @@ snapshots: ...@@ -13071,7 +13022,7 @@ snapshots:
'@typescript-eslint/type-utils': 6.21.0(eslint@8.57.1)(typescript@5.8.2) '@typescript-eslint/type-utils': 6.21.0(eslint@8.57.1)(typescript@5.8.2)
'@typescript-eslint/utils': 6.21.0(eslint@8.57.1)(typescript@5.8.2) '@typescript-eslint/utils': 6.21.0(eslint@8.57.1)(typescript@5.8.2)
'@typescript-eslint/visitor-keys': 6.21.0 '@typescript-eslint/visitor-keys': 6.21.0
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
eslint: 8.57.1 eslint: 8.57.1
graphemer: 1.4.0 graphemer: 1.4.0
ignore: 5.3.2 ignore: 5.3.2
...@@ -13089,7 +13040,7 @@ snapshots: ...@@ -13089,7 +13040,7 @@ snapshots:
'@typescript-eslint/types': 6.21.0 '@typescript-eslint/types': 6.21.0
'@typescript-eslint/typescript-estree': 6.21.0(typescript@5.8.2) '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.8.2)
'@typescript-eslint/visitor-keys': 6.21.0 '@typescript-eslint/visitor-keys': 6.21.0
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
eslint: 8.56.0 eslint: 8.56.0
optionalDependencies: optionalDependencies:
typescript: 5.8.2 typescript: 5.8.2
...@@ -13102,7 +13053,7 @@ snapshots: ...@@ -13102,7 +13053,7 @@ snapshots:
'@typescript-eslint/types': 6.21.0 '@typescript-eslint/types': 6.21.0
'@typescript-eslint/typescript-estree': 6.21.0(typescript@5.8.2) '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.8.2)
'@typescript-eslint/visitor-keys': 6.21.0 '@typescript-eslint/visitor-keys': 6.21.0
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
eslint: 8.57.1 eslint: 8.57.1
optionalDependencies: optionalDependencies:
typescript: 5.8.2 typescript: 5.8.2
...@@ -13118,7 +13069,7 @@ snapshots: ...@@ -13118,7 +13069,7 @@ snapshots:
dependencies: dependencies:
'@typescript-eslint/typescript-estree': 6.21.0(typescript@5.8.2) '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.8.2)
'@typescript-eslint/utils': 6.21.0(eslint@8.56.0)(typescript@5.8.2) '@typescript-eslint/utils': 6.21.0(eslint@8.56.0)(typescript@5.8.2)
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
eslint: 8.56.0 eslint: 8.56.0
ts-api-utils: 1.4.3(typescript@5.8.2) ts-api-utils: 1.4.3(typescript@5.8.2)
optionalDependencies: optionalDependencies:
...@@ -13130,7 +13081,7 @@ snapshots: ...@@ -13130,7 +13081,7 @@ snapshots:
dependencies: dependencies:
'@typescript-eslint/typescript-estree': 6.21.0(typescript@5.8.2) '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.8.2)
'@typescript-eslint/utils': 6.21.0(eslint@8.57.1)(typescript@5.8.2) '@typescript-eslint/utils': 6.21.0(eslint@8.57.1)(typescript@5.8.2)
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
eslint: 8.57.1 eslint: 8.57.1
ts-api-utils: 1.4.3(typescript@5.8.2) ts-api-utils: 1.4.3(typescript@5.8.2)
optionalDependencies: optionalDependencies:
...@@ -13144,7 +13095,7 @@ snapshots: ...@@ -13144,7 +13095,7 @@ snapshots:
dependencies: dependencies:
'@typescript-eslint/types': 6.21.0 '@typescript-eslint/types': 6.21.0
'@typescript-eslint/visitor-keys': 6.21.0 '@typescript-eslint/visitor-keys': 6.21.0
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
globby: 11.1.0 globby: 11.1.0
is-glob: 4.0.3 is-glob: 4.0.3
minimatch: 9.0.3 minimatch: 9.0.3
...@@ -13194,7 +13145,7 @@ snapshots: ...@@ -13194,7 +13145,7 @@ snapshots:
dependencies: dependencies:
'@ampproject/remapping': 2.3.0 '@ampproject/remapping': 2.3.0
'@bcoe/v8-coverage': 1.0.2 '@bcoe/v8-coverage': 1.0.2
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
istanbul-lib-coverage: 3.2.2 istanbul-lib-coverage: 3.2.2
istanbul-lib-report: 3.0.1 istanbul-lib-report: 3.0.1
istanbul-lib-source-maps: 5.0.6 istanbul-lib-source-maps: 5.0.6
...@@ -13842,7 +13793,7 @@ snapshots: ...@@ -13842,7 +13793,7 @@ snapshots:
dependencies: dependencies:
bytes: 3.1.2 bytes: 3.1.2
content-type: 1.0.5 content-type: 1.0.5
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
http-errors: 2.0.0 http-errors: 2.0.0
iconv-lite: 0.6.3 iconv-lite: 0.6.3
on-finished: 2.4.1 on-finished: 2.4.1
...@@ -14627,11 +14578,9 @@ snapshots: ...@@ -14627,11 +14578,9 @@ snapshots:
dependencies: dependencies:
ms: 2.1.2 ms: 2.1.2
debug@4.4.0(supports-color@5.5.0): debug@4.4.0:
dependencies: dependencies:
ms: 2.1.3 ms: 2.1.3
optionalDependencies:
supports-color: 5.5.0
decamelize@1.2.0: {} decamelize@1.2.0: {}
...@@ -15133,7 +15082,7 @@ snapshots: ...@@ -15133,7 +15082,7 @@ snapshots:
eslint-import-resolver-typescript@3.9.0(eslint-plugin-import@2.31.0)(eslint@8.56.0): eslint-import-resolver-typescript@3.9.0(eslint-plugin-import@2.31.0)(eslint@8.56.0):
dependencies: dependencies:
'@nolyfill/is-core-module': 1.0.39 '@nolyfill/is-core-module': 1.0.39
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
eslint: 8.56.0 eslint: 8.56.0
get-tsconfig: 4.10.0 get-tsconfig: 4.10.0
is-bun-module: 1.3.0 is-bun-module: 1.3.0
...@@ -15148,7 +15097,7 @@ snapshots: ...@@ -15148,7 +15097,7 @@ snapshots:
eslint-import-resolver-typescript@3.9.0(eslint-plugin-import@2.31.0)(eslint@8.57.1): eslint-import-resolver-typescript@3.9.0(eslint-plugin-import@2.31.0)(eslint@8.57.1):
dependencies: dependencies:
'@nolyfill/is-core-module': 1.0.39 '@nolyfill/is-core-module': 1.0.39
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
eslint: 8.57.1 eslint: 8.57.1
get-tsconfig: 4.10.0 get-tsconfig: 4.10.0
is-bun-module: 1.3.0 is-bun-module: 1.3.0
...@@ -15355,7 +15304,7 @@ snapshots: ...@@ -15355,7 +15304,7 @@ snapshots:
ajv: 6.12.6 ajv: 6.12.6
chalk: 4.1.2 chalk: 4.1.2
cross-spawn: 7.0.6 cross-spawn: 7.0.6
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
doctrine: 3.0.0 doctrine: 3.0.0
escape-string-regexp: 4.0.0 escape-string-regexp: 4.0.0
eslint-scope: 7.2.2 eslint-scope: 7.2.2
...@@ -15398,7 +15347,7 @@ snapshots: ...@@ -15398,7 +15347,7 @@ snapshots:
ajv: 6.12.6 ajv: 6.12.6
chalk: 4.1.2 chalk: 4.1.2
cross-spawn: 7.0.6 cross-spawn: 7.0.6
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
doctrine: 3.0.0 doctrine: 3.0.0
escape-string-regexp: 4.0.0 escape-string-regexp: 4.0.0
eslint-scope: 7.2.2 eslint-scope: 7.2.2
...@@ -15576,7 +15525,7 @@ snapshots: ...@@ -15576,7 +15525,7 @@ snapshots:
content-type: 1.0.5 content-type: 1.0.5
cookie: 0.7.2 cookie: 0.7.2
cookie-signature: 1.2.2 cookie-signature: 1.2.2
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
encodeurl: 2.0.0 encodeurl: 2.0.0
escape-html: 1.0.3 escape-html: 1.0.3
etag: 1.8.1 etag: 1.8.1
...@@ -15757,7 +15706,7 @@ snapshots: ...@@ -15757,7 +15706,7 @@ snapshots:
finalhandler@2.1.0: finalhandler@2.1.0:
dependencies: dependencies:
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
encodeurl: 2.0.0 encodeurl: 2.0.0
escape-html: 1.0.3 escape-html: 1.0.3
on-finished: 2.4.1 on-finished: 2.4.1
...@@ -15806,7 +15755,7 @@ snapshots: ...@@ -15806,7 +15755,7 @@ snapshots:
follow-redirects@1.15.9(debug@4.4.0): follow-redirects@1.15.9(debug@4.4.0):
optionalDependencies: optionalDependencies:
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
for-each@0.3.5: for-each@0.3.5:
dependencies: dependencies:
...@@ -16213,7 +16162,7 @@ snapshots: ...@@ -16213,7 +16162,7 @@ snapshots:
http-proxy-agent@7.0.2: http-proxy-agent@7.0.2:
dependencies: dependencies:
agent-base: 7.1.3 agent-base: 7.1.3
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -16225,7 +16174,7 @@ snapshots: ...@@ -16225,7 +16174,7 @@ snapshots:
https-proxy-agent@7.0.6: https-proxy-agent@7.0.6:
dependencies: dependencies:
agent-base: 7.1.3 agent-base: 7.1.3
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -16261,8 +16210,6 @@ snapshots: ...@@ -16261,8 +16210,6 @@ snapshots:
ieee754@1.2.1: {} ieee754@1.2.1: {}
ignore-by-default@1.0.1: {}
ignore@5.3.2: {} ignore@5.3.2: {}
immediate@3.0.6: {} immediate@3.0.6: {}
...@@ -16350,15 +16297,13 @@ snapshots: ...@@ -16350,15 +16297,13 @@ snapshots:
internmap@2.0.3: {} internmap@2.0.3: {}
interpret@1.4.0: {}
intersection-observer@0.12.2: {} intersection-observer@0.12.2: {}
ioredis@5.6.0: ioredis@5.6.0:
dependencies: dependencies:
'@ioredis/commands': 1.2.0 '@ioredis/commands': 1.2.0
cluster-key-slot: 1.1.2 cluster-key-slot: 1.1.2
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
denque: 2.1.0 denque: 2.1.0
lodash.defaults: 4.2.0 lodash.defaults: 4.2.0
lodash.isarguments: 3.1.0 lodash.isarguments: 3.1.0
...@@ -16629,7 +16574,7 @@ snapshots: ...@@ -16629,7 +16574,7 @@ snapshots:
istanbul-lib-source-maps@4.0.1: istanbul-lib-source-maps@4.0.1:
dependencies: dependencies:
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
istanbul-lib-coverage: 3.2.2 istanbul-lib-coverage: 3.2.2
source-map: 0.6.1 source-map: 0.6.1
transitivePeerDependencies: transitivePeerDependencies:
...@@ -16638,7 +16583,7 @@ snapshots: ...@@ -16638,7 +16583,7 @@ snapshots:
istanbul-lib-source-maps@5.0.6: istanbul-lib-source-maps@5.0.6:
dependencies: dependencies:
'@jridgewell/trace-mapping': 0.3.25 '@jridgewell/trace-mapping': 0.3.25
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
istanbul-lib-coverage: 3.2.2 istanbul-lib-coverage: 3.2.2
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -17931,7 +17876,7 @@ snapshots: ...@@ -17931,7 +17876,7 @@ snapshots:
micromark@3.2.0: micromark@3.2.0:
dependencies: dependencies:
'@types/debug': 4.1.12 '@types/debug': 4.1.12
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
decode-named-character-reference: 1.1.0 decode-named-character-reference: 1.1.0
micromark-core-commonmark: 1.1.0 micromark-core-commonmark: 1.1.0
micromark-factory-space: 1.1.0 micromark-factory-space: 1.1.0
...@@ -17953,7 +17898,7 @@ snapshots: ...@@ -17953,7 +17898,7 @@ snapshots:
micromark@4.0.2: micromark@4.0.2:
dependencies: dependencies:
'@types/debug': 4.1.12 '@types/debug': 4.1.12
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
decode-named-character-reference: 1.1.0 decode-named-character-reference: 1.1.0
devlop: 1.1.0 devlop: 1.1.0
micromark-core-commonmark: 2.0.3 micromark-core-commonmark: 2.0.3
...@@ -18093,7 +18038,7 @@ snapshots: ...@@ -18093,7 +18038,7 @@ snapshots:
dependencies: dependencies:
async-mutex: 0.5.0 async-mutex: 0.5.0
camelcase: 6.3.0 camelcase: 6.3.0
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
find-cache-dir: 3.3.2 find-cache-dir: 3.3.2
follow-redirects: 1.15.9(debug@4.4.0) follow-redirects: 1.15.9(debug@4.4.0)
https-proxy-agent: 7.0.6 https-proxy-agent: 7.0.6
...@@ -18158,7 +18103,7 @@ snapshots: ...@@ -18158,7 +18103,7 @@ snapshots:
mquery@5.0.0: mquery@5.0.0:
dependencies: dependencies:
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -18190,7 +18135,7 @@ snapshots: ...@@ -18190,7 +18135,7 @@ snapshots:
dependencies: dependencies:
'@tediousjs/connection-string': 0.5.0 '@tediousjs/connection-string': 0.5.0
commander: 11.1.0 commander: 11.1.0
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
rfdc: 1.4.1 rfdc: 1.4.1
tarn: 3.0.2 tarn: 3.0.2
tedious: 18.6.1 tedious: 18.6.1
...@@ -18252,7 +18197,7 @@ snapshots: ...@@ -18252,7 +18197,7 @@ snapshots:
new-find-package-json@2.0.0: new-find-package-json@2.0.0:
dependencies: dependencies:
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -18358,19 +18303,6 @@ snapshots: ...@@ -18358,19 +18303,6 @@ snapshots:
nodemailer@6.10.0: {} nodemailer@6.10.0: {}
nodemon@3.1.9:
dependencies:
chokidar: 3.6.0
debug: 4.4.0(supports-color@5.5.0)
ignore-by-default: 1.0.1
minimatch: 3.1.2
pstree.remy: 1.1.8
semver: 7.7.1
simple-update-notifier: 2.0.0
supports-color: 5.5.0
touch: 3.1.1
undefsafe: 2.0.5
non-layered-tidy-tree-layout@2.0.2: {} non-layered-tidy-tree-layout@2.0.2: {}
nopt@7.2.1: nopt@7.2.1:
...@@ -18919,8 +18851,6 @@ snapshots: ...@@ -18919,8 +18851,6 @@ snapshots:
proxy-from-env@1.1.0: {} proxy-from-env@1.1.0: {}
pstree.remy@1.1.8: {}
pump@3.0.2: pump@3.0.2:
dependencies: dependencies:
end-of-stream: 1.4.4 end-of-stream: 1.4.4
...@@ -19216,10 +19146,6 @@ snapshots: ...@@ -19216,10 +19146,6 @@ snapshots:
tiny-invariant: 1.3.3 tiny-invariant: 1.3.3
victory-vendor: 36.9.2 victory-vendor: 36.9.2
rechoir@0.6.2:
dependencies:
resolve: 1.22.10
redis-errors@1.2.0: {} redis-errors@1.2.0: {}
redis-parser@3.0.0: redis-parser@3.0.0:
...@@ -19477,7 +19403,7 @@ snapshots: ...@@ -19477,7 +19403,7 @@ snapshots:
router@2.2.0: router@2.2.0:
dependencies: dependencies:
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
depd: 2.0.0 depd: 2.0.0
is-promise: 4.0.0 is-promise: 4.0.0
parseurl: 1.3.3 parseurl: 1.3.3
...@@ -19605,7 +19531,7 @@ snapshots: ...@@ -19605,7 +19531,7 @@ snapshots:
send@1.2.0: send@1.2.0:
dependencies: dependencies:
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
encodeurl: 2.0.0 encodeurl: 2.0.0
escape-html: 1.0.3 escape-html: 1.0.3
etag: 1.8.1 etag: 1.8.1
...@@ -19679,17 +19605,6 @@ snapshots: ...@@ -19679,17 +19605,6 @@ snapshots:
shebang-regex@3.0.0: {} shebang-regex@3.0.0: {}
shelljs@0.8.5:
dependencies:
glob: 7.2.3
interpret: 1.4.0
rechoir: 0.6.2
shx@0.3.4:
dependencies:
minimist: 1.2.8
shelljs: 0.8.5
side-channel-list@1.0.0: side-channel-list@1.0.0:
dependencies: dependencies:
es-errors: 1.3.0 es-errors: 1.3.0
...@@ -19738,10 +19653,6 @@ snapshots: ...@@ -19738,10 +19653,6 @@ snapshots:
dependencies: dependencies:
is-arrayish: 0.3.2 is-arrayish: 0.3.2
simple-update-notifier@2.0.0:
dependencies:
semver: 7.7.1
sisteransi@1.0.5: {} sisteransi@1.0.5: {}
slash@3.0.0: {} slash@3.0.0: {}
...@@ -19756,7 +19667,7 @@ snapshots: ...@@ -19756,7 +19667,7 @@ snapshots:
socks-proxy-agent@8.0.5: socks-proxy-agent@8.0.5:
dependencies: dependencies:
agent-base: 7.1.3 agent-base: 7.1.3
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
socks: 2.8.4 socks: 2.8.4
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -19989,7 +19900,7 @@ snapshots: ...@@ -19989,7 +19900,7 @@ snapshots:
dependencies: dependencies:
component-emitter: 1.3.1 component-emitter: 1.3.1
cookiejar: 2.1.4 cookiejar: 2.1.4
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
fast-safe-stringify: 2.1.1 fast-safe-stringify: 2.1.1
form-data: 4.0.2 form-data: 4.0.2
formidable: 2.1.2 formidable: 2.1.2
...@@ -20186,8 +20097,6 @@ snapshots: ...@@ -20186,8 +20097,6 @@ snapshots:
'@tokenizer/token': 0.3.0 '@tokenizer/token': 0.3.0
ieee754: 1.2.1 ieee754: 1.2.1
touch@3.1.1: {}
tr46@0.0.3: {} tr46@0.0.3: {}
tr46@5.1.0: tr46@5.1.0:
...@@ -20387,8 +20296,6 @@ snapshots: ...@@ -20387,8 +20296,6 @@ snapshots:
buffer: 5.7.1 buffer: 5.7.1
through: 2.3.8 through: 2.3.8
undefsafe@2.0.5: {}
underscore@1.13.7: {} underscore@1.13.7: {}
undici-types@5.26.5: {} undici-types@5.26.5: {}
...@@ -20651,7 +20558,7 @@ snapshots: ...@@ -20651,7 +20558,7 @@ snapshots:
vite-node@1.6.1(@types/node@20.17.24)(sass@1.85.1)(terser@5.39.0): vite-node@1.6.1(@types/node@20.17.24)(sass@1.85.1)(terser@5.39.0):
dependencies: dependencies:
cac: 6.7.14 cac: 6.7.14
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
pathe: 1.1.2 pathe: 1.1.2
picocolors: 1.1.1 picocolors: 1.1.1
vite: 5.4.14(@types/node@20.17.24)(sass@1.85.1)(terser@5.39.0) vite: 5.4.14(@types/node@20.17.24)(sass@1.85.1)(terser@5.39.0)
...@@ -20669,7 +20576,7 @@ snapshots: ...@@ -20669,7 +20576,7 @@ snapshots:
vite-node@3.1.1(@types/node@20.17.24)(sass@1.85.1)(terser@5.39.0): vite-node@3.1.1(@types/node@20.17.24)(sass@1.85.1)(terser@5.39.0):
dependencies: dependencies:
cac: 6.7.14 cac: 6.7.14
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
es-module-lexer: 1.6.0 es-module-lexer: 1.6.0
pathe: 2.0.3 pathe: 2.0.3
vite: 6.2.2(@types/node@20.17.24)(sass@1.85.1)(terser@5.39.0) vite: 6.2.2(@types/node@20.17.24)(sass@1.85.1)(terser@5.39.0)
...@@ -20718,7 +20625,7 @@ snapshots: ...@@ -20718,7 +20625,7 @@ snapshots:
'@vitest/utils': 1.6.1 '@vitest/utils': 1.6.1
acorn-walk: 8.3.4 acorn-walk: 8.3.4
chai: 4.5.0 chai: 4.5.0
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
execa: 8.0.1 execa: 8.0.1
local-pkg: 0.5.1 local-pkg: 0.5.1
magic-string: 0.30.17 magic-string: 0.30.17
...@@ -20753,7 +20660,7 @@ snapshots: ...@@ -20753,7 +20660,7 @@ snapshots:
'@vitest/spy': 3.1.1 '@vitest/spy': 3.1.1
'@vitest/utils': 3.1.1 '@vitest/utils': 3.1.1
chai: 5.2.0 chai: 5.2.0
debug: 4.4.0(supports-color@5.5.0) debug: 4.4.0
expect-type: 1.2.0 expect-type: 1.2.0
magic-string: 0.30.17 magic-string: 0.30.17
pathe: 2.0.3 pathe: 2.0.3
......
...@@ -6,6 +6,7 @@ RUN npm install -g pnpm@9.4.0 ...@@ -6,6 +6,7 @@ RUN npm install -g pnpm@9.4.0
# 复制package.json # 复制package.json
COPY pnpm-lock.yaml pnpm-workspace.yaml ./ COPY pnpm-lock.yaml pnpm-workspace.yaml ./
COPY packages/global ./packages/global
COPY projects/mcp_server/package.json ./projects/mcp_server/package.json COPY projects/mcp_server/package.json ./projects/mcp_server/package.json
RUN apk add --no-cache\ RUN apk add --no-cache\
...@@ -14,18 +15,30 @@ RUN apk add --no-cache\ ...@@ -14,18 +15,30 @@ RUN apk add --no-cache\
# 安装依赖 # 安装依赖
RUN [ -f pnpm-lock.yaml ] || (echo "Lockfile not found." && exit 1) RUN [ -f pnpm-lock.yaml ] || (echo "Lockfile not found." && exit 1)
RUN pnpm i # if proxy exists, set proxy
RUN if [ -z "$proxy" ]; then \
pnpm i; \
else \
pnpm i --registry=https://registry.npmmirror.com; \
fi
# --------- builder ----------- # --------- builder -----------
FROM node:20.14.0-alpine AS builder FROM node:20.14.0-alpine AS builder
WORKDIR /app WORKDIR /app
COPY package.json pnpm-workspace.yaml /app/ COPY package.json pnpm-workspace.yaml .npmrc tsconfig.json ./
COPY ./projects/mcp_server /app/projects/mcp_server COPY ./projects/mcp_server /app/projects/mcp_server
COPY --from=install /app/packages /app/packages
COPY --from=install /app/node_modules /app/node_modules COPY --from=install /app/node_modules /app/node_modules
COPY --from=install /app/projects/mcp_server/node_modules /app/projects/mcp_server/node_modules COPY --from=install /app/projects/mcp_server/node_modules /app/projects/mcp_server/node_modules
RUN npm install -g pnpm@9.4.0 RUN [ -z "$proxy" ] || sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk add --no-cache libc6-compat curl bash && npm install -g pnpm@9.4.0
# Install curl and bash, then install bun
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:$PATH"
RUN pnpm --filter=mcp_server build RUN pnpm --filter=mcp_server build
# runner # runner
......
...@@ -8,23 +8,20 @@ ...@@ -8,23 +8,20 @@
], ],
"type": "module", "type": "module",
"scripts": { "scripts": {
"build": "tsc && shx chmod +x dist/*.js", "build": "bun build src/index.ts --outdir=dist --target=node && chmod +x dist/index.js",
"dev": "nodemon --watch src --ext ts,json --exec \"npm run dev:run\"", "dev": "bun --watch src/index.ts",
"dev:run": "tsc && node dist/index.js", "start": "bun src/index.ts",
"mcp_test": "npx @modelcontextprotocol/inspector" "mcp_test": "npx @modelcontextprotocol/inspector"
}, },
"dependencies": { "dependencies": {
"@fastgpt/global": "workspace:*",
"@modelcontextprotocol/sdk": "^1.12.1", "@modelcontextprotocol/sdk": "^1.12.1",
"axios": "^1.8.2",
"chalk": "^5.3.0", "chalk": "^5.3.0",
"dayjs": "^1.11.7", "dayjs": "^1.11.7",
"dotenv": "^16.5.0", "dotenv": "^16.5.0",
"express": "^4.21.2" "express": "^4.21.2"
}, },
"devDependencies": { "devDependencies": {
"@types/express": "^5.0.1", "@types/express": "^5.0.1"
"nodemon": "^3.1.9",
"shx": "^0.3.4",
"typescript": "^5.6.2"
} }
} }
import type { Tool } from '@modelcontextprotocol/sdk/types.js'; import type { Tool } from '@modelcontextprotocol/sdk/types.js';
import { GET, POST } from './request.js'; import { GET, POST } from './request';
export const getTools = (key: string) => GET<Tool[]>('/support/mcp/server/toolList', { key }); export const getTools = (key: string) => GET<Tool[]>('/support/mcp/server/toolList', { key });
......
import type { Method, InternalAxiosRequestConfig, AxiosResponse } from 'axios'; import { addLog } from '../utils/log';
import axios from 'axios';
type ConfigType = {
headers?: Record<string, string>;
timeout?: number;
};
type ConfigType = {};
type ResponseDataType = { type ResponseDataType = {
code: number; code: number;
message: string; message: string;
...@@ -9,22 +12,6 @@ type ResponseDataType = { ...@@ -9,22 +12,6 @@ type ResponseDataType = {
}; };
/** /**
* 请求开始
*/
function startInterceptors(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig {
if (config.headers) {
}
return config;
}
/**
* 请求成功,检查请求头
*/
function responseSuccess(response: AxiosResponse<ResponseDataType>) {
return response;
}
/**
* 响应数据检查 * 响应数据检查
*/ */
function checkRes(data: ResponseDataType) { function checkRes(data: ResponseDataType) {
...@@ -38,10 +25,10 @@ function checkRes(data: ResponseDataType) { ...@@ -38,10 +25,10 @@ function checkRes(data: ResponseDataType) {
} }
/** /**
* 响应错误 * 响应错误处理
*/ */
function responseError(err: any) { function responseError(err: any) {
console.log('error->', '请求错误', err); addLog.error(`Fetch request error`, err);
const data = err?.response?.data || err; const data = err?.response?.data || err;
if (!err) { if (!err) {
...@@ -51,62 +38,175 @@ function responseError(err: any) { ...@@ -51,62 +38,175 @@ function responseError(err: any) {
return Promise.reject({ message: err }); return Promise.reject({ message: err });
} }
if (typeof data === 'string') { if (typeof data === 'string') {
return Promise.reject(data); return Promise.reject({ message: data });
} }
// Handle fetch-specific errors
if (err.name === 'AbortError') {
return Promise.reject({ message: '请求超时' });
}
if (err.name === 'TypeError' && err.message.includes('fetch')) {
return Promise.reject({ message: '网络连接失败' });
}
return Promise.reject(data || err);
}
/**
* 构建查询参数
*/
function buildQueryString(params: Record<string, any>): string {
const searchParams = new URLSearchParams();
Object.keys(params).forEach((key) => {
const value = params[key];
if (value !== undefined && value !== null) {
if (Array.isArray(value)) {
value.forEach((item) => searchParams.append(key, String(item)));
} else {
searchParams.append(key, String(value));
}
}
});
return searchParams.toString();
} }
/* 创建请求实例 */ /**
const instance = axios.create({ * 发送请求
baseURL: `${process.env.FASTGPT_ENDPOINT}/api`, */
timeout: 600000, // 超时时间 async function request(url: string, data: any, config: ConfigType, method: string): Promise<any> {
headers: { // Remove undefined values
'content-type': 'application/json' const cleanData = { ...data };
for (const key in cleanData) {
if (cleanData[key] === undefined) {
delete cleanData[key];
}
} }
});
const baseURL = `${process.env.FASTGPT_ENDPOINT}/api`;
/* 请求拦截 */ let fullUrl = `${baseURL}${url}`;
instance.interceptors.request.use(startInterceptors, (err) => Promise.reject(err));
/* 响应拦截 */ // Default timeout from config or 600 seconds
instance.interceptors.response.use(responseSuccess, (err) => Promise.reject(err)); const timeout = config.timeout || 600000;
function request(url: string, data: any, config: ConfigType, method: Method): any { const options: RequestInit = {
/* 去空 */ method,
for (const key in data) { headers: {
if (data[key] === undefined) { 'content-type': 'application/json',
delete data[key]; ...config.headers
},
signal: AbortSignal.timeout(timeout)
};
// Handle request body and query parameters
if (['POST', 'PUT', 'PATCH'].includes(method)) {
if (Object.keys(cleanData).length > 0) {
options.body = JSON.stringify(cleanData);
}
} else if (Object.keys(cleanData).length > 0) {
const queryString = buildQueryString(cleanData);
if (queryString) {
fullUrl += `?${queryString}`;
} }
} }
return instance try {
.request({ const response = await fetch(fullUrl, options);
url,
method, // Handle non-2xx responses
data: ['POST', 'PUT'].includes(method) ? data : undefined, if (!response.ok) {
params: !['POST', 'PUT'].includes(method) ? data : undefined let errorData;
}) try {
.then((res) => checkRes(res.data)) errorData = await response.json();
.catch((err) => responseError(err)); } catch {
errorData = {
code: response.status,
message: response.statusText || `HTTP ${response.status}`,
data: null
};
}
throw errorData;
}
// Parse response
let result;
const contentType = response.headers.get('content-type');
if (contentType && contentType.includes('application/json')) {
result = await response.json();
} else {
// Handle non-JSON responses
const text = await response.text();
try {
result = JSON.parse(text);
} catch {
// If it's not JSON, wrap it in the expected format
result = {
code: response.status,
message: 'success',
data: text
};
}
}
return checkRes(result);
} catch (err) {
return responseError(err);
}
} }
/** /**
* api请求方式 * GET 请求
* @param {String} url * @param {String} url - 请求路径
* @param {Any} params * @param {Object} params - 查询参数
* @param {Object} config * @param {Object} config - 请求配置
* @returns * @returns {Promise<T>}
*/ */
export function GET<T = undefined>(url: string, params = {}, config: ConfigType = {}): Promise<T> { export function GET<T = undefined>(url: string, params = {}, config: ConfigType = {}): Promise<T> {
return request(url, params, config, 'GET'); return request(url, params, config, 'GET');
} }
/**
* POST 请求
* @param {String} url - 请求路径
* @param {Object} data - 请求体数据
* @param {Object} config - 请求配置
* @returns {Promise<T>}
*/
export function POST<T = undefined>(url: string, data = {}, config: ConfigType = {}): Promise<T> { export function POST<T = undefined>(url: string, data = {}, config: ConfigType = {}): Promise<T> {
return request(url, data, config, 'POST'); return request(url, data, config, 'POST');
} }
/**
* PUT 请求
* @param {String} url - 请求路径
* @param {Object} data - 请求体数据
* @param {Object} config - 请求配置
* @returns {Promise<T>}
*/
export function PUT<T = undefined>(url: string, data = {}, config: ConfigType = {}): Promise<T> { export function PUT<T = undefined>(url: string, data = {}, config: ConfigType = {}): Promise<T> {
return request(url, data, config, 'PUT'); return request(url, data, config, 'PUT');
} }
/**
* DELETE 请求
* @param {String} url - 请求路径
* @param {Object} data - 请求体数据
* @param {Object} config - 请求配置
* @returns {Promise<T>}
*/
export function DELETE<T = undefined>(url: string, data = {}, config: ConfigType = {}): Promise<T> { export function DELETE<T = undefined>(url: string, data = {}, config: ConfigType = {}): Promise<T> {
return request(url, data, config, 'DELETE'); return request(url, data, config, 'DELETE');
} }
/**
* PATCH 请求
* @param {String} url - 请求路径
* @param {Object} data - 请求体数据
* @param {Object} config - 请求配置
* @returns {Promise<T>}
*/
export function PATCH<T = undefined>(url: string, data = {}, config: ConfigType = {}): Promise<T> {
return request(url, data, config, 'PATCH');
}
#!/usr/bin/env node #!/usr/bin/env node
import './init.js'; import './init';
import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js'; import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js'; import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js'; import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
import express from 'express'; import express from 'express';
import { callTool, getTools } from './api/fastgpt.js'; import { callTool, getTools } from './api/fastgpt';
import { addLog } from './utils/log.js'; import { addLog } from './utils/log';
import { getErrText } from './utils/error.js'; import { getErrText } from '@fastgpt/global/common/error/utils';
const app = express(); const app = express();
......
import { replaceSensitiveText } from './string.js';
export const getErrText = (err: any, def = ''): any => {
const msg: string =
typeof err === 'string'
? err
: err?.response?.data?.message || err?.response?.message || err?.message || def;
// msg && console.log('error =>', msg);
return replaceSensitiveText(msg);
};
export const replaceSensitiveText = (text: string) => {
// 1. http link
text = text.replace(/(?<=https?:\/\/)[^\s]+/g, 'xxx');
// 2. nx-xxx 全部替换成xxx
text = text.replace(/ns-[\w-]+/g, 'xxx');
return text;
};
{ {
"include": ["src"], "extends": "../../tsconfig.json",
"exclude": ["node_modules"],
"compilerOptions": { "compilerOptions": {
"target": "ES2022", "target": "ES2022",
"module": "esnext", "module": "ESNext",
"moduleResolution": "node", "moduleResolution": "node",
"strict": true, "strict": true,
"esModuleInterop": true, "esModuleInterop": true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment