1b74b06753
Cut comment and docstring volume roughly in half across src, tests, examples, and docs_src: removed comments that restate the adjacent code, leftover development narration, section banners, and self-evident Args/Returns blocks, and compressed the remaining docstrings to a Google-style summary line plus only the detail that earns its place. Kept (and tightened) the load-bearing content: Raises sections, deprecation and version-availability notes, spec/RFC/issue references, why-comments for non-obvious decisions, and all coverage pragmas. The generated mcp_types.v* wire modules are untouched.
21 lines
450 B
Python
21 lines
450 B
Python
"""A simple example that exposes the desktop directory as a resource."""
|
|
|
|
from pathlib import Path
|
|
|
|
from mcp.server.mcpserver import MCPServer
|
|
|
|
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
|