# Use okdata in Cursor: social data through MCP

> Add okdata to Cursor's mcp.json so the agent can look up endpoints, check prices and fetch real posts from 10 platforms while it writes your code.

Canonical page: https://okdata.online/integrations/cursor/

After this page, the agent in Cursor can reach real social data while it builds something for you. A common case: you are making an internal page that shows what people post about your brand on X. Instead of inventing sample data, the agent reads the endpoint's fields with `describe`, fetches one real page, saves it as a fixture and writes the types and the component against it. You see every paid step before it runs.

## Before you start

- Cursor installed and signed in.
- An API key from okdata, starting with `okd_`. New keys come with $0.10 of credit. The [quickstart](/docs/quickstart/) explains how to get one.
- The key in the `OKDATA_API_KEY` environment variable. On a Mac, add this to `~/.zshrc` (Linux: `~/.bashrc`; Windows: set a user environment variable in System Settings):

```bash
export OKDATA_API_KEY="okd_..."
```

Then quit Cursor completely and open it again, so it picks the variable up.

## Add the server

Cursor reads MCP servers from two files: `~/.cursor/mcp.json` in your home folder applies to every project, and `.cursor/mcp.json` inside a project applies to that project only. Add this to either one:

```json
{
  "mcpServers": {
    "okdata": {
      "url": "https://api.okdata.online/mcp",
      "headers": { "Authorization": "Bearer ${env:OKDATA_API_KEY}" }
    }
  }
}
```

`${env:OKDATA_API_KEY}` tells Cursor to fill in the variable when it connects, so the file never contains the key. That also makes the project version safe to commit; teammates set their own variable. If the file already lists other servers, add the `"okdata"` block inside the existing `mcpServers`.

## Check that it worked

Open **Customize** in the sidebar. `okdata` should be listed and switched on, with four tools: `find`, `describe`, `call` and `account`. If it shows an error instead, see the last section.

In the Agent chat, ask: "What is my okdata balance?" A number in the answer means the key arrived. It costs nothing.

## A first prompt to try

```text
Use okdata. Describe the X post search endpoint and tell me its price.
Then fetch one page for "our-brand-name", save the raw items to
fixtures/x-posts.json, and write a TypeScript type for one item based on it.
```

By default Cursor asks before it runs an MCP tool. Click the arrow next to a tool name to see the exact arguments before you approve. Once you trust the free tools, you can allow `find` and `describe` to run without asking and keep `call` on manual approval.

## What it costs

`find`, `describe` and `account` are free. Each `call` costs the endpoint's price: one page of X post search is $0.006, so the prompt above costs $0.006. A page of [Xiaohongshu note search](/apis/xiaohongshu/notes/search/) is $0.02. Failed calls are free.

When an agent loops through pages it can add up. Put the limit in the prompt: "one page only" or "stop after three pages and ask me".

## When something goes wrong

- **`unauthorized` (401).** The header went out without a key. Usually Cursor was already open when you set the variable: quit it fully and reopen. Also check the spelling `${env:OKDATA_API_KEY}`, with `env:` in front.
- **`insufficient_balance` (402).** Not enough balance for the call; nothing was charged. Top up and run it again. Prices are on the [pricing page](/pricing/).
- **`rate_limited` (429).** Too many calls in a short time. The error has `retry_after_seconds`; wait that long and repeat the call. No charge.
- **The server shows an error or no tools.** Check the JSON (a missing comma is the usual culprit) and that the URL ends in `/mcp`. Opening the URL in a browser shows "Method not allowed", which is expected: the server only answers MCP requests. Toggle the server off and on in **Customize** to reconnect.

## Read next

- [The MCP server](/mcp/): the four tools and what to tell the agent.
- [X post search](/apis/x/posts/search/): query syntax, fields and price.
