Last active
June 30, 2025 16:34
-
-
Save khurramsyed/07818a538b7a701d02c99be45c8f1b5c to your computer and use it in GitHub Desktop.
3. Adding Tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from mcp.server.fastmcp import FastMCPAdd commentMore actions | |
| # Create an MCP server | |
| mcp = FastMCP("Calculator Server", host="0.0.0.0", port=8050) | |
| @mcp.tool()Add commentMore actions | |
| def add_numbers(number1: int, number2: int) -> str: | |
| """Addes two numbers together. | |
| Args: | |
| number1: first number | |
| number2: second number | |
| Returns: | |
| Textual representation of the sum of the two numbers in the format "The sum is: <sum>". | |
| Example: | |
| add_numbers(3, 5) -> "The sum is: 8" | |
| """ | |
| return f"The sum is: {number1 + number2}" | |
| # Run the server | |
| if __name__ == "__main__": | |
| mcp.run(transport="sse") # change to stdio for stdio i.e. running locally |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment