File tree Expand file tree Collapse file tree 3 files changed +15
-10
lines changed
Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -232,14 +232,25 @@ export abstract class BaseTransport {
232232 * @returns true if this is a tools/call for a Gradio tool, false otherwise
233233 */
234234 protected isGradioToolCall ( requestBody : unknown ) : boolean {
235- const body = requestBody as { method ?: string ; params ?: { name ?: string } } | undefined ;
235+ const body = requestBody as { method ?: string ; params ?: { name ?: string ; arguments ?: unknown } } | undefined ;
236236 const methodName = body ?. method || 'unknown' ;
237237
238238 // Check if this is a tools/call with a valid tool name
239239 if ( methodName === 'tools/call' && body ?. params && typeof body . params === 'object' && 'name' in body . params ) {
240240 const toolName = body . params . name ;
241241 if ( typeof toolName === 'string' ) {
242- return isGradioTool ( toolName ) ;
242+ // Check for standard Gradio tools (gr<number>_ or grp<number>_)
243+ if ( isGradioTool ( toolName ) ) {
244+ return true ;
245+ }
246+
247+ // Special case: dynamic_space with "invoke" operation needs streaming
248+ if ( toolName === 'dynamic_space' && body . params . arguments ) {
249+ const args = body . params . arguments as { operation ?: string } | undefined ;
250+ if ( args ?. operation === 'invoke' ) {
251+ return true ;
252+ }
253+ }
243254 }
244255 }
245256
Original file line number Diff line number Diff line change 11/**
22 * Utility functions for handling Gradio endpoint detection and configuration
33 */
4- import { DYNAMIC_SPACE_TOOL_CONFIG } from '@llmindset/hf-mcp' ;
54import type { SpaceTool } from '../../shared/settings.js' ;
65import { GRADIO_PREFIX , GRADIO_PRIVATE_PREFIX } from '../../shared/constants.js' ;
76import { logger } from './logger.js' ;
@@ -17,14 +16,12 @@ import { getGradioSpaces } from './gradio-discovery.js';
1716 * @example
1817 * isGradioTool('gr1_evalstate_flux1_schnell') // true
1918 * isGradioTool('grp2_private_tool') // true
20- * isGradioTool('dynamic_space') // true
2119 * isGradioTool('hf_doc_search') // false
2220 * isGradioTool('regular_tool') // false
2321 */
2422export function isGradioTool ( toolName : string ) : boolean {
2523 // Gradio tools follow pattern: gr<number>_<name> or grp<number>_<name>
26- // Also includes the special dynamic_space tool
27- return / ^ g r p ? \d + _ / . test ( toolName ) || toolName === DYNAMIC_SPACE_TOOL_CONFIG . name ;
24+ return / ^ g r p ? \d + _ / . test ( toolName ) ;
2825}
2926
3027/**
Original file line number Diff line number Diff line change @@ -19,10 +19,6 @@ describe('isGradioTool', () => {
1919 expect ( isGradioTool ( 'grp10_test' ) ) . toBe ( true ) ;
2020 } ) ;
2121
22- it ( 'should detect dynamic_space tool' , ( ) => {
23- expect ( isGradioTool ( 'dynamic_space' ) ) . toBe ( true ) ;
24- } ) ;
25-
2622 it ( 'should detect real-world Gradio tool names' , ( ) => {
2723 expect ( isGradioTool ( 'gr1_evalstate_flux1_schnell' ) ) . toBe ( true ) ;
2824 expect ( isGradioTool ( 'grp3_my_private_space' ) ) . toBe ( true ) ;
@@ -51,6 +47,7 @@ describe('isGradioTool', () => {
5147 expect ( isGradioTool ( 'hf_doc_search' ) ) . toBe ( false ) ;
5248 expect ( isGradioTool ( 'hf_model_search' ) ) . toBe ( false ) ;
5349 expect ( isGradioTool ( 'hf_whoami' ) ) . toBe ( false ) ;
50+ expect ( isGradioTool ( 'dynamic_space' ) ) . toBe ( false ) ;
5451 } ) ;
5552
5653 it ( 'should reject tools with missing number' , ( ) => {
You can’t perform that action at this time.
0 commit comments