@inso_web/els-mcp
Version:
MCP-сервер поверх INSO Error Logs Service. Read-only tools (search, analytics, fingerprinting, correlations) для подключения Claude Desktop/Code и ChatGPT к логам ошибок. Streamable HTTP transport + stdio для npx-запуска.
43 lines • 1.55 kB
JavaScript
import { Router } from 'express';
export function createWellKnownRouter(opts) {
const router = Router();
router.get('/oauth-protected-resource', protectedResource(opts.config));
router.get('/mcp', mcpDiscovery(opts.config, opts.toolNames));
return router;
}
function protectedResource(config) {
// Trailing slash для `resource` — стандартное представление "tenant boundary"
// в RFC 9728. Должно совпадать с тем, что отдаётся в WWW-Authenticate.
const resource = `${config.publicUrl}/`;
const body = {
resource,
authorization_servers: [config.oidcIssuer],
scopes_supported: ['errors:mcp-read'],
bearer_methods_supported: ['header'],
};
return function handler(_req, res) {
res.setHeader('Cache-Control', 'public, max-age=300');
res.status(200).json(body);
};
}
function mcpDiscovery(config, toolNames) {
const body = {
protocolVersion: '2025-03-26',
transports: ['streamable-http'],
tools: toolNames,
auth: {
type: 'oauth2',
authorizationServer: config.oidcIssuer,
resource: `${config.publicUrl}/`,
},
endpoints: {
mcp: `${config.publicUrl}/mcp`,
},
documentation: `${config.publicUrl}/docs`,
};
return function handler(_req, res) {
res.setHeader('Cache-Control', 'public, max-age=300');
res.status(200).json(body);
};
}
//# sourceMappingURL=wellKnown.js.map