lcontext
Product analytics for AI coding agents. Understand how users navigate your app — where they engage, hesitate, and drop off — then connect be
Open source Repository Open in the app JSON README (API)
About
Product analytics for AI coding agents. Understand how users navigate your app — where they engage, hesitate, and drop off — then connect behavioral insights directly to code changes.
Details
- Kind
- Plugins
- Topic
- Marketing & analytics
- Publisher
- lcontext
- Origin
- marketplace
- Category
- ferramentas
- Stars
- 2
- Last push
- 2026-05-09T11:17:19Z
- Repository state
- ativo
- Language
- JavaScript
- License
- MIT
- Added
- 2026-08-30 01:48:58
- Updated
- 2026-08-30 01:48:58
- Origin id
lcontext/lcontext/lcontext
README
# Lcontext
[](https://opensource.org/licenses/MIT)
[](https://www.npmjs.com/package/lcontext-mcp)
The product analytics agent for your AI coding tools. Lcontext studies how users navigate your product, where they engage, hesitate, and drop off, and delivers behavioral context via MCP.
**Works with:** Claude Code, Claude Desktop, Cursor, Windsurf, Cline, and any MCP-compatible AI coding tool.
## Quick Setup
The fastest way to get started -- sign up, configure your agent, and get your tracking script in one command:
```bash
npx lcontext-mcp@latest setup
```
Or using the standalone installer (no Node required):
```bash
curl -fsSL https://lcontext.com/api/cli/install | bash
```
Both will open your browser to sign up (or log in), configure your coding agent, and print the tracking script to add to your app.
### Manual Setup
If you prefer to set things up manually:
1. Create a free account at [lcontext.com](https://lcontext.com)
2. Add the tracking script to your app (find your tag in the dashboard):
```html
<script src="https://lcontext.com/it.js?iTag=YOUR_SITE_TAG" defer></script>
```
3. Connect your coding agent (see below)
<details>
<summary><b>What the tracker collects</b></summary>
- **Page views** - URL, title, referrer
- **Clicks** - Buttons, links, interactive elements (label text only, no personal data)
- **Form submissions** - Form metadata (no field values captured)
- **Scroll depth** - How far users scroll (25% increments)
- **Device metadata** - Screen size, browser language, viewport
**Privacy-focused:** No passwords, input values, or personal information collected. ~4KB minified.
</details>
<details>
<summary><b>Advanced: Link to your user IDs</b></summary>
Associate the anonymous visitor with your application's user ID:
```javascript
lcontext('setProfileId', 'user-123');
```
Track custom events:
```javascript
lcontext('trackEvent', 'purchase', { productId: 'abc', amount: 99.99 });
```
</details>
### Agent Configuration
<details open>
<summary><b>Claude Code / Claude Desktop</b></summary>
```bash
claude mcp add lcontext -s user -e LCONTEXT_API_KEY=your-api-key -- npx -y lcontext-mcp@latest
```
Then restart Claude.
</details>
<details>
<summary><b>Cursor</b></summary>
**Option 1: One-Click Install**
[Install Lcontext in Cursor](https://cursor.com/install-mcp?name=lcontext&config=eyJjb21tYW5kIjoibGNvbnRleHQiLCJlbnYiOnsiTENPTlRFWFRfQVBJX0tFWSI6InlvdXItYXBpLWtleS1oZXJlIn19)
After clicking, replace `your-api-key-here` with your actual API key in Cursor settings.
**Option 2: Manual Setup**
First, install the binary:
```bash
curl -fsSL https://lcontext.com/api/cli/install | bash
```
Then open Cursor Settings (`Cmd/Ctrl + Shift + J`), and add the server:
```json
{
"lcontext": {
"command": "lcontext",
"env": {
"LCONTEXT_API_KEY": "your-api-key-here"
}
}
}
```
</details>
<details>
<summary><b>Windsurf</b></summary>
First, install the binary:
```bash
curl -fsSL https://lcontext.com/api/cli/install | bash
```
Then open Windsurf and navigate to **Cascade > Configure > MCP Servers** (or click the hammer icon), then click "Add Server" and select "Add custom server". Add this configuration:
```json
{
"lcontext": {
"command": "lcontext",
"env": {
"LCONTEXT_API_KEY": "your-api-key-here"
}
}
}
```
</details>
<details>
<summary><b>Cline (VS Code Extension)</b></summary>
First, install the binary:
```bash
curl -fsSL https://lcontext.com/api/cli/install | bash
```
Then in VS Code with Cline installed:
1. Open Cline settings (click gear icon in Cline panel)
2. Navigate to **MCP Servers** section
3. Add a new server:
```json
{
"lcontext": {
"command": "lcontext",
"env": {
"LCONTEXT_API_KEY": "your-api-key-here"
}
}
}
```
</details>
<details>
<summary><b>Other MCP-Compatible Tools</b></summary>
First, install the binary:
```bash
curl -fsSL https://lcontext.com/api/cli/install | bash
```
Lcontext works with any tool that supports the Model Context Protocol. The general configuration pattern is:
- **Command:** `lcontext`
- **Environment Variable:** `LCONTEXT_API_KEY=your-api-key-here`
Refer to your tool's documentation for MCP server configuration.
</details>
## Alternative Installation Methods
The install script used above (`curl -fsSL https://lcontext.com/api/cli/install | bash`) is the recommended approach. If you need an alternative:
<details>
<summary><b>Manual Download</b></summary>
Download the binary for your platform from the [latest release](https://github.com/Lcontext/Lcontext/releases/latest):
| Platform | Binary |
|----------|--------|
| macOS (Apple Silicon) | `lcontext-macos-arm64` |
| macOS (Intel) | `lcontext-macos-x64` |
| Linux (x64) | `lcontext-linux-x64` |
| Linux (ARM64) | `lcontext-linux-arm64` |
| Windows (x64) | `lcontext-windows-x64.exe` |
</details>
<details>
<summary><b>Via npm</b></summary>
If you have Node.js installed:
```bash
npm install -g lcontext-mcp
```
</details>
<details>
<summary><b>From Source</b></summary>
```bash
git clone https://github.com/lcontext/lcontext.git
cd lcontext
npm install
npm run build
```
</details>
## Available Tools
### `get_page_context`
Get comprehensive analytics context for a page including stats, visitor metrics, Web Vitals (LCP, FCP, FID, CLS), and all interactive elements with their engagement data.
**Parameters:**
- `path` (required): The page path (e.g., `/products`, `/checkout`)
- `startDate` (optional): Start date for stats (ISO format)
- `endDate` (optional): End date for stats (ISO format)
- `periodType` (optional): `day` or `week` (default: `day`)
**Example:**
```
Get the analytics context for the /checkout page for the last 7 days
```
### `list_pages`
List all tracked pages for your app.
**Parameters:**
- `limit` (optional): Maximum pages to return (default: 50, max: 200)
- `search` (optional): Filter by path (e.g., `/product`)
**Example:**
```
What pages are being tracked on my app?
```
### `get_element_context`
Get detailed analytics for a specific interactive element by its label or ID.
**Parameters:**
- `elementLabel` (optional): Element's label text or aria-label
- `elementId` (optional): Element's HTML ID
- `pagePath` (optional): Filter by page path
**Example:**
```
Show me analytics for the "Add to Cart" button
```
### `get_app_context`
Get application-wide analytics including sessions, visitors, page views, engagement metrics, device breakdown (mobile/tablet/desktop), top browsers, top OS, Web Vitals (LCP, FCP, FID, CLS), and AI-generated insights.
**Parameters:**
- `periodType` (optional): `day` or `week` (default: `day`)
- `limit` (optional): Number of periods to return (default: 7, max: 30)
**Example:**
```
Give me an overview of my app's behavioral analytics for the last week
```
### `get_visitors`
Get a list of visitors with AI-generated profiles, interests, engagement trends, segment assignments, device info (type, browser, OS), and location (city, region, country).
**Parameters:**
- `limit` (optional): Maximum visitors to return (default: 20, max: 100)
- `offset` (optional): Offset for pagination
- `segmentId` (optional): Filter by segment ID
- `search` (optional): Search in visitor ID, title, summary, interests, goals, action, evidence
- `firstVisitAfter` (optional): Filter by first visit date (ISO format)
- `firstVisitBefore` (optional): Filter by first visit date (ISO format)
- `lastVisitAfter` (optional): Filter by last visit date (ISO format)
- `lastVisitBefore` (optional): Filter by last visit date (ISO format)
- `engagementTrend` (optional): `increasing`, `stable`, or `decreasing`
- `overallSentiment` (optional): `positive`, `negative`, `neutral`, or `mixed`
**Example:**
```
Show me visitors with increasing engagement trend
```
### `get_visitor_detail`
Get detailed profile and recent sessions for a specific visitor, including device info (type, browser, OS) and location.
**Parameters:**
- `visitorId` (required): The visitor's unique identifier
**Example:**
```
Get the full profile for visitor abc123
```
### `get_sessions`
Get a list of user sessions with AI-generated summaries, titles, sentiment analysis, and device type.
**Parameters:**
- `limit` (optional): Maximum sessions to return (default: 20, max: 100)
- `offset` (optional): Offset for pagination
- `visitorId` (optional): Filter by visitor ID
- `sentiment` (optional): `positive`, `negative`, or `neutral`
- `startDate` (optional): Start date for filtering (ISO format)
- `endDate` (optional): End date for filtering (ISO format)
- `search` (optional): Search in session title and description
- `minDuration` (optional): Minimum session duration in seconds
- `maxDuration` (optional): Maximum session duration in seconds
- `minEventsCount` (optional): Minimum number of events
- `maxEventsCount` (optional): Maximum number of events
- `pagePath` (optional): Filter sessions that visited a specific page path
**Example:**
```
Show me negative sentiment sessions from the last 24 hours
```
### `get_session_detail`
Get detailed information about a specific session including full event timeline, visitor context, device type, and location (city, region, country).
**Parameters:**
- `sessionId` (required): The session's numeric ID
**Example:**
```
Show me the details of session 12345
```
### `get_user_flows`
Get automatically detected user journey patterns showing how users navigate through the application. Each flow represents a common page sequence with engagement metrics and drop-off points.
**Parameters:**
- `limit` (optional): Maximum flows to return (default: 10, max: 50)
- `category` (optional): Filter by category: `conversion`, `exploration`, `onboarding`, `support`, `engagement`, `other`
- `minSessions` (optional): Minimum session count for a flow to be included
- `periodType` (optional): `day` for daily flows, `week` for weekly aggregated flows
**Example:**
```
Show me the most common user journeys on my app
```
### `get_analysis`
Get a pre-computed daily or weekly analysis report. Contains problem areas, funnel health, session findings, and prioritized recommendations — all referencing specific page paths, element IDs, and session IDs you can investigate with other tools.
**Parameters:**
- `periodType` (optional): `day` for daily report (default), `week` for weekly report
- `date` (optional): ISO date string for the period start (e.g., `2026-02-23`). Defaults to most recent completed analysis.
**Example:**
```
Get the latest daily analysis for my app
```
## Prompts
### `analytics-guide`
A comprehensive guide for analyzing user behavior data with Lcontext tools. Includes step-by-step analysis workflows, decision trees for common scenarios (e.g., "this page isn't converting", "performance feels slow"), and a reference table connecting analytics findings to code investigations.
AI agents can request this prompt to get expert-level guidance on how to use the tools effectively.
## Updating
The binary includes a self-update command:
```bash
lcontext --update
```
## Environment Variables
| Variable | Description | Required |
|----------|-------------|----------|
| `LCONTEXT_API_KEY` | Your Lcontext API key | Yes |
| `LCONTEXT_API_URL` | API base URL (default: https://lcontext.com) | No |
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and build instructions.
## License
MIT - see [LICENSE](LICENSE) for details.