@@ -90,16 +90,38 @@ export const POST = withMcpAuth('read')(
9090 )
9191 }
9292
93- // Parse array arguments based on tool schema
93+ // Cast arguments to their expected types based on tool schema
9494 if ( tool . inputSchema ?. properties ) {
9595 for ( const [ paramName , paramSchema ] of Object . entries ( tool . inputSchema . properties ) ) {
9696 const schema = paramSchema as any
97+ const value = args [ paramName ]
98+
99+ if ( value === undefined || value === null ) {
100+ continue
101+ }
102+
103+ // Cast numbers
97104 if (
98- schema . type === 'array' &&
99- args [ paramName ] !== undefined &&
100- typeof args [ paramName ] === 'string'
105+ ( schema . type === 'number' || schema . type === 'integer' ) &&
106+ typeof value === 'string'
101107 ) {
102- const stringValue = args [ paramName ] . trim ( )
108+ const numValue =
109+ schema . type === 'integer' ? Number . parseInt ( value ) : Number . parseFloat ( value )
110+ if ( ! Number . isNaN ( numValue ) ) {
111+ args [ paramName ] = numValue
112+ }
113+ }
114+ // Cast booleans
115+ else if ( schema . type === 'boolean' && typeof value === 'string' ) {
116+ if ( value . toLowerCase ( ) === 'true' ) {
117+ args [ paramName ] = true
118+ } else if ( value . toLowerCase ( ) === 'false' ) {
119+ args [ paramName ] = false
120+ }
121+ }
122+ // Cast arrays
123+ else if ( schema . type === 'array' && typeof value === 'string' ) {
124+ const stringValue = value . trim ( )
103125 if ( stringValue ) {
104126 try {
105127 // Try to parse as JSON first (handles ["item1", "item2"])
0 commit comments