get_water_rights_net_amount
Calculate net water amounts for specific rights in Colorado by providing water right name and division number to retrieve accurate allocation data.
Instructions
Get net amounts for water rights
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| waterRightName | No | Name of the water right | |
| division | No | Water division number | |
| pageSize | No | Number of results to return |
Implementation Reference
- src/index.ts:144-147 (handler)Handler for the get_water_rights_net_amount tool. Extracts arguments from the request and delegates to the shared handleApiCall method with the specific API endpoint 'waterrights/netamount'.case "get_water_rights_net_amount": { const args = request.params.arguments as any; return await this.handleApiCall("waterrights/netamount", args); }
- src/index.ts:88-92 (schema)Zod schema defining the input parameters for the tool: waterRightName (optional string), division (optional number), pageSize (optional number). This is converted to JSON schema for the tool definition.z.object({ waterRightName: z.string().optional().describe("Name of the water right"), division: z.number().optional().describe("Water division number"), pageSize: z.number().optional().describe("Number of results to return"), })
- src/index.ts:84-94 (registration)Registration of the 'get_water_rights_net_amount' tool in the ListTools response, including name, description, and input schema.{ name: "get_water_rights_net_amount", description: "Get net amounts for water rights", inputSchema: zodToJsonSchema( z.object({ waterRightName: z.string().optional().describe("Name of the water right"), division: z.number().optional().describe("Water division number"), pageSize: z.number().optional().describe("Number of results to return"), }) ), },
- src/index.ts:184-217 (helper)Shared helper method that performs the actual API call to the Colorado DWR REST API. Constructs the URL, formats parameters (including optional apiKey), fetches data using axios, and returns the JSON response as tool output. This is the core logic executed for the tool.public async handleApiCall(endpoint: string, params: any) { const url = `${BASE_URL}/${endpoint}`; const headers: Record<string, string> = {}; if (this.apiKey) { headers["Authorization"] = this.apiKey; // Or however DWR expects it, docs say 'Token: ...' or query param } // DWR docs say: "Token: B9xxxxx-xxxx-4D47-y" in header OR apiKey query param // I'll use query param if apiKey is present to be safe/easy, or header if I can confirm. // Docs: "Request Header: ... Token: ..." // Let's stick to query params for simplicity if header format is custom. // Actually, let's use the params object. const finalParams = formatParams(params); if (this.apiKey) { finalParams["apiKey"] = this.apiKey; } console.error(`Fetching ${url} with params ${JSON.stringify(finalParams)}`); const response = await axios.get(url, { params: finalParams, headers, }); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; }