This social listening example connects an AI assistant to Desearch MCP. One saved prompt retrieves recent public X posts about a topic and groups them into tables with links. Marketers can read the language people use before planning content or messaging, without writing code.
The problem
Topic searches mix questions with announcements, promotions and general conversation. A phrase such as "alternative to" can appear in a sales thread as easily as in a request for help. Marketers need dated posts they can open and read, with clear separation between conversation and promotion.
What the app does
The no-code path uses saved-prompt.md to search three phrase groups and sort posts into Asks, Complaints, Opinions, and Promo and news. Each table includes a date, author, short paraphrase and post link. Three short observations summarize the retrieved conversation. A separate Reddit pass supplies background links marked "date not confirmed".
The optional Python script runs the X searches, checks the date window, removes duplicates and assigns High, Medium or Low intent labels. Those labels are keyword hints, not the saved prompt's conversation groups. The output supports listening; it does not establish buying intent.
How it works
- Connect. Configure an MCP-capable assistant with the hosted server at
https://mcp.desearch.ai/mcp. Put the Desearch API key in theAuthorizationheader, never in the URL or chat prompt. - Choose the window and phrases. Edit the topic, topic words and lookback period in
saved-prompt.md. Keep quoted phrases and uppercase OR terms inside parentheses. - Retrieve and check. The prompt calls
x-searchonce per phrase group withstart_date,end_date,langandcount. It checks each post's date, drops duplicates and removes unrelated posts. - Read the groups. The assistant groups the posts and preserves their source links. Reddit results stay separate when their dates cannot be confirmed. Open posts to verify the interpretation.
X search returns top posts, so quiet conversations may be missed. Empty groups are useful findings and should stay empty.
The code
The saved prompt needs no Python. The optional whos_asking.py script builds arguments for each phrase group with this function, reproduced verbatim:
def build_args(group, start, end, count=50):
"""x-search arguments for one phrase group. OR terms stay inside parentheses."""
if not group or not group.strip():
raise ValueError("phrase group is empty")
q = group.strip()
if "-filter:retweets" not in q:
q += " -filter:retweets"
return {"query": q, "count": int(count), "start_date": start, "end_date": end, "lang": "en"}The same script opens an authenticated MCP session and calls x-search for each argument set. This excerpt is also verbatim:
async def search_all(arg_list, key):
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client
from mcp.shared._httpx_utils import create_mcp_http_client
out = []
async with create_mcp_http_client(headers={"Authorization": key}) as hc, \
streamable_http_client(MCP_URL, http_client=hc) as streams:
async with ClientSession(streams[0], streams[1]) as s:
await s.initialize()
for args in arg_list:
res = await s.call_tool("x-search", args, read_timeout_seconds=180)
out.append(parse_posts([c.model_dump() for c in res.content]))
return outThese functions rely on the imports, MCP_URL and parse_posts in the full source file. The script reads its key from ~/.desearch-api-key, or a file supplied with --key-file.
Endpoints
MCP tool x-search
Example output
This page describes a stored sample, not a live demo. The 2026-10-19 run searched newsletter-tool phrases over 2026-09-19 to 2026-10-19.
| Sample measurement | Result |
|---|---|
| Posts returned by the three searches | 1, 20, 0 |
| Posts kept inside the window | 21 |
| Direct "which tool" asks | 0 |
| High labels from the Python script | 2 |
Both High labels were promotional threads containing "alternative to" and a question mark. The label alone did not identify a request for a tool. The sample's --hide-handles output names rows person #1, person #2 and so on, with text and links hidden.
The saved sample write-up records the counts and interpretation. Results depend on what people posted during the chosen window.
Run it yourself
Create a Desearch account at the console, add a prepaid balance and create an API key. Connect the hosted MCP server at https://mcp.desearch.ai/mcp with the key in the Authorization header. Ask the assistant to list its tools and confirm x-search is available.
Open saved-prompt.md in the example folder, change the topic, phrases and number of days, and send it to the connected assistant. Read the linked posts before using the summary. Save the prompt for a weekly repeat and refine the phrases as new wording appears.
For the optional script, follow the folder's README to install its requirements and store the key in a private file. Run whos_asking.py with --days for the window, repeat --group for custom phrase groups, and add --hide-handles when sharing output.
What it costs
Each x-search call records X-Desearch-Cost-Usd. The sample write-up does not publish a single dollar total. The saved prompt also requests a Reddit background search, so its tool calls differ from the Python X-only path. See pricing.
Measured X searches took about 6 to 12 seconds on 2026-10-03 and 12 to 30 seconds on 2026-10-19. These are per-search observations, not a promised end-to-end runtime.
Ideas to extend it
- Repeat the saved prompt weekly with a seven-day window and compare recurring complaints.
- Add new topic phrases found in the posts and check whether they improve relevance.
- Export the grouped tables with a review column for corrections after opening each link.
- Compare the script's intent labels with manual reading before using them to prioritize posts.
