MarketTwits MCP

MarketTwits MCP

Local SQLite archive and MCP search service for the Telegram channel @markettwits, enabling users to query asset-specific twits by instrument and time range.

Category
访问服务器

README

MarketTwits MCP

Local SQLite archive and MCP search service for the Telegram channel @markettwits (-1001203560567).

What it stores

Telegram text messages are stored in data/market_twits.sqlite3 with:

  • channel ID
  • UTC message datetime
  • Telegram message ID
  • text only
  • views count
  • extracted hashtags

The normalized message_hashtags table makes hashtag queries efficient. The sync_coverage_ranges table records successfully downloaded intervals, including empty ones, without concealing gaps between disjoint downloads.

Every Telegram fetch is appended to data/download_control.csv with:

channel_id,last_message_id,last_message_datetime,messages_requested,status,input_timestamp

Telegram credentials

  1. Sign in at https://my.telegram.org/apps and create an application.
  2. Copy .env.example to .env.
  3. Set TELEGRAM_API_ID, TELEGRAM_API_HASH, and TELEGRAM_PHONE.

Use a Telegram user account. Telegram bots generally cannot retrieve historical channel messages. On the first sync, Telethon asks for the login code and creates data/telegram_user.session. Later MCP calls reuse that authorized session.

Never commit .env or the session file; both are excluded by .gitignore.

Install and initial 2024-to-now download

cd C:\_tools\202607_tradingview_mcp\twits_mcp
Copy-Item .env.example .env
# Edit .env first.
uv sync
uv run twits-sync

The initial sync downloads from telegram.history_start in config.yaml through the current UTC time. It can be stopped and safely rerun: messages are upserted by (channel_id, message_id). A failed or interrupted partial range is not marked covered. Already committed batches and the final partial batch remain in SQLite, and the audit row reports the number committed during that attempt.

Instrument mapping

Edit instrument_hashtags.csv. It uses one row per relationship:

instrument,hashtag
WBD,#WBD
PSKY,#PSKY
BRENT,#ормуз
BRENT,#нефть

Matching is case-insensitive. One instrument can have several hashtags, and the same hashtag can be mapped to several instruments. The tool does not guess links: an unmapped instrument returns an error.

The production mapping accepts either instrument,hashtag or instrument,hashtag,frequency; frequency is ignored by MCP queries. Mapping files must be UTF-8, with or without BOM. UTF-8 with BOM is recommended for reliable Cyrillic editing in Excel.

To regenerate a review file containing every stored hashtag and the number of distinct messages containing it, run:

uv run twits-tags

This writes tags/instrument_hashtags.draft.csv with the columns instrument,hashtag,frequency. Existing assignments in that output are preserved on later runs; frequencies are always recalculated from SQLite and new hashtags are added as UNMAPPED.

Run the MCP server

Stdio:

uv run twits-mcp

HTTP:

uv run twits-mcp streamable-http --host 127.0.0.1 --port 8020

The HTTP endpoint is http://127.0.0.1:8020/mcp.

Codex registration:

codex mcp add market-twits --url http://127.0.0.1:8020/mcp

Tool

asset_twits(
  instrument="WBD",
  start="2026-07-20T19:00:00Z",
  end="2026-07-22T19:00:00Z",
  format="structured"
)

start and end are inclusive. Both accept ISO-8601 timestamps; values without an offset are interpreted as UTC and values with an offset are converted to UTC. end defaults to the current UTC time. If start is omitted, the legacy days parameter calculates start = end - days and defaults to five days. A request with start > end returns an error; equal values request that exact timestamp.

instrument accepts either a bare symbol or TradingView-style EXCHANGE:SYMBOL. The exchange prefix is discarded before mapping. Supported examples include CME_MINI:NQ1!, RUS:MX1!, ICEEUR:BRN1!, BITSTAMP:BTCUSD, and COMEX:GC1!. Both SI1! and RUS:SI1! are normalized to USDRUB. Instrument aliases are configured in instrument_aliases.json.

Before querying SQLite, the tool downloads any part of the requested date window not recorded in sync_coverage_ranges. Results are newest first. format="text" is the default and returns timestamp-prefixed strings. format="structured" returns message objects:

{
  "instrument": "WBD",
  "start": "2026-07-20T19:00:00Z",
  "end": "2026-07-22T19:00:00Z",
  "format": "structured",
  "count": 1,
  "truncated": false,
  "messages": [
    {
      "id": "-1001203560567:123456",
      "ts": "2026-07-22T18:27:00Z",
      "text": "ЕС одобрил слияние Warner Bros. и Paramount",
      "hashtags": ["#PSKY", "#WBD"]
    }
  ]
}

Structured IDs combine the Telegram channel and message IDs, so they remain stable across overlapping requests. Message bodies have country flags, promotional/legal footers, repeated whitespace, and inline hashtags removed; warning markers are retained and hashtags are returned in their own array. Structured timestamps and sync ranges use ISO-8601 UTC with Z notation.

Every bounded window is returned in full: there is no result cap or silent truncation, and truncated is therefore false. The response also reports how many Telegram messages were fetched during that call.

Notes

  • Telegram history is downloaded newest-first and written to SQLite in batches of 500 messages.
  • Requests earlier than history_start are clamped to that configured boundary.
  • Requests later than now fetch only through the current UTC time.
  • SQLite uses WAL mode and a 30-second busy timeout.
  • Concurrent calls in one MCP process share a synchronization lock, preventing duplicate downloads of the same missing interval.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选