mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 15:17:30 +00:00
20 lines
687 B
TypeScript
20 lines
687 B
TypeScript
import type { RequestHandler } from 'express';
|
|
import { AddonsService } from './addons.service';
|
|
import { ADDON_IDS } from '../../addons';
|
|
|
|
/**
|
|
* Gate: 404 (empty body) when the MCP addon is disabled (M2 — prevents feature
|
|
* fingerprinting). A factory over the injected AddonsService rather than a
|
|
* middleware class: consumers build it inside their module's configure() and
|
|
* hand the bare RequestHandler to consumer.apply() ahead of the SDK routers.
|
|
*/
|
|
export function createMcpAddonGate(addons: AddonsService): RequestHandler {
|
|
return (_req, res, next) => {
|
|
if (!addons.isAddonEnabled(ADDON_IDS.MCP)) {
|
|
res.status(404).end();
|
|
return;
|
|
}
|
|
next();
|
|
};
|
|
}
|