Skip to main content
Glama

Tavily Web Search MCP Server

by inesaranab
server.py1.73 kB
from dotenv import load_dotenv from mcp.server.fastmcp import FastMCP from tavily import TavilyClient import os from dice_roller import DiceRoller #Usecase imports from elevenlabs import ElevenLabs load_dotenv() mcp = FastMCP("main-server") client = TavilyClient(os.getenv("TAVILY_API_KEY")) client_elevenlabs = ElevenLabs(api_key=os.getenv("ELEVENLABS_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) """ Add your own tool here, and then use it through Cursor! """ @mcp.tool() def text_to_speech(text: str, voice_id: str = "JBFqnCBsd6RMkjVDRZzb") -> str: """Convert the given text into speech and save as MP3 file""" import uuid try: # Generate unique filename audio_filename = f"speech_{uuid.uuid4().hex[:8]}.mp3" # Generate audio using ElevenLabs audio = client_elevenlabs.text_to_speech.convert( text=text, voice_id=voice_id, model_id="eleven_multilingual_v2" ) # Save audio to file with open(audio_filename, "wb") as f: for chunk in audio: if chunk: f.write(chunk) return f"Audio generated successfully! Saved as: {audio_filename}" except Exception as e: return f"Error generating speech: {str(e)}" if __name__ == "__main__": mcp.run(transport="stdio")

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

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