File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -3879,6 +3879,51 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
38793879 expect ( result . resources [ 0 ] . description ) . toBe ( 'Overridden description' ) ;
38803880 expect ( result . resources [ 0 ] . mimeType ) . toBe ( 'text/markdown' ) ;
38813881 } ) ;
3882+
3883+ test ( 'should support optional prompt arguments' , async ( ) => {
3884+ const mcpServer = new McpServer ( {
3885+ name : 'test server' ,
3886+ version : '1.0'
3887+ } ) ;
3888+
3889+ const client = new Client ( {
3890+ name : 'test client' ,
3891+ version : '1.0'
3892+ } ) ;
3893+
3894+ mcpServer . registerPrompt (
3895+ 'test-prompt' ,
3896+ {
3897+ argsSchema : {
3898+ name : z . string ( ) . optional ( )
3899+ }
3900+ } ,
3901+ ( ) => ( {
3902+ messages : [ ]
3903+ } )
3904+ ) ;
3905+
3906+ const [ clientTransport , serverTransport ] = InMemoryTransport . createLinkedPair ( ) ;
3907+
3908+ await Promise . all ( [ client . connect ( clientTransport ) , mcpServer . server . connect ( serverTransport ) ] ) ;
3909+
3910+ const result = await client . request (
3911+ {
3912+ method : 'prompts/list'
3913+ } ,
3914+ ListPromptsResultSchema
3915+ ) ;
3916+
3917+ expect ( result . prompts ) . toHaveLength ( 1 ) ;
3918+ expect ( result . prompts [ 0 ] . name ) . toBe ( 'test-prompt' ) ;
3919+ expect ( result . prompts [ 0 ] . arguments ) . toEqual ( [
3920+ {
3921+ name : 'name' ,
3922+ description : undefined ,
3923+ required : false
3924+ }
3925+ ] )
3926+ } )
38823927 } ) ;
38833928
38843929 describe ( 'Tool title precedence' , ( ) => {
You can’t perform that action at this time.
0 commit comments