# from mcp.server.fastmcp import FastMCP from fastmcp import FastMCP from textblob import TextBlob mcp = FastMCP("custom_mcp") @mcp.tool() def sentiment_analysis(text: str) -> dict: """ Analyze the sentiment of the given text. Args: text (str): The text to analyze Returns: dict: A dictionary containing polarity, subjectivity, and assessment """ blob = TextBlob(text) sentiment = blob.sentiment return { "polarity": round(sentiment.polarity, 2), # -1 (negative) to 1 (positive) "subjectivity": round(sentiment.subjectivity, 2), # 0 (objective) to 1 (subjective) "assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral" } @mcp.tool() def letter_counter(word: str, letter: str): """Count the occurrences of a specific letter in a word. Args: word (str): The word or phrase to analyze letter (str): The letter to count occurrences of Returns: The number of times the letter appears in the word """ return word.lower().count(letter.lower()) if __name__ == "__main__": # Initialize and run the server mcp.run(transport='sse', host='0.0.0.0') #mcp.run()