Skip to main content
Glama
199-mcp
by 199-mcp

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
NameRequiredDescriptionDefault
userIdYesUnique identifier for the user
startLatitudeYesStarting location latitude
startLongitudeYesStarting location longitude
endLatitudeYesDestination latitude
endLongitudeYesDestination longitude

Implementation Reference

  • 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),
          },
        ],
      };
    }
  • 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;
    }
  • 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),
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/199-mcp/mcp-uber'

If you have feedback or need assistance with the MCP directory API, please join our Discord server