uber_request_ride
Book an Uber ride by providing user ID, product selection, and pickup/destination coordinates to arrange transportation.
Instructions
Request an Uber ride
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | Yes | Unique identifier for the user | |
| productId | Yes | Uber product ID (from price estimates) | |
| startLatitude | Yes | Starting location latitude | |
| startLongitude | Yes | Starting location longitude | |
| endLatitude | Yes | Destination latitude | |
| endLongitude | Yes | Destination longitude | |
| fareId | No | Fare ID from price estimate |
Implementation Reference
- src/index.ts:123-127 (registration)Registration of the 'uber_request_ride' tool in the TOOLS array, including name, description, and input schema.{ name: 'uber_request_ride', description: 'Request an Uber ride', inputSchema: zodToJsonSchema(RequestRideSchema), },
- src/index.ts:52-60 (schema)Zod schema defining the input parameters for the uber_request_ride tool.const RequestRideSchema = z.object({ userId: z.string().describe('Unique identifier for the user'), productId: z.string().describe('Uber product ID (from price estimates)'), 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'), fareId: z.string().optional().describe('Fare ID from price estimate'), });
- src/index.ts:220-247 (handler)MCP tool handler for 'uber_request_ride': parses input, authenticates user, calls UberClient.requestRide, and returns the ride request details.case 'uber_request_ride': { const { userId, productId, startLatitude, startLongitude, endLatitude, endLongitude, fareId } = RequestRideSchema.parse(args); const token = userTokens.get(userId); if (!token) { throw new Error('User not authenticated. Please authorize first.'); } uberClient.setAccessToken(token); const rideRequest = await uberClient.requestRide( productId, startLatitude, startLongitude, endLatitude, endLongitude, fareId ); return { content: [ { type: 'text', text: JSON.stringify(rideRequest, null, 2), }, ], }; }
- src/uber-client.ts:67-89 (helper)Core implementation in UberClient class that makes the HTTP POST request to Uber's /v1.2/requests endpoint to request a ride.async requestRide( productId: string, startLat: number, startLng: number, endLat: number, endLng: number, fareId?: string ): Promise<RideRequest> { const payload: any = { product_id: productId, start_latitude: startLat, start_longitude: startLng, end_latitude: endLat, end_longitude: endLng, }; if (fareId) { payload.fare_id = fareId; } const response = await this.api.post('/v1.2/requests', payload); return response.data; }