Skip to main content
Glama
stefanstranger

mcp-server-vanmoof

get_vanmoof_cities

Retrieve city data from the VanMoof API to access available service locations for riders and their preferences.

Instructions

    Retrieves a list of city data from the vanMoof API.

    Returns:
        The rider vanMoof's city data if authentication is successful, otherwise None.        
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function implementing the get_vanmoof_cities tool. Authenticates using helper methods and makes a GET request to the VanMoof API to retrieve city data. Registered via @mcp.tool() decorator.
    @mcp.tool()
    # Function to get vanMoof Cities
    def get_vanmoof_cities() -> Dict[str, Any]:
        """
        Retrieves a list of city data from the vanMoof API.
    
        Returns:
            The rider vanMoof's city data if authentication is successful, otherwise None.        
        """
        # 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"}
    
        url = "https://tenjin.vanmoof.com/api/v1/cities"
        headers = {
            "authorization": f"Bearer {application_token}",
            "api-key": "fcb38d47-f14b-30cf-843b-26283f6a5819"
        }
        response = requests.get(url, headers=headers)
        return response.json()
  • Helper method in VanMoofAPI class to obtain the initial VanMoof access token using basic auth.
    def get_vanmoof_token(username, password):
        """
        Authenticates with the VanMoof API and retrieves an access token.
    
        Args:
            username: The user's VanMoof email address.
            password: The user's VanMoof password.
    
        Returns:
            The access token string if authentication is successful, otherwise None.
        """
        api_key = 'fcb38d47-f14b-30cf-843b-26283f6a5819'
        uri_prefix = 'https://my.vanmoof.com/api/v8'
        auth_url = f'{uri_prefix}/authenticate'
    
        # Prepare Basic Authentication credentials
        auth_string = f"{username}:{password}"
        encoded_auth_string = base64.b64encode(auth_string.encode('ascii')).decode('ascii')
    
        headers = {
            'Authorization': f'Basic {encoded_auth_string}',
            'Api-Key': api_key
        }
    
        try:
            response = requests.post(auth_url, headers=headers)
            response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)
    
            # Parse the JSON response and extract the token
            token = response.json().get('token')
            return token
    
        except requests.exceptions.RequestException as e:
            print(f"An error occurred during the API request: {e}")
            return None
        except Exception as e:
            print(f"An unexpected error occurred: {e}")
            return None
  • Helper method in VanMoofAPI class to exchange the access token for an application token required for API calls.
    def get_application_token(token):
        """
        Authenticates with the VanMoof API and retrieves an application token.
    
        Args:
            token: The user's VanMoof access token.
    
        Returns:
            The application token string if authentication is successful, otherwise None.
        """
        api_key = 'fcb38d47-f14b-30cf-843b-26283f6a5819'
        uri_prefix = 'https://api.vanmoof-api.com/v8'
        auth_url = f'{uri_prefix}/getApplicationToken'
    
        headers = {
            'authorization': f'Bearer {token}',
            "accept": "*/*",
            "user-agent": "VanMoof-Rider/23.7 (sdk_gphone_x86_arm, Android 11)",
            'api-key': api_key
        }
    
        try:
            response = requests.get(auth_url, headers=headers)
            response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)
    
            # Parse the JSON response and extract the token
            application_token = response.json()
            return application_token.get('token')
    
        except requests.exceptions.RequestException as e:
            print(f"An error occurred during the API request: {e}")
            return None
        except Exception as e:
            print(f"An unexpected error occurred: {e}")
            return None
  • Related tool/helper to get customer data, which is used in other tools but called within the cities handler indirectly.
    @mcp.tool()
    # Function to get customer data
    def get_customer_data() -> Dict[str, Any]:
        """
        Retrieves customer data from the vanMoof API.
    
        Returns:
            The rider vanMoof's customer data if authentication is successful, otherwise None.
        """
        # Get the Bearer token from the authenticate method
        token = VanMoofAPI.get_vanmoof_token(VANMOOF_USERNAME, VANMOOF_PASSWORD)
        if not token:
            return {"error": "Authentication failed"}
    
        url = "https://my.vanmoof.com/api/v8/getCustomerData"
        headers = {
            "authorization": f"Bearer {token}",
            "api-key": "fcb38d47-f14b-30cf-843b-26283f6a5819"
        }
        response = requests.get(url, headers=headers)
        return response.json()
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that authentication is required for successful data retrieval and that the return may be 'None' if authentication fails, adding useful behavioral context. However, it lacks details on rate limits, error handling, or data format, leaving gaps in transparency.

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 concise with two sentences that directly state the purpose and return behavior, with no wasted words. It is appropriately sized for a simple tool, though the structure could be slightly improved by front-loading key details more explicitly.

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 the tool has no parameters, no annotations, and no output schema, the description provides basic purpose and authentication context, which is minimal but viable. However, it lacks details on output format, error cases beyond authentication, or how it fits with siblings, making it incomplete for full agent understanding.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description does not add parameter information, which is acceptable here, but it could have mentioned any implicit parameters or context. Baseline is 4 for zero parameters, as it adequately handles the lack of inputs.

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 ('list of city data from the vanMoof API'), making the purpose specific and understandable. However, it does not explicitly differentiate this tool from sibling tools like 'get_city_rides_thisweek' or 'get_world_rides_thisweek', which might also involve city or ride data, so it misses full sibling differentiation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It mentions authentication success affects the return value, but does not specify contexts, prerequisites, or comparisons to sibling tools like 'get_city_rides_thisweek' for ride-specific data or 'get_customer_data' for user information.

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