DEV Community

Howlia
Howlia

Posted on AI-assisted

Introducing Market Data to AI Assistants with MCP

An AI assistant can explain a market move, but first it needs the prices, the time window, and the context behind the numbers. Model Context Protocol (MCP) offers a way to make tools available to an AI client, so it can request data as part of a conversation or workflow.

This introduction uses TickDB MCP and a real cross-market example to show what that looks like: selecting instruments, retrieving historical price bars, comparing returns, and checking a later quote. The same checks apply when building your own data-powered assistant.

What MCP adds to a market data workflow

A market data API returns structured information such as quotes and historical price bars. An MCP server exposes tools that an AI client can discover and call. The client can use the returned data to answer a question, run calculations, or prepare a chart.

For example, a user might ask:

How did Meta, the Nasdaq, gold, and the yen move during the October 22 U.S. trading session?

The workflow can be broken down into inspectable steps:

Question → Choose instruments and time range → Call MCP tools
→ Check the returned data → Calculate changes → Explain the result
Enter fullscreen mode Exit fullscreen mode

TickDB supplies the market data; the AI client coordinates the tool calls and presentation. The assistant still needs to interpret the returned fields correctly. MCP makes the tools available; it does not guarantee that a model chooses the right symbols, time range, or calculation.

Choose comparable data

The example uses four instruments:

Instrument Role in the comparison
META.US Meta shares, quoted in U.S. dollars per share
IXIC Nasdaq Composite index
XAUUSD Gold quoted in U.S. dollars per ounce
USDJPY U.S. dollars quoted in Japanese yen

These prices have different units, so comparing their raw levels is not useful. First, query the same observation window for each instrument. Then calculate a percentage change from a consistent starting point.

Request historical bars

TickDB MCP exposes a get_kline tool for historical price bars. This is the actual Meta request used in the original analysis. It shows the tool name and arguments, not the full MCP protocol envelope:

{
  "tool": "get_kline",
  "arguments": {
    "symbol": "META.US",
    "type": "stock",
    "interval": "5m",
    "adjust": "none",
    "start_time": 1792675800000,
    "end_time": 1792698900000,
    "limit": 1000
  }
}
Enter fullscreen mode Exit fullscreen mode

The request selects five-minute, unadjusted stock bars. The millisecond timestamps identify bar start times from October 22, 2026 at 13:30 UTC through 19:55 UTC; the final bar ends at 20:00 UTC. The other instruments were queried over the same range, using type: indices for IXIC and type: forex for XAUUSD and USDJPY. adjust applies to the stock request in this example.

The successful Meta response has business code 0 and places records under data.klines. Here is an excerpt of the first bar:

{
  "code": 0,
  "data": {
    "symbol": "META.US",
    "interval": "5m",
    "klines": [
      {
        "time": 1792675800000,
        "open": "676.35000000",
        "high": "681.07000000",
        "low": "657.40000000",
        "close": "657.41000000"
      }
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

Prices are strings in this response, so convert them explicitly before calculating. Check the business code, required fields, and whether the series is empty; a missing record or error is not a zero price. Also check timestamps and the trading session before describing a result as current.

Calculate changes over the same window

Each response in this example contains 78 five-minute bars. Using the first bar's open and the last bar's close for the October 22 U.S. regular session gives:

Instrument First open Last close Change
META.US 676.35 648.87 -4.06%
IXIC 26,308.407 26,008.859 -1.14%
XAUUSD 4,076.61 4,027.93 -1.19%
USDJPY 157.234 156.862 -0.24%

The calculation is (last / first - 1) × 100. A falling USDJPY means fewer yen are needed to buy one dollar, so the yen strengthened against the dollar. Inverting the pair gives approximately +0.24% for the yen over the same window.

These are open-to-close changes within the selected session, not previous-close-to-close daily returns. The distinction matters: a move before the session opens is included in the latter but not the former. The prices show what happened in this window; they do not by themselves prove why each market moved.

Follow up with a quote

An assistant can use get_ticker to request a quote snapshot for the same instruments:

{
  "tool": "get_ticker",
  "arguments": {
    "symbols": "META.US,IXIC,XAUUSD,USDJPY"
  }
}
Enter fullscreen mode Exit fullscreen mode

This request was also executed for the original article. A quote is a snapshot, not a continuous subscription. Its timestamp and session fields matter: when this request was made on October 23, the next U.S. regular session had not started, so Meta's regular-session fields still described the previous session. A client should check the returned timestamps instead of assuming every value is from the same moment.

One possible follow-up is: “Check the latest quotes for those instruments and compare them with the end of the historical window.” That is a suggested prompt, not a claim that a further conversation was executed.

Try it in your own workflow

TickDB provides a hosted MCP service and an open-source server implementation that developers can inspect or deploy themselves. Connection and authorization depend on the client and configuration; market-data access depends on the permissions of the API key in use. For a continuously updating stream, evaluate the WebSocket interface separately rather than treating a one-off MCP query as a subscription.

The useful starting point is a question with a clear time range. Keep the tool arguments and data timestamps alongside the answer, and make the calculation reproducible. That makes it easier to inspect both the data and the assistant's interpretation.

Market data provided by TickDB.ai. Source code and connection instructions: TickDB MCP on GitHub.

Adapted from Stock API in Practice: Using MCP to Analyze Tech Stocks, Gold, and Forex.

Top comments (0)