@ateam-ai/mcp 0.3.31 → 0.3.32
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/http.js +16 -1
package/package.json
CHANGED
package/src/http.js
CHANGED
|
@@ -182,9 +182,24 @@ export function startHttpServer(port = 3100) {
|
|
|
182
182
|
const mcpAuthOptional = [autoInjectToken, optionalBearerAuth];
|
|
183
183
|
|
|
184
184
|
// ─── CORS — required for browser-based MCP clients ──────────────
|
|
185
|
+
// Origin allowlist (round 014 security hardening).
|
|
186
|
+
// ATEAM_CORS_ALLOWED_ORIGINS env = comma-separated list, or "*" / unset for
|
|
187
|
+
// wildcard (default — preserves compat with third-party MCP clients).
|
|
188
|
+
// When set, Origin must match exactly; otherwise no ACAO header is sent.
|
|
189
|
+
const CORS_ALLOWED_LIST = String(process.env.ATEAM_CORS_ALLOWED_ORIGINS || "*")
|
|
190
|
+
.split(",").map((s) => s.trim()).filter(Boolean);
|
|
191
|
+
const CORS_ALLOW_ANY = CORS_ALLOWED_LIST.includes("*");
|
|
192
|
+
function resolveOrigin(req) {
|
|
193
|
+
const o = req.headers?.origin;
|
|
194
|
+
if (CORS_ALLOW_ANY) return o || "*";
|
|
195
|
+
if (o && CORS_ALLOWED_LIST.includes(o)) return o;
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
185
198
|
for (const path of MCP_PATHS) {
|
|
186
199
|
app.use(path, (req, res, next) => {
|
|
187
|
-
|
|
200
|
+
const origin = resolveOrigin(req);
|
|
201
|
+
if (origin) res.setHeader("Access-Control-Allow-Origin", origin);
|
|
202
|
+
if (!CORS_ALLOW_ANY) res.setHeader("Vary", "Origin");
|
|
188
203
|
res.setHeader("Access-Control-Allow-Methods", "POST, GET, DELETE, OPTIONS");
|
|
189
204
|
res.setHeader("Access-Control-Allow-Headers", "content-type, mcp-session-id, authorization");
|
|
190
205
|
res.setHeader("Access-Control-Expose-Headers", "Mcp-Session-Id");
|