@@ -628,6 +628,47 @@ describe("createToolSearchTool", () => {
628628 ) ;
629629 } ) ;
630630
631+ async function schemaCardLine (
632+ inputSchema : Record < string , unknown > ,
633+ ) : Promise < string | undefined > {
634+ const def : ToolDefinition = {
635+ name : "mcp__linear__big" ,
636+ description : "Linear issue with a large schema" ,
637+ inputSchema,
638+ } ;
639+ const tool = createToolSearchTool ( {
640+ search : ( ) => [ def . name ] ,
641+ lookup : ( ) => def ,
642+ } ) ;
643+ const out = await call ( tool , { query : "linear" } ) ;
644+ return out
645+ . split ( "\n" )
646+ . find ( ( line ) => line . startsWith ( " {" ) )
647+ ?. trim ( ) ;
648+ }
649+
650+ test ( "an oversized input schema's card lists its property names" , async ( ) => {
651+ const line = await schemaCardLine ( {
652+ type : "object" ,
653+ properties : {
654+ alpha : { type : "string" , description : "x" . repeat ( 400 ) } ,
655+ beta : { type : "string" , description : "y" . repeat ( 400 ) } ,
656+ } ,
657+ required : [ ] ,
658+ } ) ;
659+ expect ( line ) . toBe ( '{"properties":["alpha","beta"],"required":[]}' ) ;
660+ } ) ;
661+
662+ test ( "an oversized card lists no property names when properties is not an object" , async ( ) => {
663+ const line = await schemaCardLine ( {
664+ type : "object" ,
665+ properties : null ,
666+ description : "z" . repeat ( TOOL_SEARCH_SCHEMA_MAX ) ,
667+ required : [ "alpha" ] ,
668+ } ) ;
669+ expect ( line ) . toBe ( '{"properties":[],"required":["alpha"]}' ) ;
670+ } ) ;
671+
631672 test ( "search does not promote matches and keeps description lines short" , async ( ) => {
632673 const tool = createToolSearchTool ( {
633674 search : ( q ) => linearIndex . search ( q ) ,
0 commit comments