Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Python/SDK/examples/mcpserver/     Datei vom 5.10.2026 mit Größe 494 B image not shown  

Quelle  desktop.py   Sprache: Python

 

"""MCPServer Desktop Example

A simple example that exposes the desktop directory as a resource.
"
""

from pathlib import Path

from mcp.server.mcpserver import MCPServer

# Create server
mcp = MCPServer("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 sum(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b

Messung
CHZG
839810093

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland