chore: import upstream snapshot with attribution
Deploy Docs / deploy-docs (push) Failing after 1s
Conformance Tests / client-conformance (push) Failing after 3s
Conformance Tests / server-conformance (push) Failing after 1s
GitHub Actions Security Analysis / zizmor (push) Failing after 1s
CI / checks (push) Failing after 59m20s
CI / all-green (push) Has been cancelled
Deploy Docs / deploy-docs (push) Failing after 1s
Conformance Tests / client-conformance (push) Failing after 3s
Conformance Tests / server-conformance (push) Failing after 1s
GitHub Actions Security Analysis / zizmor (push) Failing after 1s
CI / checks (push) Failing after 59m20s
CI / all-green (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from typing import Any
|
||||
|
||||
from mcp_types import ListResourcesResult, PaginatedRequestParams, Resource
|
||||
|
||||
from mcp.server import Server, ServerRequestContext
|
||||
|
||||
BOOKS = [f"book-{n}" for n in range(1, 101)]
|
||||
|
||||
PAGE_SIZE = 10
|
||||
|
||||
|
||||
async def list_books(ctx: ServerRequestContext[Any], params: PaginatedRequestParams | None) -> ListResourcesResult:
|
||||
start = 0 if params is None or params.cursor is None else int(params.cursor)
|
||||
end = start + PAGE_SIZE
|
||||
page = [Resource(uri=f"books://catalog/{name}", name=name) for name in BOOKS[start:end]]
|
||||
next_cursor = str(end) if end < len(BOOKS) else None
|
||||
return ListResourcesResult(resources=page, next_cursor=next_cursor)
|
||||
|
||||
|
||||
server = Server("Bookshop", on_list_resources=list_books)
|
||||
Reference in New Issue
Block a user