Skip to main content
Glama
phuihock

TA-Lib MCP Server

by phuihock

calculate_t3

Compute the T3 Moving Average indicator for financial market analysis using price data to identify trends and generate trading signals.

Instructions

Calculate T3 Moving Average.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kwargsYes

Implementation Reference

  • The main handler function for the 'calculate_t3' MCP tool. It retrieves the T3 indicator from the registry, prepares market data, calls the indicator's calculate method, and returns the result or error.
    @mcp.tool() async def calculate_t3(close: List[float], timeperiod: int = 5, vfactor: float = 0.7) -> Dict[str, Any]: try: indicator = registry.get_indicator("t3") if not indicator: raise ValueError("T3 indicator not found") market_data = MarketData(close=close) result = await indicator.calculate(market_data, {"timeperiod": timeperiod, "vfactor": vfactor}) if result.success: return {"success": True, "values": result.values, "metadata": result.metadata} return {"success": False, "error": result.error_message} except Exception as e: return {"success": False, "error": str(e)}
  • Input schema definition for the T3 indicator, specifying parameters like close_prices, timeperiod, and vfactor, which aligns with tool invocation in tests.
    @property def input_schema(self) -> Dict[str, Any]: return {"type": "object", "properties": {"close_prices": {"type": "array", "items": {"type": "number"}}, "timeperiod": {"type": "integer", "default": 5}, "vfactor": {"type": "number", "default": 0.7}}, "required": ["close_prices"]}
  • The core computation logic for T3 indicator using TA-Lib's T3 function. Called by the tool handler.
    async def calculate(self, market_data: MarketData, options: Dict[str, Any] = None) -> IndicatorResult: if options is None: options = {} timeperiod = options.get("timeperiod", 5) vfactor = options.get("vfactor", 0.7) close = np.asarray(market_data.close, dtype=float) try: out = ta.T3(close, timeperiod=timeperiod, vfactor=vfactor) return IndicatorResult(indicator_name=self.name, success=True, values={"t3": out.tolist()}, metadata={"timeperiod": timeperiod, "vfactor": vfactor, "input_points": len(close), "output_points": len(out)}) except Exception as e: return IndicatorResult(indicator_name=self.name, success=False, values={}, error_message=str(e))
  • Registration of the T3Indicator class in the indicator registry under the 't3' key, enabling registry.get_indicator('t3') in the handler.
    registry.register("t3", T3Indicator)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/phuihock/mcp-talib'

If you have feedback or need assistance with the MCP directory API, please join our Discord server