Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
8e248d7b
authored
Apr 01, 2026
by
Archer
Committed by
GitHub
Apr 01, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mcp perf (#6697)
* mcp perf * fix: null object
parent
e382a74e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
packages/service/core/app/mcp.ts
+16
-11
No files found.
packages/service/core/app/mcp.ts
View file @
8e248d7b
...
...
@@ -39,18 +39,14 @@ export class MCPClient {
throw
error
;
});
this
.
client
.
onerror
=
(
error
)
=>
{
logger
.
error
(
'MCP client connection error'
,
{
url
:
this
.
url
,
error
});
this
.
connectionPromise
=
null
;
};
this
.
client
.
onclose
=
()
=>
{
this
.
connectionPromise
=
null
;
};
return
this
.
connectionPromise
;
}
private
async
doConnect
():
Promise
<
Client
>
{
// 避免连接重复,强制关闭一次
await
this
.
client
.
close
().
catch
(()
=>
{});
logger
.
debug
(
'Start connect mcp client'
,
{
url
:
this
.
url
});
try
{
const
transport
=
new
StreamableHTTPClientTransport
(
new
URL
(
this
.
url
),
{
requestInit
:
{
...
...
@@ -58,9 +54,7 @@ export class MCPClient {
}
});
await
this
.
client
.
connect
(
transport
);
return
this
.
client
;
}
catch
(
error
)
{
await
this
.
client
.
close
().
catch
(()
=>
{});
await
this
.
client
.
connect
(
new
SSEClientTransport
(
new
URL
(
this
.
url
),
{
requestInit
:
{
...
...
@@ -90,8 +84,19 @@ export class MCPClient {
}
})
);
return
this
.
client
;
}
this
.
client
.
onerror
=
(
error
)
=>
{
// 忽略掉不支持 streamable 的错误
if
(
error
?.
message
?.
includes
(
'SSE stream: Not Found'
))
return
;
logger
.
warn
(
'MCP client connection error'
,
{
url
:
this
.
url
,
error
});
this
.
connectionPromise
=
null
;
};
this
.
client
.
onclose
=
()
=>
{
this
.
connectionPromise
=
null
;
};
return
this
.
client
;
}
// 内部方法:关闭连接
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment