Skip to main content
Glama
stefanstranger

mcp-server-vanmoof

get_rides_for_week

Retrieve weekly bike ride data from VanMoof by specifying any date within the desired week to track cycling activity patterns.

Instructions

    Retrieves rides for a specific week from the vanMoof API.
    
    Args:
        date_in_week: Any date within the week in format "YYYY-MM-DD".
                    If None, uses the current date.
                    
    Returns:
        The rides for the specified week if authentication is successful, otherwise None.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
date_in_weekNo

Implementation Reference

  • Handler function decorated with @mcp.tool(), which registers and implements the get_rides_for_week tool. Validates input date, authenticates with VanMoof API, fetches customer data, constructs weekly rides URL, and returns the rides data for the specified week.
    @mcp.tool()
    def get_rides_for_week(date_in_week: str = "") -> Dict[str, Any]:
        """
        Retrieves rides for a specific week from the vanMoof API.
        
        Args:
            date_in_week: Any date within the week in format "YYYY-MM-DD".
                        If None, uses the current date.
                        
        Returns:
            The rides for the specified week if authentication is successful, otherwise None.
        """
        
        # If date_in_week is not provided, return error
        if date_in_week == "":
            return {"error": "Missing Argument. Please use YYYY-MM-DD format."}
        # Validate date format (YYYY-MM-DD)
        try:
            # Check basic format with regex
            if not re.match(r'^\d{4}-\d{2}-\d{2}$', date_in_week):
                return {"error": "Invalid date format. Please use YYYY-MM-DD format."}
            
            # Try to parse the date to validate it's a real date
            date_obj = datetime.strptime(date_in_week, "%Y-%m-%d")
        except ValueError:
            return {"error": "Invalid date. Please provide a valid date in YYYY-MM-DD format."}
        
        # Get the Bearer token from the authenticate method
        token = VanMoofAPI.get_vanmoof_token(VANMOOF_USERNAME, VANMOOF_PASSWORD)
        application_token = VanMoofAPI.get_application_token(token)
        if not application_token:
            return {"error": "Authentication failed"}
        
        # Get the riderId and bikeId from the customer data
        customerData = VanMoofAPI.get_customer_data()
        riderId = customerData.get('data', {}).get('uuid')
        if not riderId:
            return {"error": "RiderId not found"}
        bikeId = customerData.get('data', {}).get('bikes', [{}])[0].get('id')
        if not bikeId:
            return {"error": "BikeId not found"}
        country = customerData.get('data', {}).get('country')
        if not country:
            return {"error": "CountryCode not found"}    
        
        # Calculate the Monday (start) and Sunday (end) of the week
        monday = date_obj - timedelta(days=date_obj.weekday())
        sunday = monday + timedelta(days=7)
        
        # The API needs the end date of the week as lastSeenWeek
        last_seen_week = sunday.strftime("%Y-%m-%d")
        
        url = f"https://tenjin.vanmoof.com/api/v1/rides/{riderId}/{bikeId}/weekly"
        querystring = {"lastSeenWeek": last_seen_week, "limit": "1"}
        
        headers = {
            "authorization": f"Bearer {application_token}",
            "api-key": "fcb38d47-f14b-30cf-843b-26283f6a5819",
            "cache-control": "no-cache, private",
            "accept-language": f"{country.lower()}_{country.upper()}",
            "accept-encoding": "gzip",
            "timezone": timezone_name,
            "accept": "*/*",
        }
        
        response = requests.get(url, headers=headers, params=querystring)
        
        result = response.json().get('section', {})[0]
        # add section querystring to the result json
        result['querystring'] = querystring    
        
        if not result:
            return {"error": "No rides found for the specified week"}
        else:
            return result
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses authentication requirements and return behavior (returns rides if successful, otherwise None), which is valuable. However, it lacks details on rate limits, error handling, pagination, or data format, leaving behavioral gaps for a read operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with three sentences: purpose, parameter details, and return behavior. It's front-loaded with the core purpose and uses clear sections (Args, Returns). There's minimal waste, though the formatting with extra whitespace slightly reduces efficiency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a simple parameter (1 param with 0% schema coverage), the description is moderately complete. It covers purpose, parameter semantics, and authentication/return behavior, but lacks details on output format (e.g., structure of rides data), error cases beyond authentication, or performance constraints, which could be important for an API tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must compensate. It adds significant meaning: it explains the parameter 'date_in_week' as 'Any date within the week in format "YYYY-MM-DD"' with a default behavior ('If None, uses the current date'), which clarifies usage beyond the bare schema. This adequately covers the single parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Retrieves' and resource 'rides for a specific week from the vanMoof API', making the purpose explicit. It distinguishes from siblings like 'get_rides_summary' by focusing on weekly data rather than summaries, but doesn't explicitly contrast with 'get_city_rides_thisweek' or 'get_world_rides_thisweek' which might have overlapping scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving weekly rides and mentions authentication requirements, but provides no explicit guidance on when to use this tool versus alternatives like 'get_city_rides_thisweek' or 'get_world_rides_thisweek'. The context is clear but lacks sibling differentiation or exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/stefanstranger/mcp-server-vanmoof'

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