Skip to main content
Glama
webdriverio

WebDriverIO MCP Server

Official

set_geolocation

Idempotent

Override GPS coordinates for browser and mobile sessions to simulate specific locations. Requires location permissions to be granted.

Instructions

Overrides GPS coordinates for the session. Affects navigator.geolocation in browsers and location services on mobile. Location permissions must already be granted to the app.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYesLatitude coordinate
longitudeYesLongitude coordinate
altitudeNoAltitude in meters (optional)

Implementation Reference

  • The `setGeolocationTool` async function that executes the tool logic. It calls `browser.setGeoLocation()` with the provided latitude, longitude, and optional altitude.
    export const setGeolocationTool: ToolCallback = async (args: {
      latitude: number;
      longitude: number;
      altitude?: number;
    }): Promise<CallToolResult> => {
      try {
        const browser = getBrowser();
        const { latitude, longitude, altitude } = args;
    
        await browser.setGeoLocation({ latitude, longitude, altitude });
    
        return {
          content: [
            {
              type: 'text',
              text: `Geolocation set to:\n  Latitude: ${latitude}\n  Longitude: ${longitude}${altitude ? `\n  Altitude: ${altitude}m` : ''}`,
            },
          ],
        };
      } catch (e) {
        return {
          isError: true,
          content: [{ type: 'text', text: `Error setting geolocation: ${e}` }],
        };
      }
    };
  • The `setGeolocationToolDefinition` object defining the tool's name ('set_geolocation'), description, and input schema (latitude, longitude, optional altitude) using Zod validation.
    export const setGeolocationToolDefinition: ToolDefinition = {
      name: 'set_geolocation',
      description: 'Overrides GPS coordinates for the session. Affects navigator.geolocation in browsers and location services on mobile. Location permissions must already be granted to the app.',
      annotations: { title: 'Set Geolocation', destructiveHint: false, idempotentHint: true },
      inputSchema: {
        latitude: z.number().min(-90).max(90).describe('Latitude coordinate'),
        longitude: z.number().min(-180).max(180).describe('Longitude coordinate'),
        altitude: z.number().optional().describe('Altitude in meters (optional)'),
      },
    };
  • src/server.ts:148-148 (registration)
    Registration of the `set_geolocation` tool in the MCP server via `registerTool(setGeolocationToolDefinition, setGeolocationTool)`.
    registerTool(setGeolocationToolDefinition, setGeolocationTool);
  • The `getBrowser()` helper function that retrieves the current active WebdriverIO browser instance from the session state, used by the tool handler.
    export function getBrowser(): WebdriverIO.Browser {
      const browser = state.browsers.get(state.currentSession);
      if (!browser) {
        throw new Error('No active browser session');
      }
      return browser;
    }
Behavior4/5

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

Discloses that location overrides affect browser and mobile services, and that permissions are needed. Annotations already indicate idempotent and non-destructive nature; the description adds session scope and effect context.

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

Conciseness5/5

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

Two sentences, no redundant words. Front-loaded with action and effect, then adds prerequisite. Highly efficient.

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

Completeness4/5

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

For a simple tool with annotations, the description covers purpose, effect, and prerequisite. Could mention session-scope limitation but not essential for agent use.

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

Parameters3/5

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

Input schema has 100% coverage with descriptions for all three parameters. Description adds minimal new meaning beyond the schema, so baseline 3 is appropriate.

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

Purpose5/5

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

Description clearly states the tool overrides GPS coordinates for the session, affecting navigator.geolocation and location services. This is a specific verb+resource, and no sibling tool covers geolocation, so differentiation is clear.

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

Usage Guidelines4/5

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

Provides explicit prerequisite that location permissions must be granted. However, it does not mention when to use this tool over alternatives, though no direct alternatives exist.

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/webdriverio/mcp'

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