GetObjectNodeFromCache
Retrieve a cached node for an ABAP object by type, name, and technical name, expanding URI if present.
Instructions
[read-only] Returns a node from the in-memory objects list cache by OBJECT_TYPE, OBJECT_NAME, TECH_NAME, and expands OBJECT_URI if present.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| object_type | Yes | [read-only] Object type | |
| object_name | Yes | [read-only] Object name | |
| tech_name | Yes | [read-only] Technical name |
Implementation Reference
- The main handler function that looks up a cached node by object_type, object_name, tech_name, and optionally expands OBJECT_URI via an ADT request.
export async function handleGetObjectNodeFromCache( context: HandlerContext, args: any, ) { const { connection, logger } = context; const { object_type, object_name, tech_name } = args; if (!object_type || !object_name || !tech_name) { return { isError: true, content: [ { type: 'text', text: 'object_type, object_name, tech_name required' }, ], }; } const cache = objectsListCache.getCache(); let node: any = null; if (cache && Array.isArray(cache.objects)) { node = (cache.objects as any[]).find( (obj: any) => obj.OBJECT_TYPE === object_type && obj.OBJECT_NAME === object_name && obj.TECH_NAME === tech_name, ) || null; } if (!node) { logger?.debug( `Node ${object_type}/${object_name}/${tech_name} not found in cache`, ); return { isError: true, content: [{ type: 'text', text: 'Node not found in cache' }], }; } if (node.OBJECT_URI && !node.object_uri_response) { const buildEndpoint = (uri: string) => { if (uri.startsWith('http')) { try { const parsed = new URL(uri); return `${parsed.pathname}${parsed.search}`; } catch { // fall back to original if parsing fails return uri; } } return uri; }; try { const endpoint = buildEndpoint(node.OBJECT_URI); const resp = await makeAdtRequest(connection, endpoint, 'GET', 15000); node.object_uri_response = typeof resp.data === 'string' ? resp.data : JSON.stringify(resp.data); // Persist the fetched OBJECT_URI payload back into the cache entry const idx = cache.objects.findIndex( (obj: any) => obj.OBJECT_TYPE === object_type && obj.OBJECT_NAME === object_name && obj.TECH_NAME === tech_name, ); if (idx >= 0) { cache.objects[idx] = { ...cache.objects[idx], object_uri_response: node.object_uri_response, }; objectsListCache.setCache(cache); } } catch (e) { logger?.error('Failed to expand OBJECT_URI from cache', e as any); node.object_uri_response = `ERROR: ${e instanceof Error ? e.message : String(e)}`; } } logger?.info( `Returning cached node for ${object_type}/${object_name}/${tech_name}`, ); return { content: [{ type: 'json', json: node }], }; } - Tool definition including name 'GetObjectNodeFromCache', description, availability, and input schema (object_type, object_name, tech_name).
export const TOOL_DEFINITION = { name: 'GetObjectNodeFromCache', available_in: ['onprem', 'cloud'] as const, description: '[read-only] Returns a node from the in-memory objects list cache by OBJECT_TYPE, OBJECT_NAME, TECH_NAME, and expands OBJECT_URI if present.', inputSchema: { type: 'object', properties: { object_type: { type: 'string', description: '[read-only] Object type' }, object_name: { type: 'string', description: '[read-only] Object name' }, tech_name: { type: 'string', description: '[read-only] Technical name' }, }, required: ['object_type', 'object_name', 'tech_name'], }, } as const; - src/lib/handlers/groups/SystemHandlersGroup.ts:236-250 (registration)Registration of the tool in SystemHandlersGroup, mapping toolDefinition and handler to handleGetObjectNodeFromCache.
{ toolDefinition: GetObjectNodeFromCache_Tool, handler: (args: any) => { return handleGetObjectNodeFromCache( this.context, args as | { object_type: string; object_name: string } | { object_type: string; object_name: string; cache_type: string; }, ); }, }, - src/lib/getObjectsListCache.ts:5-21 (helper)In-memory cache singleton used by the handler to store and retrieve the objects list.
class ObjectsListCache { private cache: ObjectsListCacheType = null; setCache(data: any) { this.cache = data; } getCache(): ObjectsListCacheType { return this.cache; } clearCache() { this.cache = null; } } export const objectsListCache = new ObjectsListCache();