# User-Agent Parser MCP

> User-Agent Parser takes raw HTTP User-Agent strings from server logs and converts them into structured JSON objects. It extracts the exact Browser, OS, and Device data points—stopping your AI agent from guessing specs when it reads messy log files.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Tags:** user-agent, log-analysis, device-detection, browser-identification, it-support, data-parsing

## Description

You gotta deal with server logs or firewall reports, right? You see those User-Agent strings—they look like a mess. They’re just raw text: `Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15`. If your agent reads that string without help, it'll guess, and those guesses are usually wrong.

The User-Agent Parser fixes that mess. It’s built around the `parse_ua` tool. This function takes any raw User-Agent string you feed it and spits out clean, structured JSON. It stops your AI client from having to play detective with gibberish headers.

When you call `parse_ua`, you pass in that messy string. The server then surgically decodes the data. You get back an exact JSON object detailing three key things: the client's browser, the operating system (OS), and the device platform. It prevents your agent from making assumptions about specs when it reads logs.

Think about what you do with that clean data. Instead of vague guesses, you're working with verified facts. The JSON output cleanly separates the browser version, the precise OS name, and the physical device type. This makes debugging platform-specific bugs accurate because your agent isn’t relying on guesswork; it’s using structured reality.

The parser handles all that messy HTTP header data. It recognizes patterns usually hidden in plain sight—the differences between desktop clients, mobile apps, and specific operating system builds. You pass the raw string, and you get back machine-readable clarity.

It’s all about precision here. We're talking about reliable extraction of client specifications directly from logs. The tool doesn't just read the string; it interprets it using industry standards to identify what's actually running on the user's end. It separates the browser engine data from the underlying OS kernel data, giving you a complete picture.

When your agent needs to know if a specific feature works only on iOS 16 or Mac OS X, this tool provides that certainty. You don't get 'iOS-like'; you get the actual version number. You don't get 'mobile device'; you get the platform and the model context.

The process is simple: Pass any raw User-Agent string to `parse_ua`. It returns a standardized JSON structure. This means every piece of data—the browser name, its specific version, the OS family it runs on, and the underlying hardware type—is in labeled fields your agent can use immediately.

If you’re building an application that analyzes user traffic or diagnoses client-side issues, this is non-negotiable. The messy logs used to cripple analysis by forcing developers to write complex regex just to extract a simple version number. Now, your AI client handles the parsing overhead for you.

It takes raw data—the ugly strings found in `Referer` or `User-Agent` headers—and transforms it into actionable JSON records. You get the browser name (Chrome, Safari, Edge), the OS detected (Windows NT 10.0, iPhone OS), and the device platform type (Mobile, Desktop). Each data point is isolated and perfectly formatted.

The mechanism ensures that even complex strings involving multiple operating systems or emulated environments are broken down correctly. It knows how to differentiate between an 'Engine' reported in the header versus the actual 'Browser Name'. This level of granularity saves you time when troubleshooting user-reported errors across diverse client bases. You get clean data points, ready for direct use by your agent.

It’s pure, structured metadata extraction. No interpretation needed from your end; just feed it the log line, and let `parse_ua` do its job of returning a comprehensive JSON object that details every relevant piece of client information.

## Tools

### parse_ua
Pass any raw User-Agent string and get back the exact structured JSON detailing the client's browser, OS, and device type. It prevents AI guesswork.

## Prompt Examples

**Prompt:** 
```
Parse this UA from the server log: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)`
```

**Response:** 
```
Parsed User-Agent: {"browser": {"name": "Chrome", "version": "114.0"}, "os": {"name": "Mac OS", "version": "10.15.7"}}
```

**Prompt:** 
```
Find out what device the user is on based on this string: `Mozilla/5.0 (iPhone; CPU iPhone OS 16_5)`
```

**Response:** 
```
Parsed User-Agent: Device is Mobile, OS is iOS 16.5.
```

**Prompt:** 
```
Extract the browser version from this Android User-Agent.
```

**Response:** 
```
Result: Browser is Chrome version 120 on Android 13.
```

## Capabilities

### Parse Client Specs from Logs
Pass a raw User-Agent string (from HTTP headers or server logs) to get the client's exact hardware and software identification.

### Generate Structured JSON Output
Receives standardized, machine-readable data that cleanly separates the browser version, operating system name, and device platform.

## Use Cases

### Debugging a mobile checkout failure
A user reports that the checkout page fails only on their iPhone. Instead of manually checking logs for patterns, your agent runs `parse_ua` using the provided User-Agent string. It immediately confirms the client is running iOS 16.5 and Chrome, allowing you to focus debugging efforts solely on that specific OS/Browser combination.

### Analyzing a spike in server errors
Your logs show a massive error spike originating from multiple IPs. Your agent runs `parse_ua` on several samples. The tool reveals that 90% of the traffic is coming from older versions of Firefox on Linux, pointing directly to an outdated compatibility issue you need to patch.

### Building a feature rollout tracker
You're rolling out a new UI element. Your agent uses `parse_ua` across historical log data streams. It can accurately count how many unique users are running Chrome 120 vs. Safari 605, ensuring your feature isn't broken for any major client segment.

### Forensic analysis of a compromised account
Security teams need to trace where the unauthorized access came from. By piping suspicious User-Agent strings into `parse_ua`, they gain immediate, structured confirmation that the malicious activity originated from a specific operating system and browser type.

## Benefits

- Eliminate guessing games. Instead of letting your AI agent guess the OS version, `parse_ua` gives you deterministic JSON output for accurate log analysis every time.
- Pinpoint bugs faster. When debugging a platform-specific issue, you feed the exact User-Agent string into `parse_ua`. You instantly know if it's an iOS bug or a Windows machine problem.
- Handle diverse logs. Whether the source is a firewall log, API gateway data, or web server access records, `parse_ua` standardizes the messy input into clean specs.
- Improve agent reliability. Your AI client doesn't have to rely on general knowledge; it uses `parse_ua` to get verified device and browser details before making a decision.
- Support multiple platforms. The tool accurately identifies everything from ancient Mac OS versions to modern Android builds, giving you full coverage.

## How It Works

The bottom line is: it turns unreadable log spam into structured, actionable data points.

1. Provide the MCP Server with the messy User-Agent string found in your log file.
2. The server uses deterministic parsing logic to break down the raw string into component parts (OS, Browser, Device).
3. You get back a clean JSON object that contains verified data points for immediate use by your AI agent.

## Frequently Asked Questions

**Does User-Agent Parser support all operating systems?**
Yes. The parser uses industry standards to decode a wide range of OSs and devices, from older Mac versions to modern mobile platforms.

**What format does parse_ua return the data in?**
It returns clean, structured JSON. This is designed for immediate consumption by your AI client, making it easy to read programmatically.

**Can I use User-Agent Parser on non-HTTP logs?**
The tool expects a raw HTTP User-Agent string. You must extract the specific header value from your log before passing it to `parse_ua`.

**Is the data from parse_ua more reliable than what an LLM guesses?**
Absolutely. It uses deterministic parsing logic, which is far more reliable than generalized knowledge or guesswork by a language model.

**What happens if I pass `parse_ua` a completely corrupted or malformed User-Agent string?**
The tool handles bad inputs gracefully. Instead of failing, it returns an error object within the structured JSON output. This allows your agent to detect the failure and adjust its logic without crashing.

**Is the data processed by User-Agent Parser secure regarding my sensitive log files?**
Yes, the parsing is designed with privacy in mind. The server processes the raw strings you send and doesn't store them or retain any access to your original log data after the tool call completes.

**How fast can I expect `parse_ua` to run when analyzing a large batch of logs?**
It runs quickly because it uses deterministic parsing logic. This approach is efficient for processing high volumes of strings, meaning you get accurate results without significant performance slowdowns.

**Does the User-Agent Parser support non-standard or proprietary client headers?**
It supports industry-standard formats using `ua-parser-js`. However, if a header is completely custom or highly corrupted outside standard parsing rules, you might need to pre-clean the data before passing it to the tool.

**Is it accurate for mobile devices?**
Yes, it accurately identifies iOS, Android versions, and specific phone models.

**Why not use a regex in the LLM prompt?**
User-Agents change daily and are heavily obfuscated. A hardcoded regex will fail on newer devices.

**Does it identify bots?**
Yes, the parser can identify common web crawlers, scrapers, and search engine bots (like Googlebot).