837ef904f8
Deploy Docs / deploy-docs (push) Has been cancelled
CI / checks (push) Failing after 24m23s
CI / all-green (push) Has been cancelled
Conformance Tests / server-conformance (push) Has been cancelled
Conformance Tests / client-conformance (push) Has been cancelled
GitHub Actions Security Analysis / zizmor (push) Has been cancelled
21 lines
551 B
Python
21 lines
551 B
Python
from mcp import Client
|
|
from mcp.server import MCPServer
|
|
|
|
mcp = MCPServer("Bookshop")
|
|
|
|
|
|
@mcp.tool()
|
|
def search_books(query: str) -> str:
|
|
"""Search the catalog by title or author."""
|
|
return f"Found 3 books matching {query!r}."
|
|
|
|
|
|
async def main() -> None:
|
|
async with Client(mcp) as client:
|
|
saved = client.session.discover_result
|
|
|
|
async with Client(mcp, mode="2026-07-28", prior_discover=saved) as client:
|
|
print(client.protocol_version)
|
|
if client.server_info is not None:
|
|
print(client.server_info.name)
|