Skip to main content
Glama
phuihock

TA-Lib MCP Server

by phuihock

calculate_ht_trendline

Calculate Hilbert Transform Trendline for financial market analysis to identify trend direction and potential reversals in price data.

Instructions

Calculate Hilbert Transform Trendline.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kwargsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'calculate_ht_trendline'. Fetches 'ht_trendline' indicator from registry, creates MarketData from close prices, calls indicator.calculate(), and returns success/values or error.
    @mcp.tool()
    async def calculate_ht_trendline(close: List[float]) -> Dict[str, Any]:
        try:
            indicator = registry.get_indicator("ht_trendline")
            if not indicator:
                raise ValueError("HT_TRENDLINE indicator not found")
            market_data = MarketData(close=close)
            result = await indicator.calculate(market_data, {})
            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)}
  • HTTrendlineIndicator class implementing the core logic: wraps TA-Lib's ta.HT_TRENDLINE on close prices, handles input/output as IndicatorResult with values['ht_trendline'] and metadata.
    class HTTrendlineIndicator(BaseIndicator):
        def __init__(self):
            super().__init__(name="ht_trendline", description="Hilbert Transform - Instantaneous Trendline")
    
        @property
        def input_schema(self) -> Dict[str, Any]:
            return {"type": "object", "properties": {"close_prices": {"type": "array", "items": {"type": "number"}}}, "required": ["close_prices"]}
    
        async def calculate(self, market_data: MarketData, options: Dict[str, Any] = None) -> IndicatorResult:
            close = np.asarray(market_data.close, dtype=float)
            try:
                out = ta.HT_TRENDLINE(close)
                return IndicatorResult(
                    indicator_name=self.name,
                    success=True,
                    values={"ht_trendline": out.tolist()},
                    metadata={"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))
  • Input schema definition for the indicator, specifying 'close_prices' as required array of numbers.
    @property
    def input_schema(self) -> Dict[str, Any]:
        return {"type": "object", "properties": {"close_prices": {"type": "array", "items": {"type": "number"}}}, "required": ["close_prices"]}
  • Registration of HTTrendlineIndicator in the IndicatorRegistry under key 'ht_trendline', which is fetched by the handler.
    registry.register("ht_trendline", HTTrendlineIndicator)
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but offers none. It does not indicate whether this is a read-only or destructive operation, what permissions or inputs are required, or any rate limits or side effects, making it inadequate for a tool with computational complexity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words, making it appropriately concise. However, this brevity contributes to under-specification rather than clarity, but it meets the criteria for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of financial calculations, no annotations, 0% schema coverage, and one undocumented parameter, the description is severely incomplete. While an output schema exists, the description lacks essential details on purpose, usage, behavior, and parameters, making it inadequate for effective tool selection and invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description provides no parameter information. The single parameter 'kwargs' is undocumented in both schema and description, leaving its meaning, format, or required inputs completely unspecified, failing to compensate for the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Calculate Hilbert Transform Trendline' restates the tool name with minimal elaboration, making it a tautology. It specifies the verb 'Calculate' and resource 'Hilbert Transform Trendline', but lacks detail on what this calculation entails or its practical application, failing to distinguish it from sibling tools like 'calculate_rsi' or 'calculate_sma' beyond the technical term.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description does not mention context, prerequisites, or comparisons to sibling tools (e.g., 'calculate_ema' for exponential moving averages), leaving the agent with no usage instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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