yt-transcript-strapi-plugin 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -855,21 +855,11 @@ const bootstrap = async ({ strapi }) => {
855
855
  plugin.sessions = /* @__PURE__ */ new Map();
856
856
  const oauthPlugin = strapi.plugin(OAUTH_PLUGIN_ID);
857
857
  if (oauthPlugin) {
858
- try {
859
- await oauthPlugin.service("endpoint").register({
860
- name: "YouTube Transcript MCP",
861
- pluginId: PLUGIN_ID,
862
- path: `/api/${PLUGIN_ID}/mcp`,
863
- description: "MCP endpoint for YouTube transcript tools"
864
- });
865
- strapi.log.info(`[${PLUGIN_ID}] Registered with OAuth plugin - supports OAuth + API tokens`);
866
- } catch (error) {
867
- strapi.log.error(`[${PLUGIN_ID}] Failed to register with OAuth plugin`, { error });
868
- }
858
+ strapi.log.info(`[${PLUGIN_ID}] OAuth manager detected - OAuth + API token auth enabled`);
869
859
  } else {
870
860
  const fallbackMiddleware = createFallbackAuthMiddleware();
871
861
  strapi.server.use(fallbackMiddleware);
872
- strapi.log.info(`[${PLUGIN_ID}] Using API token authentication (OAuth plugin not installed)`);
862
+ strapi.log.info(`[${PLUGIN_ID}] Using API token authentication (OAuth manager not installed)`);
873
863
  }
874
864
  strapi.log.info(`[${PLUGIN_ID}] MCP endpoint available at: /api/${PLUGIN_ID}/mcp`);
875
865
  };
@@ -1049,7 +1039,30 @@ const mcpController = ({ strapi }) => ({
1049
1039
  plugin.sessions.set(sessionId, session);
1050
1040
  strapi.log.debug(`[yt-transcript-mcp] New session created: ${sessionId} (auth: ${ctx.state.authMethod})`);
1051
1041
  }
1052
- await session.transport.handleRequest(ctx.req, ctx.res, ctx.request.body);
1042
+ try {
1043
+ await session.transport.handleRequest(ctx.req, ctx.res, ctx.request.body);
1044
+ } catch (transportError) {
1045
+ strapi.log.warn(`[yt-transcript-mcp] Transport error, cleaning up session: ${requestedSessionId}`, {
1046
+ error: transportError instanceof Error ? transportError.message : String(transportError)
1047
+ });
1048
+ try {
1049
+ session.server.close();
1050
+ } catch {
1051
+ }
1052
+ plugin.sessions.delete(requestedSessionId);
1053
+ if (!ctx.res.headersSent) {
1054
+ ctx.status = 400;
1055
+ ctx.body = {
1056
+ jsonrpc: "2.0",
1057
+ error: {
1058
+ code: -32e3,
1059
+ message: "Session transport error. Please reinitialize the connection."
1060
+ },
1061
+ id: null
1062
+ };
1063
+ }
1064
+ return;
1065
+ }
1053
1066
  ctx.respond = false;
1054
1067
  } catch (error) {
1055
1068
  strapi.log.error("[yt-transcript-mcp] Error handling MCP request", {
@@ -854,21 +854,11 @@ const bootstrap = async ({ strapi }) => {
854
854
  plugin.sessions = /* @__PURE__ */ new Map();
855
855
  const oauthPlugin = strapi.plugin(OAUTH_PLUGIN_ID);
856
856
  if (oauthPlugin) {
857
- try {
858
- await oauthPlugin.service("endpoint").register({
859
- name: "YouTube Transcript MCP",
860
- pluginId: PLUGIN_ID,
861
- path: `/api/${PLUGIN_ID}/mcp`,
862
- description: "MCP endpoint for YouTube transcript tools"
863
- });
864
- strapi.log.info(`[${PLUGIN_ID}] Registered with OAuth plugin - supports OAuth + API tokens`);
865
- } catch (error) {
866
- strapi.log.error(`[${PLUGIN_ID}] Failed to register with OAuth plugin`, { error });
867
- }
857
+ strapi.log.info(`[${PLUGIN_ID}] OAuth manager detected - OAuth + API token auth enabled`);
868
858
  } else {
869
859
  const fallbackMiddleware = createFallbackAuthMiddleware();
870
860
  strapi.server.use(fallbackMiddleware);
871
- strapi.log.info(`[${PLUGIN_ID}] Using API token authentication (OAuth plugin not installed)`);
861
+ strapi.log.info(`[${PLUGIN_ID}] Using API token authentication (OAuth manager not installed)`);
872
862
  }
873
863
  strapi.log.info(`[${PLUGIN_ID}] MCP endpoint available at: /api/${PLUGIN_ID}/mcp`);
874
864
  };
@@ -1048,7 +1038,30 @@ const mcpController = ({ strapi }) => ({
1048
1038
  plugin.sessions.set(sessionId, session);
1049
1039
  strapi.log.debug(`[yt-transcript-mcp] New session created: ${sessionId} (auth: ${ctx.state.authMethod})`);
1050
1040
  }
1051
- await session.transport.handleRequest(ctx.req, ctx.res, ctx.request.body);
1041
+ try {
1042
+ await session.transport.handleRequest(ctx.req, ctx.res, ctx.request.body);
1043
+ } catch (transportError) {
1044
+ strapi.log.warn(`[yt-transcript-mcp] Transport error, cleaning up session: ${requestedSessionId}`, {
1045
+ error: transportError instanceof Error ? transportError.message : String(transportError)
1046
+ });
1047
+ try {
1048
+ session.server.close();
1049
+ } catch {
1050
+ }
1051
+ plugin.sessions.delete(requestedSessionId);
1052
+ if (!ctx.res.headersSent) {
1053
+ ctx.status = 400;
1054
+ ctx.body = {
1055
+ jsonrpc: "2.0",
1056
+ error: {
1057
+ code: -32e3,
1058
+ message: "Session transport error. Please reinitialize the connection."
1059
+ },
1060
+ id: null
1061
+ };
1062
+ }
1063
+ return;
1064
+ }
1052
1065
  ctx.respond = false;
1053
1066
  } catch (error) {
1054
1067
  strapi.log.error("[yt-transcript-mcp] Error handling MCP request", {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.2",
2
+ "version": "0.1.4",
3
3
  "keywords": [
4
4
  "yt-transcript-strapi-plugin",
5
5
  "youtube",