from datetime import datetime
from mcp.server.fastmcp import Context
from mcp.types import PromptMessage, TextContent
from mcp_use.server import MCPServer
server = MCPServer(name="Prompt Server", version="1.0.0")
@server.prompt(
name="help",
title="Help",
description="Display available commands and usage"
)
def help_prompt() -> str:
"""Show help information."""
return """Available commands:
- /help - Show this message
- /status - Check server status
- /search <query> - Search for information
How can I assist you today?"""
@server.prompt(name="task")
def task_prompt(task_type: str, priority: str = "normal") -> str:
"""Generate a task-focused prompt."""
priority_prefix = {
"high": "URGENT: ",
"normal": "",
"low": "When you have time: "
}
prefix = priority_prefix.get(priority, "")
return f"{prefix}Please help me with the following {task_type} task:"
@server.prompt(name="conversation")
def conversation_starter(topic: str) -> list[PromptMessage]:
"""Start a conversation about a topic."""
return [
PromptMessage(
role="user",
content=TextContent(
type="text",
text=f"I'd like to learn about {topic}."
)
),
PromptMessage(
role="assistant",
content=TextContent(
type="text",
text=f"Great choice! {topic} is a fascinating subject. What aspect interests you most?"
)
)
]
@server.prompt(name="daily")
async def daily_prompt(context: Context) -> str:
"""Generate a daily prompt based on current time."""
hour = datetime.now().hour
if hour < 12:
greeting = "Good morning"
elif hour < 17:
greeting = "Good afternoon"
else:
greeting = "Good evening"
return f"{greeting}! What would you like to work on?"
if __name__ == "__main__":
server.run(transport="streamable-http", debug=True)