> For the complete documentation index, see [llms.txt](https://docs.trover.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trover.tech/engineering/x-mcp.md).

# X MCP

The repository includes a stdio bridge to X's hosted Streamable HTTP MCP server. It is an operator tool and is not connected to the worker scheduler, so starting the application does not perform X API reads.

## Configure

1. In the X Developer Console, register `http://localhost:8080/callback` as an OAuth callback URL.
2. Put `X_MCP_CLIENT_ID` and `X_MCP_CLIENT_SECRET` in `.env`. Existing `X_CLIENT_ID` and `X_CLIENT_SECRET` are used as a fallback. Set `X_MCP_USERNAME=troverobinhood` so the bridge authenticates Trover's single active X account.
3. Run `pnpm x:mcp`, or open the workspace in VS Code/Cursor and enable the `xapi` MCP server. The open-source `xurl` bridge opens the OAuth flow, caches the user token locally, refreshes it, and injects a current Bearer token.

The MCP URL defaults to `https://api.x.com/mcp`. Never put these secrets in a `NEXT_PUBLIC_*` variable or commit an authenticated token cache.

## Cost boundary

The MCP only runs when an operator invokes it. The bot's runtime uses inbound X webhooks and accepts only explicit mentions/replies and DMs. Search backfill, thread backfill, polling fallback, trend reads, and market radar are disabled by default. The X usage endpoint is called only from the internal panel's manual “check usage” action.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.trover.tech/engineering/x-mcp.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
