π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
fix(mcp): serve the streamable endpoints in Mastra's dual-era mode
Gilad Resisi5ead635170e8
diff --git a/libraries/nestjs-libraries/src/chat/start.mcp.ts b/libraries/nestjs-libraries/src/chat/start.mcp.tsindex b96c75d8a..25dff80be 100644--- a/libraries/nestjs-libraries/src/chat/start.mcp.ts+++ b/libraries/nestjs-libraries/src/chat/start.mcp.ts@@ -25,6 +25,18 @@ const fixAcceptHeader = (req: Request) => {}};+// 2026-07-28 clients hold a subscriptions/listen stream open for the whole+// session, and the tool list never changes - the stream ends once the+// subscription had time to be acknowledged+const endListenStream = (req: Request, res: Response) => {+ if (req.headers['mcp-method'] !== 'subscriptions/listen') {+ return;+ }++ const timer = setTimeout(() => res.end(), 10000);+ res.on('close', () => clearTimeout(timer));+};+const openAiOAuthClientId = process.env.OPENAI_OAUTH_CLIENT_ID?.trim();const enableOidcEmailClaims = Boolean(openAiOAuthClientId);const oauthScopes = [@@ -133,7 +145,7 @@ export const startMcp = async (app: INestApplication) => {appResources,};- const server = new MCPServer(serverConfig);+ const server = new MCPServer({ ...serverConfig, protocolVersion: '2026-07-28' });// The directory-facing servers don't register the agent - it would be// exposed as an annotation-less catch-all ask_postiz tool, which the@@ -141,6 +153,7 @@ export const startMcp = async (app: INestApplication) => {const oauthServer = new MCPServer({name: 'Postiz MCP',version: '1.0.0',+ protocolVersion: '2026-07-28',tools,appResources,});@@ -151,6 +164,7 @@ export const startMcp = async (app: INestApplication) => {const claudeOauthServer = new MCPServer({name: 'Postiz MCP',version: '1.0.0',+ protocolVersion: '2026-07-28',tools: claudeTools,appResources: claudeAppResources,});@@ -164,11 +178,13 @@ export const startMcp = async (app: INestApplication) => {selfHostedServer = new MCPServer({name: 'Postiz MCP',version: '1.0.0',+ protocolVersion: '2026-07-28',tools: selfHostedTools,});claudeSelfHostedServer = new MCPServer({name: 'Postiz MCP',version: '1.0.0',+ protocolVersion: '2026-07-28',tools: withoutClaudeHidden(selfHostedTools),});}@@ -340,6 +356,7 @@ export const startMcp = async (app: INestApplication) => {return;}+ endListenStream(req, res);fixAcceptHeader(req);await runWithContext({ requestId: token!, auth, relay: relay || undefined }, async () => {await (relay ? selfHostedServer! : mcpServer).startHTTP({@@ -347,7 +364,6 @@ export const startMcp = async (app: INestApplication) => {httpPath: url.pathname,options: {serverless: true,- enableJsonResponse: true,},req,res,@@ -389,6 +405,7 @@ export const startMcp = async (app: INestApplication) => {const url = new URL('/mcp', process.env.NEXT_PUBLIC_BACKEND_URL);+ endListenStream(req, res);fixAcceptHeader(req);// @ts-ignoreawait runWithContext({ requestId: token, auth: req.auth }, async () => {@@ -397,7 +414,6 @@ export const startMcp = async (app: INestApplication) => {httpPath: url.pathname,options: {serverless: true,- enableJsonResponse: true,},req,res,@@ -430,6 +446,7 @@ export const startMcp = async (app: INestApplication) => {process.env.NEXT_PUBLIC_BACKEND_URL);+ endListenStream(req, res);fixAcceptHeader(req);await runWithContext(// @ts-ignore@@ -440,7 +457,6 @@ export const startMcp = async (app: INestApplication) => {httpPath: url.pathname,options: {serverless: true,- enableJsonResponse: true,},req,res,