create-evda 0.1.9 → 0.1.10

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/lib/mcp-http.mjs CHANGED
@@ -54,6 +54,23 @@ function limiter() {
54
54
  };
55
55
  }
56
56
 
57
+ // HQ-2330: what a request carries beyond the protocol, by NAME only, so the log can show whether an
58
+ // app sends something that names the conversation (claude.ai reuses one Mcp-Session-Id across chats).
59
+ // Values are never logged: a header or a _meta value can carry anything.
60
+ const PLAIN_HEADERS = new Set(["host", "content-type", "content-length", "authorization", "accept", "accept-encoding", "accept-language", "user-agent", "connection", "origin", "mcp-session-id", "mcp-protocol-version", "last-event-id", "via", "forwarded", "x-real-ip", "cache-control", "pragma", "te", "keep-alive"]);
61
+ const clipName = (k) => String(k).replace(/[^\x21-\x7e]/g, "").slice(0, 64);
62
+ export function extraNames(headers, params) {
63
+ const out = {};
64
+ const h = Object.keys(headers ?? {}).map((k) => k.toLowerCase()).filter((k) => !PLAIN_HEADERS.has(k) && !k.startsWith("x-forwarded-") && !k.startsWith("tailscale-") && !k.startsWith("sec-fetch-")).map(clipName).slice(0, 20);
65
+ if (h.length) out.header_names = h;
66
+ const meta = params?._meta;
67
+ if (meta && typeof meta === "object" && !Array.isArray(meta)) {
68
+ const m = Object.keys(meta).map(clipName).slice(0, 20);
69
+ if (m.length) out.meta_keys = m;
70
+ }
71
+ return out;
72
+ }
73
+
57
74
  const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
58
75
  const shortId = (s) => auth.sha256(String(s)).slice(0, 8);
59
76
 
@@ -167,7 +184,7 @@ export function createMcpHttpServer({ dir, version, publicUrl, env = process.env
167
184
  if (batch.length !== 1) return send(400, { jsonrpc: "2.0", id: null, error: { code: -32600, message: "initialize must be sent alone" } });
168
185
  evictSessions(now);
169
186
  newSid = randomBytes(24).toString("hex");
170
- session = { family: grant.family, last: now, ctx: { version, log: (s) => log(s), clock, env: readerEnv, evda: () => openEvda(dir), session: newSession(), caller: callerFrom({ env: readerEnv }) } };
187
+ session = { family: grant.family, last: now, ctx: { version, log: (s) => log(s), clock, env: readerEnv, evda: () => openEvda(dir), session: newSession(), caller: callerFrom({ env: readerEnv }), keepsToolList: true } };
171
188
  sessions.set(newSid, session);
172
189
  } else {
173
190
  if (!sid) return send(400, { jsonrpc: "2.0", id: null, error: { code: -32600, message: "Mcp-Session-Id header required; initialize first" } });
@@ -188,6 +205,7 @@ export function createMcpHttpServer({ dir, version, publicUrl, env = process.env
188
205
  const line = { call: method === "tools/call" ? (TOOL_NAMES.has(tool) ? tool : "unknown_tool") : METHODS.has(method) ? method : "unknown_method", status: st, ms: clock() - t0, session: shortId(sid ?? newSid), conn: note.who };
189
206
  // Which app connected (HQ-2207): initialize's clientInfo name and version, nothing else of it.
190
207
  if (method === "initialize") { const ci = clientInfoOf(one.params); line.client_name = ci.name; line.client_version = ci.version; }
208
+ Object.assign(line, extraNames(req.headers, one.params));
191
209
  if (auth.FALSIFY("log-content", env)) line.args = one.params?.arguments;
192
210
  record(line);
193
211
  }