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

# X (Twitter) MCP

> Connect X's official MCP server so OpenSRE can search, read, and post on X during investigations

OpenSRE connects to X's official [Model Context Protocol (MCP)](https://github.com/xdevplatform/xmcp) server, exposing X's API — tweet search, timelines, user profiles, likes, retweets, bookmarks, and posting — as tools the agent can call while investigating an incident.

Unlike PostHog or Sentry's always-on hosted MCP servers, XMCP is designed to run **locally**: you clone the [xmcp repo](https://github.com/xdevplatform/xmcp), supply your own X API credentials, and run the server yourself. OpenSRE connects to that local endpoint (or a tunneled URL if you need remote access, e.g. via ngrok).

## Tools

| Tool           | What it does                                                                      |
| -------------- | --------------------------------------------------------------------------------- |
| `list_x_tools` | List the tools the connected X MCP server exposes (compact, filterable)           |
| `call_x_tool`  | Call a named X MCP tool (e.g. search tweets, inspect a timeline, look up a tweet) |

The agent typically calls `list_x_tools` first to discover what is available, then `call_x_tool` with the chosen tool name and arguments. Pass `name_filter` (space- or comma-separated terms, e.g. `"search tweet"`) to narrow a large tool list, and `include_schema=true` on a narrowed list to fetch the full input schema for the tool you intend to call.

## Prerequisites

* A running instance of [xmcp](https://github.com/xdevplatform/xmcp) with your own X API credentials configured (`X_BEARER_TOKEN`, and OAuth1/OAuth2 credentials if you need write access such as posting)
* Network access from OpenSRE to the xmcp server's URL (local by default; tunnel it if OpenSRE runs elsewhere)

<Info>
  XMCP authenticates to the X API using its own environment (`X_BEARER_TOKEN`, OAuth credentials) at startup. OpenSRE does not need to know your X API credentials for `streamable-http`/`sse` connections to an already-running server — it only needs the server's URL. An optional auth token can be set if your endpoint sits behind an authenticating tunnel or proxy.
</Info>

## Setup

### Option 1: Interactive CLI

```bash theme={null}
opensre integrations setup x_mcp
opensre integrations verify x_mcp
```

You'll be prompted for the xmcp server URL (defaults to `http://127.0.0.1:8000/mcp`) and, optionally, an auth token if the endpoint is tunneled behind an authenticating proxy.

### Option 2: Environment variables

Add to your `.env`:

```bash theme={null}
X_MCP_MODE=streamable-http
X_MCP_URL=http://127.0.0.1:8000/mcp
X_MCP_AUTH_TOKEN=                     # optional, only for a tunneled/proxied endpoint
```

| Variable           | Default                     | Description                                                                                                              |
| ------------------ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `X_MCP_URL`        | `http://127.0.0.1:8000/mcp` | X MCP server URL (local or tunneled)                                                                                     |
| `X_MCP_MODE`       | `streamable-http`           | Transport: `streamable-http`, `sse`, or `stdio`                                                                          |
| `X_MCP_AUTH_TOKEN` | —                           | Optional bearer token, only needed if the endpoint requires client auth                                                  |
| `X_MCP_COMMAND`    | —                           | Command to launch the xmcp server directly (`stdio` mode only)                                                           |
| `X_MCP_ARGS`       | —                           | Arguments for the local xmcp command (`stdio` mode only)                                                                 |
| `X_BEARER_TOKEN`   | —                           | X API bearer token forwarded to the server when OpenSRE launches it (`stdio` mode only); not sent over the MCP transport |

To have OpenSRE launch the local xmcp server itself instead of connecting to one you already started, use `stdio` mode:

```bash theme={null}
X_MCP_MODE=stdio
X_MCP_COMMAND=python
X_MCP_ARGS=server.py
X_BEARER_TOKEN=your_x_api_bearer_token
```

### Option 3: Persistent store

```json theme={null}
{
  "version": 1,
  "integrations": [
    {
      "id": "x-mcp-local",
      "service": "x_mcp",
      "status": "active",
      "credentials": {
        "url": "http://127.0.0.1:8000/mcp",
        "mode": "streamable-http"
      }
    }
  ]
}
```

## Verify

```bash theme={null}
opensre integrations verify x_mcp
```

A successful check connects to the MCP server and reports how many tools it discovered. If it fails, confirm the xmcp server is running and reachable at the configured URL, and that its own X API credentials (`X_BEARER_TOKEN`) are valid.
