This commit is contained in:
2025-09-23 17:56:39 +03:00
commit 1f32743021
3 changed files with 46 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*.pyi
__pycache__

26
mcp-moex.py Normal file
View File

@@ -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")

18
moex.py Normal file
View File

@@ -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"]