使用说明
MCP Server Demo
A Model Context Protocol (MCP) server demonstrating tools, resources, and prompts using FastMCP.
Features
- Tools: Mathematical operations (addition)
- Resources: Personalized greeting messages
- Prompts: Greeting generation and text summarization
Prerequisites
- macOS
- Python 3.8+
Installation
1. Install uv (Python package manager)
curl -LsSf https://astral.sh/uv/install.sh | sh
2. Initialize Project
uv init mcp-server-demo
cd mcp-server-demo
3. Create Virtual Environment
uv venv
source .venv/bin/activate
4. Install Dependencies
uv add "mcp[cli]"
5. Install MCP Inspector (Optional)
npx @modelcontextprotocol/inspector
Usage
Run the MCP Server
uv run mcp dev main.py
Available Tools
add(a: int, b: int) -> int: Add two numbers
Available Resources
greeting/{name}: Get a personalized greeting message
Available Prompts
greet_user(name: str, style: str = "friendly"): Generate greeting prompts- Styles: "friendly", "formal", "casual"
summarize_text(text: str): Summarize text in one sentence
Development
The server is built using FastMCP and includes:
- Tools: Functions that can be called by MCP clients
- Resources: Named data sources that can be accessed
- Prompts: Template prompts for common tasks
License
MIT
