opa_get_storage
Retrieve current oil storage and inventory levels for Cushing, Oklahoma (WTI delivery hub) and the US Strategic Petroleum Reserve (SPR), with changes indicated.
Instructions
Get oil storage and inventory levels for Cushing, Oklahoma (WTI delivery hub) and/or the US Strategic Petroleum Reserve (SPR). Use when the user asks about oil inventories, storage levels, Cushing stocks, or the SPR. Returns current inventory levels with changes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| facility | No | Storage facility: cushing (WTI delivery hub), spr (Strategic Petroleum Reserve), or all (default: all) | all |
Implementation Reference
- src/index.ts:1190-1241 (registration)Registration of the 'opa_get_storage' tool via server.tool(), defining its name, description, input schema (facility enum), and handler callback.
server.tool( "opa_get_storage", "Get oil storage and inventory levels for Cushing, Oklahoma (WTI delivery hub) and/or the US Strategic Petroleum Reserve (SPR). Use when the user asks about oil inventories, storage levels, Cushing stocks, or the SPR. Returns current inventory levels with changes.", { facility: z .enum(["cushing", "spr", "all"]) .default("all") .describe( "Storage facility: cushing (WTI delivery hub), spr (Strategic Petroleum Reserve), or all (default: all)", ), }, async ({ facility }) => { const sections: string[] = ["# Oil Storage Levels\n"]; let hasData = false; if (facility === "cushing" || facility === "all") { const response = await makeApiRequest< ApiResponse<Record<string, unknown>> >("/v1/storage/cushing"); if (response?.status === "success") { hasData = true; sections.push("## Cushing, Oklahoma (WTI Hub)\n"); sections.push( "```json\n" + JSON.stringify(response.data, null, 2) + "\n```\n", ); } } if (facility === "spr" || facility === "all") { const response = await makeApiRequest<ApiResponse<Record<string, unknown>>>( "/v1/storage/spr", ); if (response?.status === "success") { hasData = true; sections.push("## Strategic Petroleum Reserve (SPR)\n"); sections.push( "```json\n" + JSON.stringify(response.data, null, 2) + "\n```\n", ); } } if (!hasData) { return errorResult( "Storage data not available. This requires a paid plan with energy intelligence access.", ); } sections.push("_Data from [OilPriceAPI](https://oilpriceapi.com)_"); return textResult(sections.join("\n")); }, ); - src/index.ts:1201-1241 (handler)The handler function for opa_get_storage. It queries Cushing (WTI hub) and/or SPR storage endpoints via makeApiRequest and formats results as text.
async ({ facility }) => { const sections: string[] = ["# Oil Storage Levels\n"]; let hasData = false; if (facility === "cushing" || facility === "all") { const response = await makeApiRequest< ApiResponse<Record<string, unknown>> >("/v1/storage/cushing"); if (response?.status === "success") { hasData = true; sections.push("## Cushing, Oklahoma (WTI Hub)\n"); sections.push( "```json\n" + JSON.stringify(response.data, null, 2) + "\n```\n", ); } } if (facility === "spr" || facility === "all") { const response = await makeApiRequest<ApiResponse<Record<string, unknown>>>( "/v1/storage/spr", ); if (response?.status === "success") { hasData = true; sections.push("## Strategic Petroleum Reserve (SPR)\n"); sections.push( "```json\n" + JSON.stringify(response.data, null, 2) + "\n```\n", ); } } if (!hasData) { return errorResult( "Storage data not available. This requires a paid plan with energy intelligence access.", ); } sections.push("_Data from [OilPriceAPI](https://oilpriceapi.com)_"); return textResult(sections.join("\n")); }, ); - src/index.ts:1193-1200 (schema)Input schema for opa_get_storage: a 'facility' enum parameter ('cushing', 'spr', 'all') defaulting to 'all', validated with Zod.
{ facility: z .enum(["cushing", "spr", "all"]) .default("all") .describe( "Storage facility: cushing (WTI delivery hub), spr (Strategic Petroleum Reserve), or all (default: all)", ), }, - src/index.ts:396-400 (helper)Helper function textResult() used by the handler to format success responses.
function textResult(text: string) { return { content: [{ type: "text" as const, text }], }; } - src/index.ts:386-391 (helper)Helper function errorResult() used by the handler to format error responses.
function errorResult(message: string) { return { content: [{ type: "text" as const, text: message }], isError: true, }; }