Skip to main content
Glama

Tavily Web Search MCP Server

by UpendraNath
server.py2.23 kB
from dotenv import load_dotenv from mcp.server.fastmcp import FastMCP from tavily import TavilyClient import os from dice_roller import DiceRoller from bookmark_organizer import BookmarkOrganizer 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 load_bookmark_data(data_folder: str = "data") -> str: """Load bookmarks and history data from files""" try: from bookmark_organizer import BookmarkOrganizer organizer = BookmarkOrganizer(data_folder) organizer.load_data() return f"Loaded {len(organizer.all_items)} total items from {data_folder}" except Exception as e: return f"Error loading data: {str(e)}" @mcp.tool() def organize_and_categorize(data_folder: str = "data", output_folder: str = "organized") -> str: """Clean, deduplicate, and categorize bookmark data""" try: from bookmark_organizer import BookmarkOrganizer organizer = BookmarkOrganizer(data_folder) organizer.load_data() organizer.clean_and_deduplicate() organizer.categorize_and_tag() organized_data = organizer.organize_by_category() organizer.save_organized_data(organized_data, output_folder) report = organizer.generate_report(organized_data) return f"Organization complete!\n\n{report}" except Exception as e: return f"Error organizing data: {str(e)}" if __name__ == "__main__": ##To run local and access it via Cursore IDE, use the following code: mcp.run(transport="stdio") ##To run locally and access it via the web, use the following code: #mcp.run(transport="http", host="127.0.0.1", port=8000) ##host="127.0.0.1", # Binds to the local machine only (good practice) # port=8000) # The port where the server will listen)

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/UpendraNath/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server