get_trips
Fetch recent trips from a Polarsteps user's travel history with summary details like names, dates, duration, and basic statistics. Control the number of trips retrieved to browse travel history or find trip IDs for further exploration.
Instructions
Fetch a list of a user's recent trips with summary information including trip names, dates, duration, and basic stats. Ideal for browsing someone's travel history or finding trip IDs for detailed exploration. Use n_trips parameter to control how many recent trips to retrieve (default: 5).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | The Polarsteps username whose trips you want to retrieve | |
| n_trips | No | Maximum number of recent trips to return (ordered by most recent first) |
Implementation Reference
- src/polarsteps_mcp/tools.py:139-151 (handler)The core handler function for the 'get_trips' tool. Retrieves the user's trips via _get_user helper, checks if trips exist, and returns JSON-serialized summaries of the most recent n_trips (default 5) as TextContent objects.def get_trips( polarsteps_client: PolarstepsClient, input: GetTripsInput ) -> list[TextContent]: user = _get_user(polarsteps_client, input.username) if user.alltrips is None: return single_text_content( f"No trips found for user with username={input.username}" ) return [ TextContent(type="text", text=json.dumps(trip.to_summary())) for trip in user.alltrips[: input.n_trips] ]
- src/polarsteps_mcp/tools.py:128-137 (schema)Pydantic model defining the input schema for the get_trips tool, with required 'username' and optional 'n_trips' (default 5, min 1) fields.class GetTripsInput(BaseModel): username: str = Field( ..., description="The Polarsteps username whose trips you want to retrieve" ) n_trips: int = Field( 5, ge=1, description="Maximum number of recent trips to return (ordered by most recent first)", )
- src/polarsteps_mcp/tools.py:227-231 (registration)Registration of the 'get_trips' tool in the PolarstepsTool Enum, providing the tool name, description, and input schema for MCP server tool listing.TRIPS = ( "get_trips", "Fetch a list of a user's recent trips with summary information including trip names, dates, duration, and basic stats. Ideal for browsing someone's travel history or finding trip IDs for detailed exploration. Use n_trips parameter to control how many recent trips to retrieve (default: 5).", GetTripsInput, )
- src/polarsteps_mcp/server.py:64-66 (registration)Dispatch logic in the MCP server's call_tool handler that invokes the get_trips function with parsed input when the 'get_trips' tool is called.case PolarstepsTool.TRIPS: input = GetTripsInput(**args) return get_trips(client, input)