@@ -65,13 +65,19 @@ const make = Effect.gen(function* () {
6565
6666 let payload : unknown ;
6767 if ( names . has ( "searchJiraIssuesUsingJql" ) ) {
68+ let cloudId : string | undefined ;
69+ if ( names . has ( "getAccessibleAtlassianResources" ) ) {
70+ const resources = yield * session . callTool ( "getAccessibleAtlassianResources" , { } ) ;
71+ cloudId = firstAtlassianCloudId ( resources ) ;
72+ }
6873 payload = yield * session . callTool ( "searchJiraIssuesUsingJql" , {
6974 jql,
7075 maxResults : MAX_ROWS ,
76+ ...( cloudId !== undefined ? { cloudId } : { } ) ,
7177 } ) ;
7278 } else if ( names . has ( "search" ) || names . has ( "jira_search" ) ) {
7379 const tool = names . has ( "search" ) ? "search" : "jira_search" ;
74- payload = yield * session . callTool ( tool , { jql, maxResults : MAX_ROWS } ) ;
80+ payload = yield * session . callTool ( tool , { jql, limit : MAX_ROWS } ) ;
7581 } else {
7682 return yield * new MentionIndexMcpError ( {
7783 detail :
@@ -114,7 +120,11 @@ const make = Effect.gen(function* () {
114120 const scopeKey = mentionIndexScopeKey ( "jira" , projectId ) ;
115121 const meta = yield * index . scopeMeta ( scopeKey ) ;
116122 const now = yield * Clock . currentTimeMillis ;
117- const stale = meta === null || now - meta . syncedAt > STALE_AFTER_MS ;
123+ const freshnessMs =
124+ meta !== null && ( meta . status === "empty" || meta . status === "error" )
125+ ? 30_000
126+ : STALE_AFTER_MS ;
127+ const stale = meta === null || now - meta . syncedAt > freshnessMs ;
118128 if ( ! stale ) return ;
119129
120130 const key = String ( projectId ) ;
@@ -148,6 +158,23 @@ function asRecord(value: unknown): Record<string, unknown> | null {
148158 : null ;
149159}
150160
161+ function firstAtlassianCloudId ( payload : unknown ) : string | undefined {
162+ const root = textFromMcpResult ( payload ) ;
163+ const entries = Array . isArray ( root )
164+ ? root
165+ : Array . isArray ( asRecord ( root ) ?. resources )
166+ ? ( asRecord ( root ) ?. resources as unknown [ ] )
167+ : Array . isArray ( asRecord ( root ) ?. data )
168+ ? ( asRecord ( root ) ?. data as unknown [ ] )
169+ : [ ] ;
170+ for ( const entry of entries ) {
171+ const record = asRecord ( entry ) ;
172+ const cloudId = record === null ? undefined : ( stringOf ( record . cloudId ) ?? stringOf ( record . id ) ) ;
173+ if ( cloudId !== undefined ) return cloudId ;
174+ }
175+ return stringOf ( asRecord ( root ) ?. cloudId ) ;
176+ }
177+
151178function stringOf ( value : unknown ) : string | undefined {
152179 return typeof value === "string" && value . trim ( ) . length > 0 ? value . trim ( ) : undefined ;
153180}
0 commit comments