🔄 fix: Improve MCP Connection Cleanup (#7400)

* chore: linting for mcp related modules

* fix: update `isConnected` method to return a Promise and handle connection state asynchronously to properly handle/cleanup disconnected user connections
This commit is contained in:
Danny Avila 2025-05-15 12:17:17 -04:00 committed by GitHub
parent 535e7798b3
commit fe311df969
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 12 deletions

View file

@ -85,7 +85,10 @@ export const SSEOptionsSchema = BaseOptionsSchema.extend({
export const StreamableHTTPOptionsSchema = BaseOptionsSchema.extend({
type: z.literal('streamable-http'),
headers: z.record(z.string(), z.string()).optional(),
url: z.string().url().refine(
url: z
.string()
.url()
.refine(
(val) => {
const protocol = new URL(val).protocol;
return protocol !== 'ws:' && protocol !== 'wss:';
@ -93,7 +96,7 @@ export const StreamableHTTPOptionsSchema = BaseOptionsSchema.extend({
{
message: 'Streamable HTTP URL must not start with ws:// or wss://',
},
),
),
});
export const MCPOptionsSchema = z.union([