refactor: avoid double JSON parsing (#1917)
This commit is contained in:
parent
6d463bb353
commit
ae7793efd6
2 changed files with 4 additions and 6 deletions
|
|
@ -32,10 +32,8 @@ class RegistrationHandler:
|
||||||
async def handle(self, request: Request) -> Response:
|
async def handle(self, request: Request) -> Response:
|
||||||
# Implements dynamic client registration as defined in https://datatracker.ietf.org/doc/html/rfc7591#section-3.1
|
# Implements dynamic client registration as defined in https://datatracker.ietf.org/doc/html/rfc7591#section-3.1
|
||||||
try:
|
try:
|
||||||
# Parse request body as JSON
|
body = await request.body()
|
||||||
# TODO(Marcelo): This is unnecessary. We should use `request.body()`.
|
client_metadata = OAuthClientMetadata.model_validate_json(body)
|
||||||
body = await request.json()
|
|
||||||
client_metadata = OAuthClientMetadata.model_validate(body)
|
|
||||||
|
|
||||||
# Scope validation is handled below
|
# Scope validation is handled below
|
||||||
except ValidationError as validation_error:
|
except ValidationError as validation_error:
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ class FastMCP(Generic[LifespanResultT]):
|
||||||
website_url: str | None = None,
|
website_url: str | None = None,
|
||||||
icons: list[Icon] | None = None,
|
icons: list[Icon] | None = None,
|
||||||
version: str | None = None,
|
version: str | None = None,
|
||||||
auth_server_provider: (OAuthAuthorizationServerProvider[Any, Any, Any] | None) = None,
|
auth_server_provider: OAuthAuthorizationServerProvider[Any, Any, Any] | None = None,
|
||||||
token_verifier: TokenVerifier | None = None,
|
token_verifier: TokenVerifier | None = None,
|
||||||
*,
|
*,
|
||||||
tools: list[Tool] | None = None,
|
tools: list[Tool] | None = None,
|
||||||
|
|
@ -123,7 +123,7 @@ class FastMCP(Generic[LifespanResultT]):
|
||||||
warn_on_duplicate_resources: bool = True,
|
warn_on_duplicate_resources: bool = True,
|
||||||
warn_on_duplicate_tools: bool = True,
|
warn_on_duplicate_tools: bool = True,
|
||||||
warn_on_duplicate_prompts: bool = True,
|
warn_on_duplicate_prompts: bool = True,
|
||||||
lifespan: (Callable[[FastMCP[LifespanResultT]], AbstractAsyncContextManager[LifespanResultT]] | None) = None,
|
lifespan: Callable[[FastMCP[LifespanResultT]], AbstractAsyncContextManager[LifespanResultT]] | None = None,
|
||||||
auth: AuthSettings | None = None,
|
auth: AuthSettings | None = None,
|
||||||
):
|
):
|
||||||
self.settings = Settings(
|
self.settings = Settings(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue