Rebuild the docs around tested examples; shrink README.v2.md to a pitch (#2978)
This commit is contained in:
parent
4caa41f6d5
commit
411a6d3980
1 changed files with 9510 additions and 2639 deletions
20
docs_src/client/tutorial002.py
Normal file
20
docs_src/client/tutorial002.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from mcp import Client
|
||||
from mcp.server import MCPServer
|
||||
|
||||
mcp = MCPServer("Bookshop")
|
||||
|
||||
|
||||
@mcp.tool(title="Search the catalog")
|
||||
def search_books(query: str, limit: int = 10) -> str:
|
||||
"""Search the catalog by title or author."""
|
||||
return f"Found 3 books matching {query!r} (showing up to {limit})."
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
async with Client(mcp) as client:
|
||||
result = await client.list_tools()
|
||||
for tool in result.tools:
|
||||
print(tool.name)
|
||||
print(tool.title)
|
||||
print(tool.description)
|
||||
print(tool.input_schema)
|
||||
Loading…
Reference in a new issue