mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-19 06:54:18 +01:00
Update all FastMCP examples to use mcp.server.fastmcp instead of fastmcp. Add tests to verify example servers work correctly. Changes: - Update import paths in all example files - Create test_examples.py to verify functionality - Fix test assertions to match actual response format
26 lines
487 B
Python
26 lines
487 B
Python
"""
|
|
FastMCP Desktop Example
|
|
|
|
A simple example that exposes the desktop directory as a resource.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from mcp.server.fastmcp import FastMCP
|
|
|
|
# Create server
|
|
mcp = FastMCP("Demo")
|
|
|
|
|
|
@mcp.resource("dir://desktop")
|
|
def desktop() -> list[str]:
|
|
"""List the files in the user's desktop"""
|
|
desktop = Path.home() / "Desktop"
|
|
return [str(f) for f in desktop.iterdir()]
|
|
|
|
|
|
@mcp.tool()
|
|
def add(a: int, b: int) -> int:
|
|
"""Add two numbers"""
|
|
return a + b
|