Spaces:
Runtime error
Runtime error
Download app.py from juancitro/mcp-server-custom: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/juancitro/mcp-server-custom/resolve/main/app.py
- Command line
-
hf download hf://spaces/juancitro/mcp-server-custom/app.py
-
curl -L -o app.py https://huggingface.co/spaces/juancitro/mcp-server-custom/resolve/main/app.py
1.26 kB
| # from mcp.server.fastmcp import FastMCP | |
| from fastmcp import FastMCP | |
| from textblob import TextBlob | |
| mcp = FastMCP("custom_mcp") | |
| 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" | |
| } | |
| 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() |