FastAPI MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@FastAPI MCP Serverwhat's the current server time?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
FastAPI MCP Server
A comprehensive FastAPI application with Model Context Protocol (MCP) server functionality, providing 21+ useful tools for mathematical operations, string manipulation, file handling, utilities, and web requests.
๐ฅ Demo Video
๐บ Watch the Demo
Direct Video Link: FastAPI MCP Server Demo Video
Click the link above to watch the demonstration video showing all 21+ tools in action!
๐ฌ Video Preview
The demo showcases:
โ Mathematical Operations - Addition, subtraction, multiplication, division, power, square root
โ String Manipulation - Uppercase, lowercase, reverse, length operations
โ File Operations - Reading, writing, and directory listing
โ Utility Functions - Time, random numbers, UUID generation, hashing
โ Web Utilities - URL validation and HTTP requests
โ MCP Protocol - WebSocket communication and tool calling
๐ Download Instructions:
Click the video link above to view in GitHub
Right-click on the video โ "Save video as" to download
Play locally for the best viewing experience
๐ Alternative Hosting Options:
YouTube - Best for public demos with embed preview
Google Drive - Easy sharing and preview
GitHub Releases - For downloadable files
Vimeo - Professional video hosting
Related MCP server: Simple MCP Server
Features
๐ข Mathematical Operations
add - Add two numbers together
subtract - Subtract second number from first number
multiply - Multiply two numbers
divide - Divide first number by second number (with zero-division protection)
power - Raise first number to the power of second number
sqrt - Calculate square root of a number
๐ String Operations
echo - Echo back the input text
uppercase - Convert text to uppercase
lowercase - Convert text to lowercase
reverse_string - Reverse a string
string_length - Get the length of a string
๐ File Operations
read_file - Read contents of a file
write_file - Write content to a file
list_directory - List files and directories in a path
๐ ๏ธ Utility Functions
get_time - Get current server time
random_number - Generate a random number between min and max
generate_uuid - Generate a random UUID
hash_md5 - Generate MD5 hash of input text
hash_sha256 - Generate SHA256 hash of input text
๐ Web Utilities
validate_url - Validate if a string is a valid URL
make_request - Make an HTTP request to a URL
Installation
Clone the repository:
git clone https://github.com/moawizbinyamin/Fastapi-mcp-server-.git
cd Fastapi-mcp-server-Create a virtual environment:
python -m venv venvActivate the virtual environment:
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activateInstall dependencies:
pip install -r requirements.txtUsage
Running the Server
python main.pyThe server will start on http://localhost:8000
Available Endpoints
GET / - Root endpoint with server info
GET /health - Health check endpoint
GET /tools - List all available tools
POST /tools/call - Call tools via HTTP
WebSocket /mcp - MCP protocol endpoint
GET /docs - FastAPI automatic documentation
Testing Tools via HTTP
List all tools:
curl http://localhost:8000/toolsCall a tool:
curl -X POST http://localhost:8000/tools/call \
-H "Content-Type: application/json" \
-d '{"name": "add", "arguments": {"a": 5, "b": 3}}'Example: Mathematical operations on 2 and 4:
# Addition: 2 + 4 = 6
curl -X POST http://localhost:8000/tools/call \
-H "Content-Type: application/json" \
-d '{"name": "add", "arguments": {"a": 2, "b": 4}}'
# Subtraction: 2 - 4 = -2
curl -X POST http://localhost:8000/tools/call \
-H "Content-Type: application/json" \
-d '{"name": "subtract", "arguments": {"a": 2, "b": 4}}'
# Multiplication: 2 ร 4 = 8
curl -X POST http://localhost:8000/tools/call \
-H "Content-Type: application/json" \
-d '{"name": "multiply", "arguments": {"a": 2, "b": 4}}'
# Division: 2 รท 4 = 0.5
curl -X POST http://localhost:8000/tools/call \
-H "Content-Type: application/json" \
-d '{"name": "divide", "arguments": {"a": 2, "b": 4}}'
# Power: 2^4 = 16
curl -X POST http://localhost:8000/tools/call \
-H "Content-Type: application/json" \
-d '{"name": "power", "arguments": {"base": 2, "exponent": 4}}'MCP Protocol Support
This server implements the Model Context Protocol (MCP) specification, allowing it to be used with MCP-compatible clients. The WebSocket endpoint /mcp handles MCP protocol communication.
MCP Configuration
For use with MCP clients, configure your MCP client with:
{
"mcpServers": {
"fastapi-mcp-server": {
"command": "python",
"args": ["main.py"],
"cwd": "/path/to/Fastapi-mcp-server-",
"env": {
"PYTHONPATH": "/path/to/Fastapi-mcp-server-"
}
}
}
}Dependencies
FastAPI - Modern, fast web framework for building APIs
Uvicorn - ASGI server implementation
Pydantic - Data validation using Python type annotations
httpx - HTTP client for making web requests
websockets - WebSocket implementation
Error Handling
All tools include comprehensive error handling:
Division by zero protection
File not found handling
Invalid input validation
Network request error handling
Development
Project Structure
Fastapi-mcp-server-/
โโโ main.py # Main FastAPI application
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ .gitignore # Git ignore rules
โโโ start_server.bat # Windows startup script
โโโ start_server.sh # Linux/Mac startup scriptAdding New Tools
To add a new tool:
Add the tool definition to the
toolsdictionary in theMCPServer.__init__()methodAdd the tool implementation to the
call_tool()methodTest the tool via the HTTP endpoint
License
This project is open source and available under the MIT License.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For support, please open an issue on the GitHub repository.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/moawizbinyamin/Fastapi-mcp-server-'
If you have feedback or need assistance with the MCP directory API, please join our Discord server