uber_get_price_estimates
Calculate ride costs between two locations to help users plan and budget their Uber trips before booking.
Instructions
Get price estimates for a ride between two locations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | Yes | Unique identifier for the user | |
| startLatitude | Yes | Starting location latitude | |
| startLongitude | Yes | Starting location longitude | |
| endLatitude | Yes | Destination latitude | |
| endLongitude | Yes | Destination longitude |
Implementation Reference
- src/index.ts:193-218 (handler)MCP tool handler for 'uber_get_price_estimates': parses input, checks authentication, calls UberClient.getPriceEstimates, and returns JSON-formatted estimates.case 'uber_get_price_estimates': { const { userId, startLatitude, startLongitude, endLatitude, endLongitude } = PriceEstimateSchema.parse(args); const token = userTokens.get(userId); if (!token) { throw new Error('User not authenticated. Please authorize first.'); } uberClient.setAccessToken(token); const estimates = await uberClient.getPriceEstimates( startLatitude, startLongitude, endLatitude, endLongitude ); return { content: [ { type: 'text', text: JSON.stringify(estimates, null, 2), }, ], }; }
- src/uber-client.ts:50-65 (helper)Core UberClient method that performs the API request to retrieve price estimates from Uber's /v1.2/estimates/price endpoint.async getPriceEstimates( startLat: number, startLng: number, endLat: number, endLng: number ): Promise<PriceEstimate[]> { const response = await this.api.get('/v1.2/estimates/price', { params: { start_latitude: startLat, start_longitude: startLng, end_latitude: endLat, end_longitude: endLng, }, }); return response.data.prices; }
- src/index.ts:44-50 (schema)Zod input schema for validating parameters of uber_get_price_estimates tool.const PriceEstimateSchema = z.object({ userId: z.string().describe('Unique identifier for the user'), startLatitude: z.number().describe('Starting location latitude'), startLongitude: z.number().describe('Starting location longitude'), endLatitude: z.number().describe('Destination latitude'), endLongitude: z.number().describe('Destination longitude'), });
- src/index.ts:118-122 (registration)Tool registration in the TOOLS array, including name, description, and input schema.{ name: 'uber_get_price_estimates', description: 'Get price estimates for a ride between two locations', inputSchema: zodToJsonSchema(PriceEstimateSchema), },