server.py•946 B
from dotenv import load_dotenv
from mcp.server.fastmcp import FastMCP
from tavily import TavilyClient
import os
from dice_roller import DiceRoller
from polygon_api import get_stock_data
load_dotenv()
mcp = FastMCP("mcp-server")
client = TavilyClient(os.getenv("TAVILY_API_KEY"))
@mcp.tool()
def web_search(query: str) -> str:
"""Search the web for information about the given query"""
search_results = client.get_search_context(query=query)
return search_results
@mcp.tool()
def roll_dice(notation: str, num_rolls: int = 1) -> str:
"""Roll the dice with the given notation"""
roller = DiceRoller(notation, num_rolls)
return str(roller)
@mcp.tool()
def get_stock_ohlc(symbol: str, date: str = None) -> str:
"""Get Open, High, Low, Close (OHLC) data for a stock symbol for the last working day or specified date"""
return get_stock_data(symbol, date)
if __name__ == "__main__":
mcp.run(transport="stdio")