@jalpp/mcp-adapter 0.3.1 → 0.3.3

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +36 -10
  2. package/dist/index.js +19334 -120
  3. package/package.json +19 -8
package/dist/index.d.ts CHANGED
@@ -146,6 +146,20 @@ interface HttpToolAdapterWithSchema<T extends ZodRawShapeCompat> {
146
146
  inputSchema: T;
147
147
  /** Optional authentication strategy. */
148
148
  auth?: HttpAuth;
149
+ /**
150
+ * Optional name of the input parameter whose value will be used as a runtime
151
+ * bearer token (`Authorization: Bearer <value>`). The parameter is consumed and
152
+ * never forwarded as a query param or body field.
153
+ *
154
+ * When both `tokenParam` and a static `auth` are provided, the runtime token
155
+ * takes precedence.
156
+ *
157
+ * @example
158
+ * // Schema includes { token: z.string(), userId: z.string() }
159
+ * tokenParam: "token"
160
+ * // → Authorization: Bearer <value of args.token>
161
+ */
162
+ tokenParam?: string;
149
163
  /** Optional extra axios config (e.g. headers, timeout). */
150
164
  axiosConfig?: AxiosRequestConfig;
151
165
  }
@@ -167,6 +181,11 @@ interface HttpToolAdapterWithoutSchema {
167
181
  inputSchema?: undefined;
168
182
  /** Optional authentication strategy. */
169
183
  auth?: HttpAuth;
184
+ /**
185
+ * Not applicable when there is no input schema — included for type symmetry only.
186
+ * Use the schema variant if you need a runtime token param.
187
+ */
188
+ tokenParam?: never;
170
189
  /** Optional extra axios config (e.g. headers, timeout). */
171
190
  axiosConfig?: AxiosRequestConfig;
172
191
  }
@@ -217,6 +236,8 @@ type DeleteToolAdapterConfig<T extends ZodRawShapeCompat> = Omit<HttpToolAdapter
217
236
  * - Path variables (`:paramName`) are interpolated from input args.
218
237
  * - GET/DELETE: remaining args → query parameters.
219
238
  * - POST/PUT/PATCH: remaining args → JSON request body.
239
+ * - `tokenParam`: if set, the named input field is extracted and used as a runtime
240
+ * bearer token, overriding the static `auth` config.
220
241
  *
221
242
  * @template T - Zod raw shape inferred from `inputSchema`.
222
243
  * @param server - The `McpServer` instance to register the tool on.
@@ -239,10 +260,11 @@ declare function httpToolAdapter(server: McpServer, adapter: HttpToolAdapterWith
239
260
  * name: "get-user",
240
261
  * description: "Fetch a user by ID",
241
262
  * endpoint: "https://api.example.com/users/:userId",
242
- * inputSchema: { userId: z.string(), expand: z.string().optional() },
243
- * auth: { type: "bearer", token: process.env.API_TOKEN! },
263
+ * inputSchema: { userId: z.string(), token: z.string(), expand: z.string().optional() },
264
+ * tokenParam: "token",
244
265
  * });
245
266
  * // GET https://api.example.com/users/abc123?expand=profile
267
+ * // Authorization: Bearer <token>
246
268
  */
247
269
  declare function getToolAdapter<T extends ZodRawShapeCompat>(server: McpServer, config: GetToolAdapterConfig<T>): void;
248
270
  declare function getToolAdapter(server: McpServer, config: GetToolAdapterConfigNoSchema): void;
@@ -261,10 +283,11 @@ declare function getToolAdapter(server: McpServer, config: GetToolAdapterConfigN
261
283
  * name: "create-post",
262
284
  * description: "Create a new post for a user",
263
285
  * endpoint: "https://api.example.com/users/:userId/posts",
264
- * inputSchema: { userId: z.string(), title: z.string(), body: z.string() },
265
- * auth: { type: "bearer", token: process.env.API_TOKEN! },
286
+ * inputSchema: { userId: z.string(), token: z.string(), title: z.string(), body: z.string() },
287
+ * tokenParam: "token",
266
288
  * });
267
289
  * // POST https://api.example.com/users/abc123/posts { title, body }
290
+ * // Authorization: Bearer <token>
268
291
  */
269
292
  declare function postToolAdapter<T extends ZodRawShapeCompat>(server: McpServer, config: PostToolAdapterConfig<T>): void;
270
293
  declare function postToolAdapter(server: McpServer, config: PostToolAdapterConfigNoSchema): void;
@@ -283,10 +306,11 @@ declare function postToolAdapter(server: McpServer, config: PostToolAdapterConfi
283
306
  * name: "update-user",
284
307
  * description: "Replace a user record",
285
308
  * endpoint: "https://api.example.com/users/:userId",
286
- * inputSchema: { userId: z.string(), name: z.string(), email: z.string() },
287
- * auth: { type: "bearer", token: process.env.API_TOKEN! },
309
+ * inputSchema: { userId: z.string(), token: z.string(), name: z.string(), email: z.string() },
310
+ * tokenParam: "token",
288
311
  * });
289
312
  * // PUT https://api.example.com/users/abc123 { name, email }
313
+ * // Authorization: Bearer <token>
290
314
  */
291
315
  declare function putToolAdapter<T extends ZodRawShapeCompat>(server: McpServer, config: PutToolAdapterConfig<T>): void;
292
316
  /**
@@ -304,10 +328,11 @@ declare function putToolAdapter<T extends ZodRawShapeCompat>(server: McpServer,
304
328
  * name: "update-post-title",
305
329
  * description: "Partially update a post",
306
330
  * endpoint: "https://api.example.com/posts/:postId",
307
- * inputSchema: { postId: z.string(), title: z.string() },
308
- * auth: { type: "bearer", token: process.env.API_TOKEN! },
331
+ * inputSchema: { postId: z.string(), token: z.string(), title: z.string() },
332
+ * tokenParam: "token",
309
333
  * });
310
334
  * // PATCH https://api.example.com/posts/xyz789 { title }
335
+ * // Authorization: Bearer <token>
311
336
  */
312
337
  declare function patchToolAdapter<T extends ZodRawShapeCompat>(server: McpServer, config: PatchToolAdapterConfig<T>): void;
313
338
  /**
@@ -325,10 +350,11 @@ declare function patchToolAdapter<T extends ZodRawShapeCompat>(server: McpServer
325
350
  * name: "delete-post",
326
351
  * description: "Delete a post by ID",
327
352
  * endpoint: "https://api.example.com/posts/:postId",
328
- * inputSchema: { postId: z.string() },
329
- * auth: { type: "bearer", token: process.env.API_TOKEN! },
353
+ * inputSchema: { postId: z.string(), token: z.string() },
354
+ * tokenParam: "token",
330
355
  * });
331
356
  * // DELETE https://api.example.com/posts/xyz789
357
+ * // Authorization: Bearer <token>
332
358
  */
333
359
  declare function deleteToolAdapter<T extends ZodRawShapeCompat>(server: McpServer, config: DeleteToolAdapterConfig<T>): void;
334
360