d-saurabh/mcp-server-demo
3.1
If you are the rightful owner of mcp-server-demo and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Model Context Protocol (MCP) server is a framework designed to facilitate the development and deployment of model-based applications, providing a structured environment for managing model interactions.
MCP Server Demo
This document provides step-by-step instructions to create and run the MCP server demo project.
Prerequisites
- Python 3.13 or later installed on your system.
uv
CLI tool installed. You can install it using:curl -LsSf https://astral.sh/uv/install.sh | sh
Steps to Create and Run the Project
1. Initialize the Project
- Open a terminal and navigate to your desired workspace directory.
- Run the following command to initialize a new MCP server project:
uv init mcp-server-demo
- Navigate into the project directory:
cd mcp-server-demo
2. Add Dependencies
- Add the
mcp[cli]
dependency to the project:uv add "mcp[cli]"
3. Modify the main.py
File
- Open the
main.py
file in your preferred text editor. - Ensure the
FastMCP
object is globally accessible with a standard name (e.g.,mcp
). Example content formain.py
:from mcp.server.fastmcp import FastMCP # Ensure the FastMCP object is globally accessible with a standard name mcp = FastMCP("Demo") def main(): print("Hello from mcp-server-demo!") if __name__ == "__main__": main()
4. Run the MCP Server
- Start the MCP server in development mode:
uv run mcp dev main.py
- The server will start and be accessible at
http://127.0.0.1:6274
.
5. Interact with the Server
- Use a browser,
curl
, or Postman to send requests to the server. - Example:
curl http://127.0.0.1:6274
Notes
- Ensure that the
uv
CLI tool is in your system's PATH. - If you encounter issues, verify that the
FastMCP
object is correctly defined and globally accessible inmain.py
.
Enjoy working with your MCP server demo!