> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xquik.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect AI Agents via MCP

> Connect AI agents to Xquik via the Model Context Protocol

<blockquote className="agent-llms-directive">
  For the complete documentation index, see <a href="/llms.txt">llms.txt</a>.
</blockquote>

Xquik runs a [Model Context Protocol](https://modelcontextprotocol.io) server that lets AI agents and development tools interact with your Xquik account programmatically.

<Note>
  This page covers the API MCP server at `https://xquik.com/mcp` for
  authenticated account actions. For read-only documentation search, use the
  [Docs MCP server](/mcp/docs-mcp) at `https://docs.xquik.com/mcp`.
</Note>

## Connection

<CardGroup cols={3}>
  <Card title="Protocol" icon="route">
    HTTP with StreamableHTTP transport for MCP clients.
  </Card>

  <Card title="Endpoint" icon="plug">
    Connect clients to `https://xquik.com/mcp`.
  </Card>

  <Card title="Authentication" icon="key-round">
    Use an API key in `x-api-key` or OAuth 2.1 Bearer tokens.
  </Card>
</CardGroup>

MCP server discovery metadata is available at:

```text theme={null}
https://xquik.com/.well-known/mcp.json
```

`GET` and `POST` requests to `/.well-known/mcp.json` return the MCP registry
server card JSON directly. `GET /.well-known/mcp/server-card.json` returns the
same card for clients that read the nested server-card path. OAuth-aware clients
can also read `GET /.well-known/oauth-protected-resource/.well-known/mcp.json`
for protected-resource metadata for `https://xquik.com/mcp`.

Registry-card clients receive a `streamable-http` remote for
`https://xquik.com/mcp` with `Authorization: Bearer {XQUIK_API_KEY}`. Create
the key from `https://dashboard.xquik.com/en/account`; direct client examples
below can still send the same key with `x-api-key` when the client supports
custom headers.

Agent discovery metadata is also available at
`https://xquik.com/.well-known/agent-index.json`. That index lists
`com.xquik/mcp`, `https://xquik.com/mcp`, `https://xquik.com/.well-known/mcp.json`,
the OAuth authorization metadata, the protected-resource metadata, and
`https://xquik.com/auth.md`. The `auth.md` file is Markdown for agents that need
the supported anonymous OAuth client registration path before requesting
`mcp:tools`.

Unauthenticated requests to `https://xquik.com/mcp` return `401` with a
`WWW-Authenticate: Bearer` challenge. The challenge includes
`resource_metadata="https://xquik.com/.well-known/oauth-protected-resource/mcp"`,
`scope="mcp:tools"`, `error="invalid_token"`, and
`error_description="Missing or invalid access token"`. The JSON body is
`{ "error": "Authentication required" }`. OAuth-capable clients use that
challenge to discover the authorization metadata. API-key clients should send
`x-api-key` on the first request.

## Authentication

The MCP server supports 2 authentication methods:

* **API key** (`x-api-key` header): Used by Claude Code, Cursor, VS Code, Windsurf, Codex CLI, OpenCode, and Claude Desktop. Pass your key during the MCP handshake.
* **OAuth 2.1** (Bearer token): Used by Claude.ai (web) and ChatGPT Developer Mode. OAuth handles authentication automatically via browser login. No API key needed. See [OAuth 2.1 documentation](/oauth/overview) for the complete authorization flow, token lifetimes, and implementation details.

## How it works

The MCP server uses a **code-execution sandbox model** with 2 tools:

<CardGroup cols={2}>
  <Card title="explore" icon="search">
    Search the API spec. Read-only, no network calls, no credits. Requires MCP authentication to execute.
  </Card>

  <Card title="xquik" icon="terminal">
    Execute authenticated API calls. Cost follows the endpoint.
  </Card>
</CardGroup>

The AI agent writes async JavaScript arrow functions that run in a sandboxed environment. Auth is injected automatically.

### `explore` tool

Searches the in-memory API endpoint catalog. Free means no usage credits; the call still requires MCP authentication through an API key or OAuth Bearer token. The sandbox provides:

```typescript theme={null}
interface EndpointInfo {
  method: string;
  path: string;
  summary: string;
  category: string; // account, composition, credits, extraction, media, monitoring, support, twitter, x-accounts, x-write
  free: boolean;
  parameters?: Array<{ name: string; in: 'query' | 'path' | 'body'; required: boolean; type: string; description: string }>;
  responseShape?: string;
}

declare const spec: { endpoints: EndpointInfo[] };
```

### `xquik` tool

Executes API calls. The sandbox provides:

```typescript theme={null}
declare const xquik: {
  request(path: string, options?: {
    method?: string;  // default: 'GET'
    body?: unknown;
    query?: Record<string, string>;
  }): Promise<unknown>;
};
declare const spec: { endpoints: EndpointInfo[] };
```

The agent writes code like `async () => xquik.request('/api/v1/radar')` and the server executes it with auth injected.

## MCP vs REST API

Both the MCP server and REST API connect to the same backend, use the same data, and share the same billing.

<CardGroup cols={2}>
  <Card title="MCP Server" icon="terminal">
    Best for AI agents, IDE integrations, and natural language workflows. Connect to `https://xquik.com/mcp` with `x-api-key` or OAuth 2.1 Bearer auth. Agents use 2 tools: `explore` for spec search and `xquik` for sandboxed API calls.
  </Card>

  <Card title="REST API" icon="route">
    Best for backend services, automation scripts, and direct programmatic access. Call `https://xquik.com/api/v1/*` with an `x-api-key` header. Use 120 individual operations and file download responses for extraction or draw exports.
  </Card>
</CardGroup>

**When to use MCP:** You're building an AI agent or working in an IDE (Claude Code, Cursor, VS Code, Windsurf) and want the agent to interact with X data through natural language.

**When to use REST:** You're building a backend service, automation pipeline, or need fine-grained control over API calls, pagination, and file exports.

<Tip>
  Start with [Claude.ai](https://claude.ai) for OAuth login or [Claude Code](#setup) for terminal setup.
</Tip>

## Setup

### Web and terminal clients

<Tabs>
  <Tab title="Claude.ai (Web)">
    Claude.ai supports MCP connectors natively via OAuth. Add Xquik as a connector from **Settings > Feature Preview > Integrations > Add More > Xquik**. The OAuth 2.1 flow handles authentication automatically. No API key needed.
  </Tab>

  <Tab title="Claude Desktop">
    Claude Desktop only supports stdio transport. Use the `mcp-remote` npm package as a bridge (requires [Node.js](https://nodejs.org)). Add to your `claude_desktop_config.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "xquik": {
          "command": "npx",
          "args": [
            "mcp-remote@latest",
            "https://xquik.com/mcp",
            "--header",
            "x-api-key:xq_YOUR_KEY_HERE"
          ]
        }
      }
    }
    ```
  </Tab>

  <Tab title="Claude Code">
    Add to your `.mcp.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "xquik": {
          "type": "http",
          "url": "https://xquik.com/mcp",
          "headers": {
            "x-api-key": "xq_YOUR_KEY_HERE"
          }
        }
      }
    }
    ```
  </Tab>

  <Tab title="Codex CLI">
    Add to `~/.codex/config.toml`:

    ```toml theme={null}
    [mcp_servers.xquik]
    url = "https://xquik.com/mcp"
    http_headers = { "x-api-key" = "xq_YOUR_KEY_HERE" }
    ```
  </Tab>
</Tabs>

### Editor clients

<Tabs>
  <Tab title="Cursor">
    Add to `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (project):

    ```json theme={null}
    {
      "mcpServers": {
        "xquik": {
          "url": "https://xquik.com/mcp",
          "headers": {
            "x-api-key": "xq_YOUR_KEY_HERE"
          }
        }
      }
    }
    ```
  </Tab>

  <Tab title="VS Code">
    Add to `.vscode/mcp.json` (project) or use **MCP: Open User Configuration** (global):

    ```json theme={null}
    {
      "servers": {
        "xquik": {
          "type": "http",
          "url": "https://xquik.com/mcp",
          "headers": {
            "x-api-key": "xq_YOUR_KEY_HERE"
          }
        }
      }
    }
    ```
  </Tab>

  <Tab title="Windsurf">
    Add to `~/.codeium/windsurf/mcp_config.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "xquik": {
          "serverUrl": "https://xquik.com/mcp",
          "headers": {
            "x-api-key": "xq_YOUR_KEY_HERE"
          }
        }
      }
    }
    ```
  </Tab>

  <Tab title="OpenCode">
    Add to `opencode.json`:

    ```json theme={null}
    {
      "mcp": {
        "xquik": {
          "type": "remote",
          "url": "https://xquik.com/mcp",
          "headers": {
            "x-api-key": "xq_YOUR_KEY_HERE"
          }
        }
      }
    }
    ```
  </Tab>
</Tabs>

### ChatGPT

3 ways to connect ChatGPT to Xquik:

**Option 1: Custom GPT (Recommended)**

Create a Custom GPT and add Xquik as an Action using the OpenAPI schema at `https://xquik.com/openapi.json`. Set the API key under Authentication > API Key > Header `x-api-key`.

**Option 2: Agents SDK**

Use the [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/mcp/) for programmatic access:

```python theme={null}
from agents.mcp import MCPServerStreamableHttp

async with MCPServerStreamableHttp(
    url="https://xquik.com/mcp",
    headers={"x-api-key": "xq_YOUR_KEY_HERE"},
    params={},
) as xquik:
    # use xquik as a tool provider
    pass
```

**Option 3: Developer Mode**

ChatGPT Developer Mode supports MCP connectors via OAuth. Add Xquik from **Settings > Developer Mode > MCP Tools > Add**. Enter `https://xquik.com/mcp` as the endpoint. OAuth handles authentication automatically.

## Example prompts

Once connected, you can ask your AI agent things like:

**Monitoring & Events**

* Start watching @elonmusk for new tweets and replies.
* List the accounts I am currently monitoring.
* Show monitored account activity from today.
* Replay stored events for monitor mon\_123 using the last next\_cursor as after.
* Stop tracking @elonmusk.

**Search & Lookup**

* Search recent X posts about TypeScript.
* Find recent tweets from @vercel.
* Read this tweet: [https://x.com/elonmusk/status/1893456789012345678](https://x.com/elonmusk/status/1893456789012345678)
* Get metrics for this tweet: [https://x.com/vercel/status/1893704267862470862](https://x.com/vercel/status/1893704267862470862)

**User Profiles & Follows**

* Get @xquikcom follower count.
* Read @openai profile bio.
* Check whether @elonmusk follows @SpaceX.
* Check whether @vercel and @nextjs follow each other.

**Trends**

* Show current X trends.
* Show top trending topics in the US.
* Check whether AI is trending today.

**Radar & News**

* Show current Radar trends.
* Show top developer trends today.
* Show fastest-growing startup trends.
* Get technology topics from the last 12 hours.
* Show popular knowledge topics right now.
* Show regional trends for Turkey.
* Find trending tech news and draft a tweet about one item.

**Extractions**

* Pull all replies to this tweet: [https://x.com/elonmusk/status/1893456789012345678](https://x.com/elonmusk/status/1893456789012345678)
* List users who retweeted this tweet: [https://x.com/vercel/status/1893704267862470862](https://x.com/vercel/status/1893704267862470862)
* Estimate the cost to extract all followers of @elonmusk.
* Get quote tweets for this post: [https://x.com/openai/status/1893456789012345678](https://x.com/openai/status/1893456789012345678)
* Extract the full thread for this tweet: [https://x.com/elonmusk/status/1893704267862470862](https://x.com/elonmusk/status/1893704267862470862)

**Giveaways**

* Pick 3 random winners from this tweet: [https://x.com/xquikcom/status/1893456789012345678](https://x.com/xquikcom/status/1893456789012345678)
* Run a giveaway draw where participants must have retweeted and have at least 100 followers.
* Show the results of my last giveaway draw.

**Webhooks**

* Set up a webhook at [https://my-server.com/events](https://my-server.com/events) for new tweets.
* List configured webhook endpoints.
* Remove the webhook pointing to my old server.

**Tweet Composition**

* Write a casual launch tweet for my new product.
* Optimize the draft for engagement.
* Score this draft: Just shipped v2.0 of our API. What do you think?
* Improve this tweet to get more replies.

**Style Analysis & Drafts**

* Analyze how @elonmusk tweets.
* Compare @vercel and @nextjs tweeting styles.
* Show cached tweet performance.
* Save this tweet draft for later.
* Show all saved drafts.
* Set my X account to @myusername.

**X Write Actions**

* Post a tweet saying: Just shipped v2.0!
* Like this tweet: [https://x.com/vercel/status/1893704267862470862](https://x.com/vercel/status/1893704267862470862)
* Retweet this: [https://x.com/openai/status/1893456789012345678](https://x.com/openai/status/1893456789012345678)
* Follow @vercel from my connected account.
* Send a DM to user ID 44196397 saying hello.
* Post a tweet saying: New feature! Use public image URL [https://example.com/launch.png](https://example.com/launch.png).

**Account & Usage**

* Show my plan and month-to-date usage.
* Check whether I have enough budget left for a large extraction.

## Framework guides

Build agents with Xquik's MCP tools in your preferred framework:

<CardGroup cols={3}>
  <Card title="LangChain" icon="link" href="/guides/langchain">Python agents with LangChain + LangGraph</Card>
  <Card title="CrewAI" icon="users" href="/guides/crewai">Multi-agent crews with CrewAI</Card>
  <Card title="Pydantic AI" icon="code" href="/guides/pydantic-ai">Type-safe agents with Pydantic AI</Card>
  <Card title="Google ADK" icon="bot" href="/guides/google-adk">Multi-agent assistants with Google ADK</Card>
  <Card title="Mastra" icon="server" href="/guides/mastra">TypeScript agents with Mastra</Card>
  <Card title="Microsoft Agent Framework" icon="workflow" href="/guides/microsoft-agent-framework">Python agents with Microsoft Agent Framework</Card>
  <Card title="Migrate from Composio" icon="arrow-right" href="/guides/composio-migration">Replace Composio's deprecated Twitter MCP</Card>
</CardGroup>

## AI agent skill

The [Xquik Skill](https://github.com/Xquik-dev/x-twitter-scraper) gives AI coding agents deep knowledge of the Xquik API without requiring an MCP connection. Install it to let your agent write API integrations, set up webhooks, and configure MCP connections using Xquik best practices.

Works with 40+ AI coding agents including Claude Code, Cursor, GitHub Copilot, Codex, Windsurf, VS Code, Gemini CLI, and more. The skill covers MCP tools and 120 REST API operations.

```bash theme={null}
npx skills add Xquik-dev/x-twitter-scraper
```
