@context-engine-bridge/context-engine-mcp-bridge 0.0.20 → 0.0.21
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.
- package/package.json +1 -1
- package/src/mcpServer.js +27 -2
package/package.json
CHANGED
package/src/mcpServer.js
CHANGED
|
@@ -639,9 +639,34 @@ async function createBridgeServer(options) {
|
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
641
|
|
|
642
|
+
// Build requestInit with Authorization header for nginx auth_request passthrough.
|
|
643
|
+
// When the bridge connects to a remote endpoint (e.g. https://dev.example.com/indexer/mcp),
|
|
644
|
+
// nginx's auth_request subrequest checks the Authorization header. Without it, the
|
|
645
|
+
// connection is rejected with 401.
|
|
646
|
+
const transportOpts = {};
|
|
647
|
+
if (sessionId && !sessionId.startsWith("ctxce-")) {
|
|
648
|
+
transportOpts.requestInit = {
|
|
649
|
+
headers: {
|
|
650
|
+
Authorization: `Bearer ${sessionId}`,
|
|
651
|
+
},
|
|
652
|
+
};
|
|
653
|
+
debugLog(`[ctxce] Transport auth: injecting Authorization header (session ${sessionId.slice(0, 8)}...)`);
|
|
654
|
+
} else {
|
|
655
|
+
// Check for API key in environment as fallback
|
|
656
|
+
const envApiKey = (process.env.CTXCE_API_KEY || process.env.CTXCE_AUTH_TOKEN || "").trim();
|
|
657
|
+
if (envApiKey) {
|
|
658
|
+
transportOpts.requestInit = {
|
|
659
|
+
headers: {
|
|
660
|
+
Authorization: `Bearer ${envApiKey}`,
|
|
661
|
+
},
|
|
662
|
+
};
|
|
663
|
+
debugLog("[ctxce] Transport auth: injecting Authorization header (env API key/token)");
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
642
667
|
let nextIndexerClient = null;
|
|
643
668
|
try {
|
|
644
|
-
const indexerTransport = new StreamableHTTPClientTransport(indexerUrl);
|
|
669
|
+
const indexerTransport = new StreamableHTTPClientTransport(indexerUrl, transportOpts);
|
|
645
670
|
const client = new Client(
|
|
646
671
|
{
|
|
647
672
|
name: "ctx-context-engine-bridge-http-client",
|
|
@@ -665,7 +690,7 @@ async function createBridgeServer(options) {
|
|
|
665
690
|
let nextMemoryClient = null;
|
|
666
691
|
if (memoryUrl) {
|
|
667
692
|
try {
|
|
668
|
-
const memoryTransport = new StreamableHTTPClientTransport(memoryUrl);
|
|
693
|
+
const memoryTransport = new StreamableHTTPClientTransport(memoryUrl, transportOpts);
|
|
669
694
|
const client = new Client(
|
|
670
695
|
{
|
|
671
696
|
name: "ctx-context-engine-bridge-memory-client",
|