uber_request_ride
Request an Uber ride by specifying user ID, product ID, start and destination coordinates, and fare ID. Simplify ride booking via the MCP Uber Server.
Instructions
Request an Uber ride
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endLatitude | Yes | Destination latitude | |
| endLongitude | Yes | Destination longitude | |
| fareId | No | Fare ID from price estimate | |
| productId | Yes | Uber product ID (from price estimates) | |
| startLatitude | Yes | Starting location latitude | |
| startLongitude | Yes | Starting location longitude | |
| userId | Yes | Unique identifier for the user |
Implementation Reference
- src/index.ts:220-247 (handler)The handler function for the 'uber_request_ride' tool. It validates input with RequestRideSchema, checks user authentication, sets the access token, calls uberClient.requestRide, and returns the ride request details as JSON.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/index.ts:52-60 (schema)Zod schema for input validation of the uber_request_ride tool parameters.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:123-127 (registration)Registration of the 'uber_request_ride' tool in the TOOLS array, specifying name, description, and input schema.{ name: 'uber_request_ride', description: 'Request an Uber ride', inputSchema: zodToJsonSchema(RequestRideSchema), },
- src/uber-client.ts:67-89 (helper)Core implementation in UberClient class that constructs the payload and makes the POST request to Uber's /v1.2/requests API 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; }