Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions plugin/controller/lib/impl/mcp/MCPControllerRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ export class MCPControllerRegister implements ControllerRegister {
ctx.respond = false;
ctx.set({
'content-type': 'text/event-stream',
'transfer-encoding': 'chunked',
});
await ctx.app.ctxStorage.run(ctx, async () => {
await mw(ctx, async () => {
Expand Down Expand Up @@ -352,7 +351,6 @@ export class MCPControllerRegister implements ControllerRegister {

ctx.set({
'content-type': 'text/event-stream',
'transfer-encoding': 'chunked',
});

await mcpServerHelper.server.connect(transport);
Expand Down Expand Up @@ -402,7 +400,6 @@ export class MCPControllerRegister implements ControllerRegister {
ctx.respond = false;
ctx.set({
'content-type': 'text/event-stream',
'transfer-encoding': 'chunked',
});

await ctx.app.ctxStorage.run(ctx, async () => {
Expand Down Expand Up @@ -471,7 +468,6 @@ export class MCPControllerRegister implements ControllerRegister {
self.transports[id] = transport;
ctx.set({
'content-type': 'text/event-stream',
'transfer-encoding': 'chunked',
});
ctx.respond = false;
const mcpServerHelper = self.mcpServerHelperMap[name ?? 'default']();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const GetAlipayTeggHook = (app: Application) => {
ctx.set({
'content-type': 'text/event-stream',
'cache-control': 'no-cache',
'transfer-encoding': 'chunked',
});
try {
const auth = ctx.get('authorization');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ export default class App extends Controller {
this.ctx.set({
'content-type': 'text/event-stream',
'cache-control': 'no-cache',
'transfer-encoding': 'chunked',
});
const self = this;
const transport = new SSEServerTransport('/message', this.ctx.res);
Expand Down Expand Up @@ -255,7 +254,6 @@ export default class App extends Controller {
this.ctx.set({
'content-type': 'text/event-stream',
'cache-control': 'no-cache',
'transfer-encoding': 'chunked',
});
const eventStore = new InMemoryEventStore();
const self = this;
Expand Down Expand Up @@ -305,7 +303,6 @@ export default class App extends Controller {
this.ctx.set({
'content-type': 'text/event-stream',
'cache-control': 'no-cache',
'transfer-encoding': 'chunked',
});
const transport = transports[sessionId] as StreamableHTTPServerTransport;
await transport.handleRequest(this.ctx.req, this.ctx.res);
Expand Down
13 changes: 12 additions & 1 deletion plugin/mcp-proxy/test/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { CallToolRequest, CallToolResultSchema, ListToolsRequest, ListToolsResultSchema, LoggingMessageNotificationSchema } from '@modelcontextprotocol/sdk/types.js';
import assert from 'assert';
import { fetch } from 'urllib';

async function listTools(client: Client) {
const toolsRequest: ListToolsRequest = {
Expand Down Expand Up @@ -133,7 +134,17 @@ describe('plugin/mcp-proxy/test/proxy.test.ts', () => {
});
const baseUrl = await app.httpRequest()
.post('/stream').url;
const streamableTransport = new StreamableHTTPClientTransport(new URL(baseUrl));
const streamableTransport = new StreamableHTTPClientTransport(new URL(baseUrl), {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
fetch: async (...args) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const res = await fetch(...args);
assert.deepEqual(res.headers.has('content-length'), !res.headers.has('transfer-encoding'));
return res;
},
});
const streamableNotifications: { level: string, data: string }[] = [];
streamableClient.setNotificationHandler(LoggingMessageNotificationSchema, notification => {
streamableNotifications.push({ level: notification.params.level, data: notification.params.data as string });
Expand Down
Loading