@@ -43,7 +43,7 @@ export function parsePath(path: string): EndpointPath {
43
43
44
44
if ( parts . length != 3 ) {
45
45
throw new Error (
46
- `Invalid Endpoint path format [${ path } ]. Use or vendor/space/endpoint` ,
46
+ `Invalid Endpoint path format [${ path } ]. Use or vendor/space/endpoint`
47
47
) ;
48
48
}
49
49
@@ -74,19 +74,19 @@ export class EndpointWrapper {
74
74
private endpointPath : EndpointPath ,
75
75
private endpoint : ApiEndpoint ,
76
76
private client : Client ,
77
- private workingDir : WorkingDirectory ,
77
+ private workingDir : WorkingDirectory
78
78
) {
79
79
this . converter = new GradioConverter ( workingDir ) ;
80
80
}
81
81
82
82
static async createEndpoint (
83
83
configuredPath : string ,
84
- workingDir : WorkingDirectory ,
84
+ workingDir : WorkingDirectory
85
85
) : Promise < EndpointWrapper > {
86
86
const pathParts = configuredPath . split ( "/" ) ;
87
87
if ( pathParts . length < 2 || pathParts . length > 3 ) {
88
88
throw new Error (
89
- `Invalid space path format [${ configuredPath } ]. Use: vendor/space or vendor/space/endpoint` ,
89
+ `Invalid space path format [${ configuredPath } ]. Use: vendor/space or vendor/space/endpoint`
90
90
) ;
91
91
}
92
92
@@ -114,7 +114,7 @@ export class EndpointWrapper {
114
114
if ( config . debug ) {
115
115
await fs . writeFile (
116
116
`${ pathParts [ 0 ] } _${ pathParts [ 1 ] } _debug_api.json` ,
117
- JSON . stringify ( api , null , 2 ) ,
117
+ JSON . stringify ( api , null , 2 )
118
118
) ;
119
119
}
120
120
// Try chosen API if specified
@@ -123,20 +123,20 @@ export class EndpointWrapper {
123
123
parsePath ( configuredPath ) ,
124
124
api . named_endpoints [ endpointTarget ] ,
125
125
gradio ,
126
- workingDir ,
126
+ workingDir
127
127
) ;
128
128
}
129
129
130
130
// Try preferred APIs
131
131
const preferredApi = preferredApis . find (
132
- ( name ) => api . named_endpoints [ name ] ,
132
+ ( name ) => api . named_endpoints [ name ]
133
133
) ;
134
134
if ( preferredApi ) {
135
135
return new EndpointWrapper (
136
136
parsePath ( `${ configuredPath } ${ preferredApi } ` ) ,
137
137
api . named_endpoints [ preferredApi ] ,
138
138
gradio ,
139
- workingDir ,
139
+ workingDir
140
140
) ;
141
141
}
142
142
@@ -147,22 +147,22 @@ export class EndpointWrapper {
147
147
parsePath ( `${ configuredPath } ${ firstNamed [ 0 ] } ` ) ,
148
148
firstNamed [ 1 ] ,
149
149
gradio ,
150
- workingDir ,
150
+ workingDir
151
151
) ;
152
152
}
153
153
154
154
// Try unnamed endpoints
155
155
const validUnnamed = Object . entries ( api . unnamed_endpoints ) . find (
156
156
( [ , endpoint ] ) =>
157
- endpoint . parameters . length > 0 && endpoint . returns . length > 0 ,
157
+ endpoint . parameters . length > 0 && endpoint . returns . length > 0
158
158
) ;
159
159
160
160
if ( validUnnamed ) {
161
161
return new EndpointWrapper (
162
162
parsePath ( `${ configuredPath } /${ validUnnamed [ 0 ] } ` ) ,
163
163
validUnnamed [ 1 ] ,
164
164
gradio ,
165
- workingDir ,
165
+ workingDir
166
166
) ;
167
167
}
168
168
@@ -192,7 +192,7 @@ export class EndpointWrapper {
192
192
193
193
async call (
194
194
request : CallToolRequest ,
195
- server : Server ,
195
+ server : Server
196
196
) : Promise < CallToolResult > {
197
197
const progressToken = request . params . _meta ?. progressToken as
198
198
| string
@@ -207,7 +207,7 @@ export class EndpointWrapper {
207
207
// Process each parameter, applying handle_file for file inputs
208
208
for ( const [ key , value ] of Object . entries ( parameters ) ) {
209
209
const param = endpointParams . find (
210
- ( p ) => p . parameter_name === key || p . label === key ,
210
+ ( p ) => p . parameter_name === key || p . label === key
211
211
) ;
212
212
if ( param && isFileParameter ( param ) && typeof value === "string" ) {
213
213
const file = await this . validatePath ( value ) ;
@@ -226,22 +226,22 @@ export class EndpointWrapper {
226
226
async handleToolCall (
227
227
parameters : Record < string , unknown > ,
228
228
progressToken : string | undefined ,
229
- server : Server ,
229
+ server : Server
230
230
) : Promise < CallToolResult > {
231
231
const events = [ ] ;
232
232
try {
233
233
let result = null ;
234
234
const submission : AsyncIterable < GradioEvent > = this . client . submit (
235
235
this . endpointPath . endpoint ,
236
- parameters ,
236
+ parameters
237
237
) as AsyncIterable < GradioEvent > ;
238
238
const progressNotifier = createProgressNotifier ( server ) ;
239
239
for await ( const msg of submission ) {
240
240
if ( config . debug ) events . push ( msg ) ;
241
241
if ( msg . type === "data" ) {
242
242
if ( Array . isArray ( msg . data ) ) {
243
243
const hasContent = msg . data . some (
244
- ( item : unknown ) => typeof item !== "object" ,
244
+ ( item : unknown ) => typeof item !== "object"
245
245
) ;
246
246
247
247
if ( hasContent ) result = msg . data ;
@@ -262,7 +262,7 @@ export class EndpointWrapper {
262
262
return await this . convertPredictResults (
263
263
this . endpoint . returns ,
264
264
result ,
265
- this . endpointPath ,
265
+ this . endpointPath
266
266
) ;
267
267
} catch ( error ) {
268
268
const errorMessage =
@@ -274,7 +274,7 @@ export class EndpointWrapper {
274
274
`${ this . mcpToolName } _status_${ crypto
275
275
. randomUUID ( )
276
276
. substring ( 0 , 5 ) } .json`,
277
- JSON . stringify ( events , null , 2 ) ,
277
+ JSON . stringify ( events , null , 2 )
278
278
) ;
279
279
}
280
280
}
@@ -283,7 +283,7 @@ export class EndpointWrapper {
283
283
private async convertPredictResults (
284
284
returns : ApiReturn [ ] ,
285
285
predictResults : unknown [ ] ,
286
- endpointPath : EndpointPath ,
286
+ endpointPath : EndpointPath
287
287
) : Promise < CallToolResult > {
288
288
const content : ( TextContent | ImageContent | EmbeddedResource ) [ ] = [ ] ;
289
289
@@ -292,7 +292,7 @@ export class EndpointWrapper {
292
292
const converted = await this . converter . convert (
293
293
output ,
294
294
value as GradioResourceValue ,
295
- endpointPath ,
295
+ endpointPath
296
296
) ;
297
297
content . push ( converted ) ;
298
298
}
@@ -317,13 +317,13 @@ export class EndpointWrapper {
317
317
name,
318
318
description : prop ?. description || name ,
319
319
required : schema . required ?. includes ( name ) || false ,
320
- } ) ,
320
+ } )
321
321
) ,
322
322
} ;
323
323
}
324
324
325
325
async getPromptTemplate (
326
- args ?: Record < string , string > ,
326
+ args ?: Record < string , string >
327
327
) : Promise < GetPromptResult > {
328
328
const schema = convertApiToSchema ( this . endpoint ) ;
329
329
let promptText = `Using the ${ this . mcpDescriptionName ( ) } :\n\n` ;
0 commit comments