@@ -112,6 +112,11 @@ export interface ClientOptions {
112112 */
113113 apiKey ?: string | undefined ;
114114
115+ /**
116+ * Base URL for Smithery Connect REST methods.
117+ */
118+ connectBaseURL ?: string | null | undefined ;
119+
115120 /**
116121 * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
117122 *
@@ -186,6 +191,7 @@ export interface ClientOptions {
186191 */
187192export class Smithery {
188193 apiKey : string ;
194+ connectBaseURL : string | null ;
189195
190196 baseURL : string ;
191197 maxRetries : number ;
@@ -203,6 +209,7 @@ export class Smithery {
203209 * API Client for interfacing with the Smithery API.
204210 *
205211 * @param {string | undefined } [opts.apiKey=process.env['SMITHERY_API_KEY'] ?? undefined]
212+ * @param {string | null | undefined } [opts.connectBaseURL=process.env['SMITHERY_CONNECT_BASE_URL'] ?? https://smithery.run]
206213 * @param {string } [opts.baseURL=process.env['SMITHERY_BASE_URL'] ?? https://api.smithery.ai] - Override the default base URL for the API.
207214 * @param {number } [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
208215 * @param {MergedRequestInit } [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
@@ -214,6 +221,7 @@ export class Smithery {
214221 constructor ( {
215222 baseURL = readEnv ( 'SMITHERY_BASE_URL' ) ,
216223 apiKey = readEnv ( 'SMITHERY_API_KEY' ) ,
224+ connectBaseURL = readEnv ( 'SMITHERY_CONNECT_BASE_URL' ) ?? 'https://smithery.run' ,
217225 ...opts
218226 } : ClientOptions = { } ) {
219227 if ( apiKey === undefined ) {
@@ -224,6 +232,7 @@ export class Smithery {
224232
225233 const options : ClientOptions = {
226234 apiKey,
235+ connectBaseURL,
227236 ...opts ,
228237 baseURL : baseURL || `https://api.smithery.ai` ,
229238 } ;
@@ -258,6 +267,7 @@ export class Smithery {
258267 this . _options = options ;
259268
260269 this . apiKey = apiKey ;
270+ this . connectBaseURL = connectBaseURL ;
261271 }
262272
263273 /**
@@ -274,6 +284,7 @@ export class Smithery {
274284 fetch : this . fetch ,
275285 fetchOptions : this . fetchOptions ,
276286 apiKey : this . apiKey ,
287+ connectBaseURL : this . connectBaseURL ,
277288 ...options ,
278289 } ) ;
279290 return client ;
@@ -324,7 +335,12 @@ export class Smithery {
324335 query : Record < string , unknown > | null | undefined ,
325336 defaultBaseURL ?: string | undefined ,
326337 ) : string {
327- const baseURL = ( ! this . #baseURLOverridden( ) && defaultBaseURL ) || this . baseURL ;
338+ const resolvedDefaultBaseURL =
339+ defaultBaseURL === 'https://smithery.run' ? this . connectBaseURL || defaultBaseURL : defaultBaseURL ;
340+ const baseURL =
341+ ( defaultBaseURL === 'https://smithery.run' && resolvedDefaultBaseURL ) ||
342+ ( ! this . #baseURLOverridden( ) && resolvedDefaultBaseURL ) ||
343+ this . baseURL ;
328344 const url =
329345 isAbsoluteURL ( path ) ?
330346 new URL ( path )
0 commit comments