Skip to main content
Glama
phuihock

TA-Lib MCP Server

by phuihock
test_wma.py1.24 kB
import asyncio import json import numpy as np import pytest import talib as ta from mcp import ClientSession, StdioServerParameters from mcp.client.stdio import stdio_client @pytest.mark.asyncio async def test_wma_matches_talib(): server_params = StdioServerParameters(command="uv", args=["run", "python", "-m", "mcp_talib.cli"]) close = [float(x) for x in range(1, 61)] timeperiod = 20 expected = ta.WMA(np.asarray(close, dtype=float), timeperiod=timeperiod) async with stdio_client(server_params) as (reader, writer): async with ClientSession(reader, writer) as session: await session.initialize() result = await session.call_tool("calculate_wma", {"close_prices": close, "timeperiod": timeperiod}) if hasattr(result, "value"): value = result.value else: text = getattr(result.content[0], "text", None) assert text is not None value = json.loads(text) assert value.get("success") is True np.testing.assert_allclose(np.asarray(value["values"]["wma"], dtype=float), expected, rtol=1e-6, atol=1e-8) if __name__ == "__main__": asyncio.run(test_wma_matches_talib())

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