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
ded69214
authored
Aug 04, 2026
by
Finley Ge
Committed by
GitHub
Aug 04, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(mcp): avoid duplicating headers in SSE fallback (#7447)
parent
98f1479d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
+19
-15
packages/service/core/app/mcp.ts
+1
-15
packages/service/test/core/app/mcp.test.ts
+18
-0
No files found.
packages/service/core/app/mcp.ts
View file @
ded69214
...
@@ -265,24 +265,10 @@ export class MCPClient {
...
@@ -265,24 +265,10 @@ export class MCPClient {
try
{
try
{
await
this
.
client
.
connect
(
await
this
.
client
.
connect
(
new
SSEClientTransport
(
new
URL
(
this
.
url
),
{
new
SSEClientTransport
(
new
URL
(
this
.
url
),
{
fetch
:
safeFetch
,
fetch
:
safeFetch
,
requestInit
:
{
requestInit
:
{
headers
:
this
.
headers
headers
:
this
.
headers
},
eventSourceInit
:
{
fetch
:
(
url
,
init
)
=>
{
const
mergedHeaders
=
{
...
this
.
headers
};
Object
.
assign
(
mergedHeaders
,
headersInitToRecord
(
init
?.
headers
));
return
safeFetch
(
url
,
{
...
init
,
headers
:
mergedHeaders
});
}
}
}
})
})
);
);
...
...
packages/service/test/core/app/mcp.test.ts
View file @
ded69214
...
@@ -495,6 +495,24 @@ describe('MCPClient', () => {
...
@@ -495,6 +495,24 @@ describe('MCPClient', () => {
expect
(
result
).
toBe
(
client
);
expect
(
result
).
toBe
(
client
);
});
});
it
(
'should pass custom headers once to the SSE fallback transport'
,
async
()
=>
{
const
mcpClient
=
new
MCPClient
(
config
);
const
client
=
getPrivateClient
(
mcpClient
);
client
.
connect
=
vi
.
fn
()
.
mockRejectedValueOnce
(
new
StreamableHTTPError
(
405
,
'Method Not Allowed'
))
.
mockResolvedValueOnce
(
undefined
);
await
(
mcpClient
as
any
).
getConnection
();
const
sseTransport
=
client
.
connect
.
mock
.
calls
[
1
][
0
]
as
{
_requestInit
?:
RequestInit
;
_eventSourceInit
?:
EventSourceInit
;
};
expect
(
sseTransport
.
_requestInit
?.
headers
).
toEqual
(
config
.
headers
);
expect
(
sseTransport
.
_eventSourceInit
).
toBeUndefined
();
});
it
(
'should not fallback to SSE on a non-HTTP (e.g. network) error'
,
async
()
=>
{
it
(
'should not fallback to SSE on a non-HTTP (e.g. network) error'
,
async
()
=>
{
const
mcpClient
=
new
MCPClient
(
config
);
const
mcpClient
=
new
MCPClient
(
config
);
const
client
=
getPrivateClient
(
mcpClient
);
const
client
=
getPrivateClient
(
mcpClient
);
...
...
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