Skip to main content
Glama
IPGeolocation

IP Geolocation MCP Server

parse_user_agent

Extract browser, device, OS, and engine details from a user-agent string to identify client software and hardware specifications.

Instructions

Parse an explicit user-agent string via POST /v3/user-agent. Paid only. Cost: 1 credit. Returns browser, device, OS, and engine details.

This MCP tool parses only the uaString you pass. It does not infer a caller user-agent from the MCP transport. For multiple strings, use bulk_parse_user_agent.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uaStringYesThe user-agent string to parse (e.g. Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36).
force_refreshNoDefault false. Leave unset unless the user asks to refresh or rerun.

Implementation Reference

  • The handler for the 'parse_user_agent' tool, which handles user-agent parsing with caching and error handling.
    async (params) => {
      try {
        const cacheKey = buildUserAgentCacheKey(params.uaString);
        const cached = params.force_refresh ? undefined : getCachedValue(cacheKey);
        const result =
          cached ??
          (await parseUserAgent({
            uaString: params.uaString,
          }));
        if (cached === undefined) {
          setCachedValue(cacheKey, result);
        }
        return {
          content: [
            { type: "text" as const, text: formatToolResult(result) },
          ],
        };
      } catch (error) {
        return errorToolResponse(error);
      }
    }
  • Registration of the 'parse_user_agent' tool in the MCP server.
      server.registerTool(
        "parse_user_agent",
        {
          title: "User-Agent Parser",
          annotations: {
            readOnlyHint: true,
          },
          description: `Parse an explicit user-agent string via POST /v3/user-agent. Paid only. Cost: 1 credit. Returns browser, device, OS, and engine details.
    
    This MCP tool parses only the uaString you pass. It does not infer a caller user-agent from the MCP transport. For multiple strings, use bulk_parse_user_agent.`,
          inputSchema: {
            uaString: z
              .string()
              .describe(
                "The user-agent string to parse (e.g. Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36)."
              ),
            force_refresh: z
              .boolean()
              .optional()
              .describe("Default false. Leave unset unless the user asks to refresh or rerun."),
          },
        },
  • The API client helper function that performs the actual network request to parse a user-agent.
    export async function parseUserAgent(params: {
      uaString: string;
    }): Promise<unknown> {
      return request(
        "/v3/user-agent",
        {},
        { method: "POST", body: { uaString: params.uaString } }
      );
    }

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/IPGeolocation/ipgeolocation-io-mcp'

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