get_loans_for_asset
Retrieve loan history for a specific asset by providing its UUID. Returns loan details embedded in the asset record.
Instructions
Get the loan history for a single asset. Currently returns whatever loans field is embedded on the asset detail; in a future version may paginate independently.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asset_id | Yes | Asset uuid. |
Implementation Reference
- src/tools/index.ts:113-138 (handler)The full ToolDef for 'get_loans_for_asset': defines the name, description, inputSchema (asset_id required), and the async handler that calls GET /v1/schools/{schoolId}/gear/{id} and returns the loan history (current_loan and loans array) from the asset detail.
const getLoansForAsset: ToolDef = { name: 'get_loans_for_asset', description: 'Get the loan history for a single asset. Currently returns whatever loans field is embedded on the asset detail; in a future version may paginate independently.', inputSchema: { type: 'object', properties: { asset_id: { type: 'string', description: "Asset uuid." }, }, required: ['asset_id'], additionalProperties: false, }, async handler(args, client) { const id = String(args.asset_id ?? ''); if (!id) throw new Error('asset_id is required'); const ctx = await client.getContext(); const detail = (await client.get<{ current_loan?: unknown; loans?: unknown[] }>( `/v1/schools/${ctx.schoolId}/gear/${id}`, )) as { current_loan?: unknown; loans?: unknown[] }; return { asset_id: id, current_loan: detail.current_loan ?? null, loans: detail.loans ?? [], }; }, }; - src/tools/index.ts:117-124 (schema)Input schema for 'get_loans_for_asset': expects an object with required 'asset_id' (string) and no additional properties.
inputSchema: { type: 'object', properties: { asset_id: { type: 'string', description: "Asset uuid." }, }, required: ['asset_id'], additionalProperties: false, }, - src/tools/index.ts:193-200 (registration)The tool is registered in the exported 'tools' array (line 197) and also added to the 'toolByName' map (line 202) used by the MCP server to dispatch calls by name.
export const tools: ToolDef[] = [ listSchools, getAsset, searchAssets, getLoansForAsset, listMembers, listAssetThreads, ];