From 1f32743021c080add199ef6fb0281cb2c973efde Mon Sep 17 00:00:00 2001 From: "Leonov Artur (Depish)" Date: Tue, 23 Sep 2025 17:56:39 +0300 Subject: [PATCH] init --- .gitignore | 2 ++ mcp-moex.py | 26 ++++++++++++++++++++++++++ moex.py | 18 ++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 .gitignore create mode 100644 mcp-moex.py create mode 100644 moex.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f83fb7c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyi +__pycache__ \ No newline at end of file diff --git a/mcp-moex.py b/mcp-moex.py new file mode 100644 index 0000000..403775f --- /dev/null +++ b/mcp-moex.py @@ -0,0 +1,26 @@ +from starlette.applications import Starlette +from starlette.routing import Mount +from mcp.server.fastmcp import FastMCP +from typing import TypedDict, List + + +from moex import bond_sequrities + + +mcp = FastMCP("mcp-moex - Данные с московской биржы.", port=8021) + + +@mcp.tool() +def get_bond_securities(bond_ticker: str, board: str) -> dict: + """ + Возвращает данные облигации по + + Args: + bond_ticker (str): Тикер облигации (например, "SU26230RMFS1"). + board (str): Доска торговли (например, "TQOB"). + """ + return bond_sequrities(bond_ticker, board) + + +if __name__ == "__main__": + mcp.run(transport="streamable-http", mount_path="/mcp") diff --git a/moex.py b/moex.py new file mode 100644 index 0000000..9818d8d --- /dev/null +++ b/moex.py @@ -0,0 +1,18 @@ +import requests +import xmltodict + + +BASE_URL: str = "https://iss.moex.com/iss" + +session = requests.Session() + + + +def bond_sequrities(bond_ticker: str, board: str) -> dict: + res = requests.get(f"{BASE_URL}/engines/stock/markets/BONDS/boards/{board}/securities.xml?securities={bond_ticker}&iss.meta=off&iss.only=securities") + + if res.status_code != 200: + return {"error": True, "status_code": res.status_code} + + return xmltodict.parse(res.text)["document"]["data"]["rows"]["row"] +