Nasreen1717/MCP-Server
3.1
If you are the rightful owner of MCP-Server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Model Context Protocol (MCP) server is a framework designed to facilitate the development and deployment of AI models and tools using a standardized protocol.
🧑💻 MCP Project Setup Guide (Using uv, mcp, and uvicorn)
📁 Step 1: Open Terminal
Open your system terminal or integrated terminal in VS Code.
📂 Step 2: Create and Enter the Project Folder
uv init hello_mcp
cd hello_mcp
📦 Step 3: Install Required Packages
a. Install MCP Package:
uv add mcp
b. Install Uvicorn:
uv add uvicorn
c. Open Project in VS Code:
code .
⚙️ Step 4: Set the Python Virtual Environment
a. Locate .venv Folder:
- Right-click on
.venvfolder and copy full path.
b. Set Python Interpreter in VS Code:
- Press
Ctrl + Shift + Pto open Command Palette. - Type
Python: Select Interpreterand select it. - Paste the copied path to activate the environment.
📝 Step 5: Prepare Your main.py File
a. Open main.py
b. Delete all existing code
c. Add the following MCP server code:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP(name="hello-mcp", stateless_http=True)
mcp_app = mcp.streamable_http_app()
🚀 Step 6: Run the MCP Server
uv run uvicorn main:mcp_app
Or with port and hot reload:
uv run uvicorn main:mcp_app --port 8000 --reload
✅ Your MCP server should start successfully. 🔗 Click the URL shown in the terminal to test the server.
🤖 Step 7: Create and Run a Client Script
a. Stop the Server
- Press
Ctrl + Cin the terminal to stop the server.
b. Install requests package:
uv add requests
c. Restart the Server:
uv run uvicorn main:mcp_app
d. Create a new file client.py and add the following code:
import requests
# Define the MCP server URL
url = "http://localhost:8000/mcp/"
# Set the headers to accept JSON and event-stream responses
headers = {
"Accept": "application/json, text/event-stream",
}
# Create the JSON-RPC request body to list available tools
body = {
"jsonrpc": "2.0",
"method": "tools/list",
"id": 1,
"params": {},
}
# Send the POST request
response = requests.post(url, headers=headers, json=body)
# Stream and print each line of the response
for line in response.iter_lines():
if line:
print(line)
e. Run the Client Script:
uv run client.py
✅ You should see the list of tools printed line-by-line from the MCP server response.