@datadive-tools/mcp 0.18.0 → 0.19.0

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/dist/lib.d.ts CHANGED
@@ -56,6 +56,13 @@ interface Config {
56
56
  * MCP server, which takes it from its own load balancer; the stdio path leaves it unset.
57
57
  */
58
58
  forwardedFor?: string;
59
+ /**
60
+ * Extra headers the hosted (remote) MCP server sends on every DataDive API call, e.g. the
61
+ * proxy secret that proves to the API the call came through that server. They can never
62
+ * replace the credential, `accept`, `content-type` or `user-agent` headers this package sets.
63
+ * The stdio path leaves it unset.
64
+ */
65
+ extraHeaders?: Readonly<Record<string, string>>;
59
66
  }
60
67
  declare function loadConfig(env?: NodeJS.ProcessEnv): Config;
61
68
 
package/dist/lib.js CHANGED
@@ -139,7 +139,7 @@ function extractMessage(body) {
139
139
  }
140
140
 
141
141
  // package.json
142
- var version = "0.18.0";
142
+ var version = "0.19.0";
143
143
 
144
144
  // src/http/client.ts
145
145
  var PKG_VERSION = version;
@@ -179,7 +179,7 @@ async function httpGet(ctx, path, query) {
179
179
  method: "GET",
180
180
  headers: {
181
181
  ...authHeaders(ctx.config),
182
- ...forwardedForHeader(ctx.config),
182
+ ...hostHeaders(ctx.config),
183
183
  accept: "application/json",
184
184
  "user-agent": userAgent(ctx.toolName)
185
185
  }
@@ -197,7 +197,7 @@ async function httpPost(ctx, path, body) {
197
197
  method: "POST",
198
198
  headers: {
199
199
  ...authHeaders(ctx.config),
200
- ...forwardedForHeader(ctx.config),
200
+ ...hostHeaders(ctx.config),
201
201
  accept: "application/json",
202
202
  "content-type": "application/json",
203
203
  "user-agent": userAgent(ctx.toolName)
@@ -217,7 +217,7 @@ async function httpPatch(ctx, path, body) {
217
217
  method: "PATCH",
218
218
  headers: {
219
219
  ...authHeaders(ctx.config),
220
- ...forwardedForHeader(ctx.config),
220
+ ...hostHeaders(ctx.config),
221
221
  accept: "application/json",
222
222
  "content-type": "application/json",
223
223
  "user-agent": userAgent(ctx.toolName)
@@ -237,7 +237,7 @@ async function httpDelete(ctx, path) {
237
237
  method: "DELETE",
238
238
  headers: {
239
239
  ...authHeaders(ctx.config),
240
- ...forwardedForHeader(ctx.config),
240
+ ...hostHeaders(ctx.config),
241
241
  accept: "application/json",
242
242
  "user-agent": userAgent(ctx.toolName)
243
243
  }
@@ -283,8 +283,13 @@ function authHeaders(config) {
283
283
  const c = config.credentials;
284
284
  return c.kind === "bearer" ? { authorization: `Bearer ${c.token}` } : { "x-api-key": c.apiKey };
285
285
  }
286
- function forwardedForHeader(config) {
287
- return config.forwardedFor ? { "x-forwarded-for": config.forwardedFor } : {};
286
+ var RESERVED_HEADERS = /* @__PURE__ */ new Set(["authorization", "x-api-key", "accept", "content-type", "user-agent"]);
287
+ function hostHeaders(config) {
288
+ const extra = Object.entries(config.extraHeaders ?? {}).filter(([name]) => !RESERVED_HEADERS.has(name.toLowerCase()));
289
+ return {
290
+ ...Object.fromEntries(extra),
291
+ ...config.forwardedFor ? { "x-forwarded-for": config.forwardedFor } : {}
292
+ };
288
293
  }
289
294
  function unwrap(body) {
290
295
  if (!isObject(body)) return body;