DEV Community

Cover image for Moving Beyond LLM Hallucinations in Technical Analysis via Deterministic MCP Tools
Renato Marinho
Renato Marinho

Posted on

Moving Beyond LLM Hallucinations in Technical Analysis via Deterministic MCP Tools

Large Language Models are notoriously bad at arithmetic. When you ask a model to interpret complex financial oscillators, it isn't performing calculus; it is predicting the most likely next token based on training data. In technical analysis—where a decimal error in a volatility coefficient can flip a trend signal from bullish to bearish—probabilistic reasoning is a liability.

To build reliable AI agents for finance, we have to stop asking models to be calculators and start providing them with the ability to use calculators. This shift moves the intelligence from stochastic estimation to deterministic execution.

The Problem with Probabilistic Indicators

Welles Wilder’s methodologies, such as the Swing Index (SI), rely on precise calculations involving price movement intensity relative to volatility and a predefined limit move. If an agent attempts to derive these metrics purely through prompt engineering, it will eventually fail. Even with few-shot prompting, the transformer architecture lacks the internal precision required for consistent convergence on high-frequency or highly granular OHLC (Open, High, Low, Close) datasets.

The goal is to provide an agent with an interface where it can offload the math entirely, receiving instead a clean, verified result that it can then interpret logically. This is exactly what our Swing Index Calculator connector facilitates within the Model Context Protocol (MCP) ecosystem.

Engineering Determinism: Inside the Toolset

The connector isn't just a wrapper around a Python script; it is a structured set of tools designed for machine consumption. By exposing specific functions through MCP, we allow an agent to navigate three distinct layers of market analysis:

  1. Metric Derivation (calculate_swing_metrics): Instead of feeding raw numbers and hoping for the best, the agent provides OHLC data and a 'limit move' parameter. The tool returns exact SI and CSI (Cumulative Swing Index) values. The 'limit move' acts as a scaling factor—representing the maximum theoretical price movement allowed in a single period—which ensures the resulting index remains mathematically sound according to Wilder's original logic.

  2. Signal Detection (analyze_csi_signals): Once the math is settled, the agent needs to act. Rather than scanning arrays itself, it calls this tool to detect critical events like zero-line crosses or divergences. Identifying a transition from 0.1 to -0.5 in a CSI series becomes a discrete event detection task rather than a fuzzy pattern matching exercise.

  3. Volatility Contextualization (get_volatility_context): Trends do not exist in vacuums. To prevent false positives during periods of extreme noise, the get_volatility_context tool allows an agent to check if current price intensities are statistically significant relative to historical bounds.

Reliability Through Infrastructure

A common friction point I've encountered while building software over the last two decades is integration complexity. In the early days of PHP development, getting local environments to talk to remote APIs meant managing endless OAuth handshakes and fragile environment variables. Today, we face similar friction with MCP servers: setting up individual environments for every specialized tool.

Vinkius was built specifically to solve this gap between having an MCP server and being able to deploy it into production workflows reliably.

When we developed this connector using MCPFusion—our open-source TypeScript framework—we prioritized consistency and isolation. On Vinkius, every connector operates within an isolated V8 sandbox governed by strict policies including DLP (Data Loss Prevention) and SSRF prevention. This means that even when an AI agent is granted permission to interact with sensitive financial data structures via these tools, there is hardware-level enforcement preventing those tools from leaking data or making unauthorized outbound requests.

The architectural advantage here is simplicity for the developer: you don't manage per-provider credentials or handle complicated authentication flows for dozens of microservices. You subscribe once, take one connection token, and plug it into your client (whether that's Claude Desktop or a custom implementation). It transforms scattered utility scripts into professional-grade connectivity nodes.

Implementing Quantitative Logic in Agent Workflows

You can observe how this looks in practice by examining how an agent interacts with these inputs:

Scenario A: Calculating Metrics
Entering raw price points into calculate_swing_metrics yields immediate numerical certainty:
Input: [{'open': 100, 'high': 105, 'low': 98, 'close': 103...}] with limit move $5$.: \
*Output:
The calculated Swing Index (SI) for the second period is 12.5 and the Cumulative Swing Index (CSI) is 12.5.$
****
Note how much more efficient this is than forcing an LLM to explain its steps toward reaching that number.

Scenario B: Signal Intelligence
A secondary step involves analyzing trends through analyze_csi_signals. If an agent sees $[0.5, 1.2, 2.5, 0.1, -0.5]$, it doesn't guess if there is a crossover; it asks directy:
determining whether moving from positive territory ($0.1$) to negative territory ($-0.5$) constitutes a bearish signal triggers specific logical branches in the agent's decision tree without ambiguity.

Conclusion: Moving Toward Specialized Agency

The future of autonomous agents lies in specialization via robust interfaces rather than increasing parameter counts solely for reasoning breadthabilities alone cannot compensate for lack of mathematical rigor under pressure.

By leveraging deterministic connectors like the Swing Index Calculator, engineers can build agents capable of genuine quantitative tasks while maintaining control over security and accuracy through managed infrastructure like Vinkius.


AI agents only matter when they reach real systems. We built the connector catalog. Discover Vinkius.

Top comments (1)

Collapse
 
jeemmo profile image
Azeem Javed •

Agree completely: let tools compute and let the model explain. One failure mode I hit even with deterministic tools: name-based lookups returned records for a different entity, and the model presented them confidently. Re-checking that every returned row belongs to the entity asked about fixed it. I wrote about the setup here: dev.to/jeemmo/how-i-stop-an-llm-fr...