Content
This is a runnable demo of an **mcp (model context protocol)** server with only **9 lines** of code, suitable for beginners who want to get started with mcp.
## Step 1: Download the Code
Download the complete code or simply copy the 9 lines of code below.
```python
import datetime
from mcp.server.fastmcp import FastMCP
mcp = FastMCP(name="time-service")
@mcp.tool(name="get_current_time", description="Get the current system time")
def get_current_time(format_str: str = "%Y-%m-%d %H:%M:%S") -> str:
now = datetime.datetime.now()
return now.strftime(format_str)
if __name__ == "__main__":
mcp.run(transport='sse') # Run the service in SSE mode
```
## Step 2: Configure the Conda Environment
```
conda.exe create -n mcp python=3.12
conda activate mcp
```
## Step 3: Install Dependencies
```
pip install "mcp[cli]"
pip install psutil
```
## Step 4: Run the Code
```
python mcp_get_current_time.py
```
## Step 5: Configure the mcp server in the chatbot and use it
Connection Info
You Might Also Like
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
everything-claude-code
Complete Claude Code configuration collection - agents, skills, hooks,...
servers
Model Context Protocol Servers
charlotte
Structured web browsing MCP server — some terrific, radiant, humble web pages.
skyflo
Self-hosted AI Agent for Kubernetes & DevOps
agnix
The missing linter and lsp for AI coding assistants. Validate CLAUDE.md,...