# Moesif API Analytics MCP

> Moesif lets you connect your AI client directly to deep API analytics, giving you instant visibility into all your application traffic. Log every request and response, track user profiles with custom metadata, and run complex historical queries using powerful filters—all without leaving your conversation window.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Tags:** api-monitoring, api-analytics, elasticsearch-dsl, user-tracking, debugging

## Description

Need to know what's happening with your backend APIs? Moesif connects your AI client to a live feed of your entire API ecosystem. You get deep visibility into every request and response that hits your service, allowing you to monitor traffic in real time or dig into months of historical data. This MCP lets you record single or batch requests while also managing user and company profiles by attaching custom metadata—like MRR or plan type—directly to the usage logs. Need to find out why a specific customer hit an error rate limit? You can search through massive amounts of event data using complex filters, pinpointing exactly when and where it went wrong. If you're looking for a way to debug API calls or track feature adoption without building custom dashboards, this is it. Because Vinkius hosts this MCP in the catalog, you connect your preferred AI client once and gain access to powerful debugging tools like this.

## Tools

### count_events
Calculates and returns the total number of recorded API events that match specific filtering criteria.

### log_event
Records a single API call, including its full request and response body, into Moesif for monitoring.

### log_events_batch
Sends multiple recorded API calls in one go, efficiently populating the event log with bulk data.

### search_events
Searches through historical events using advanced filtering and sorting to find specific incidents or patterns over time.

### update_company
Updates a company's profile record in Moesif, allowing you to attach new metadata like MRR or plan type.

### update_user
Updates an individual user’s profile record with custom details, linking usage data to specific customer segments.

## Prompt Examples

**Prompt:** 
```
Count how many API calls resulted in a 401 Unauthorized error in the last 7 days.
```

**Response:** 
```
I've queried Moesif using `count_events`. There were 142 instances of 401 Unauthorized errors between -7d and now.
```

**Prompt:** 
```
Update user 'user_123' in Moesif with email 'dev@example.com' and plan 'Enterprise'.
```

**Response:** 
```
I've updated the profile for 'user_123' using `update_user`. The metadata now includes the new email and plan details.
```

**Prompt:** 
```
Search for the last 5 API requests made to the '/v1/payments' endpoint.
```

**Response:** 
```
Using `search_events`, I found the 5 most recent requests to '/v1/payments'. Most were successful (200 OK), but one returned a 402 Payment Required. Would you like to see the body of that specific event?
```

## Capabilities

### Track User and Company Profiles
Update or create records for specific users or companies by adding custom metadata, linking API usage directly to customer accounts.

### Log Single Events
Record one immediate API request and its full response payload into the system's event log for quick inspection.

### Batch Log Multiple Events
Send a large group of recorded API calls at once to populate the event logs efficiently.

### Search Historical Data
Query millions of past events using powerful filtering and sorting rules, letting you pinpoint rare or specific incidents across time.

### Count Filtered Occurrences
Determine the exact number of recorded events that match a specified set of criteria (e.g., all 404 errors in the last week).

## Use Cases

### The Payments Bug Mystery
A customer reports that payments fail intermittently. Instead of asking the client for logs, you ask your agent to search historical data using `search_events` for 'payment endpoint' and filter by HTTP 402 errors. You immediately find a pattern showing the failure only happens when the payload is over 5MB.

### Checking Rate Limit Abuse
The Ops team notices unexpected spikes in API calls from one account. They use `count_events` to count all requests originating from that specific user ID within a two-hour window, confirming they hit the defined rate limit.

### Onboarding New Enterprise Clients
The CSM needs to verify if an enterprise client's paid features are actually being used. They run `update_company` and link their 'Enterprise Plan' metadata, then use `search_events` to confirm usage of the premium endpoints.

### Debugging a Broken Workflow
A developer finds a broken internal workflow. Rather than manually checking multiple logs, they tell the agent to `log_event` for the entire sequence of calls, creating one clean debug thread for review.

## Benefits

- Pinpoint errors immediately. If a user reports an issue, you can use `search_events` to pull up the exact failing payload and pinpoint if it was a bad request or an API bug.
- Stop guessing on feature adoption. Use `update_user` and `update_company` alongside logging to link specific usage spikes (like increased payments) directly to known customer segments.
- Audit traffic in minutes. Instead of running complex queries in a dedicated dashboard, use `count_events` or `search_events` to count how many times a rate limit was hit last month.
- Save time during debugging. When an API call fails, simply run `log_event` and get the full context—request headers, payload, and error code—right in your conversation.
- Track usage at scale. With `log_events_batch`, you can feed data from multiple endpoints simultaneously, giving a comprehensive view of how different services interact.

## How It Works

The bottom line is that it brings complex API monitoring tools right into your conversation flow, so you don't have to jump between dashboards.

1. First, subscribe to this MCP and provide your Moesif Application ID and Management API Key.
2. Next, tell your AI agent what you need to check—for example, 'Count all 401 errors from last week.'
3. The system runs the query against the live logs and returns a precise count or list of events directly in your chat window.

## Frequently Asked Questions

**How does Moesif use `search_events`?**
Moesif uses advanced filtering to let you search through historical logs. You can filter by specific status codes, endpoints, or time ranges to narrow down millions of records quickly.

**Can I link API usage to a customer's revenue with Moesif?**
Yes. By using `update_company` and attaching metadata like MRR (Monthly Recurring Revenue), you can tie every event log back to the account’s monetary value for better reporting.

**Is it hard to log multiple events with Moesif?**
No. You can use `log_events_batch` to send many calls at once, which is much faster than logging them one by one using `log_event`.

**What if I need to check errors from last month with Moesif?**
You use the filtering capabilities of `search_events`. You simply specify a time range (like 'last 30 days') in your prompt, and it handles the date logic for you.

**Does Moesif track user details?**
Yes. The MCP allows you to use `update_user` to store custom metadata (like email or plan type) against individual users, making them searchable in your logs.