uber_get_price_estimates
Obtain estimated ride costs between specified start and end locations for users. Enables AI assistants to provide accurate fare information for Uber rides.
Instructions
Get price estimates for a ride between two locations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endLatitude | Yes | Destination latitude | |
| endLongitude | Yes | Destination longitude | |
| startLatitude | Yes | Starting location latitude | |
| startLongitude | Yes | Starting location longitude | |
| userId | Yes | Unique identifier for the user |
Implementation Reference
- src/index.ts:193-218 (handler)MCP server request handler for the uber_get_price_estimates tool. Validates input using PriceEstimateSchema, checks user authentication token, sets the token on UberClient, calls uberClient.getPriceEstimates, and returns the JSON stringified result.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/index.ts:44-50 (schema)Zod schema defining the input parameters for the uber_get_price_estimates tool: userId, start/end latitude/longitude.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)Registration of the uber_get_price_estimates tool in the MCP 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), },
- src/uber-client.ts:50-65 (helper)UberClient method that performs the actual API call to Uber's /v1.2/estimates/price endpoint to fetch price estimates between start and end locations.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; }