Rebuild the docs around tested examples; shrink README.v2.md to a pitch (#2978)
This commit is contained in:
parent
4caa41f6d5
commit
411a6d3980
3 changed files with 9510 additions and 2639 deletions
|
|
@ -85,7 +85,7 @@ class Context(BaseModel, Generic[LifespanContextT, RequestT]):
|
|||
@property
|
||||
def request_context(self) -> ServerRequestContext[LifespanContextT, RequestT]:
|
||||
"""Access to the underlying request context."""
|
||||
if self._request_context is None: # pragma: no cover
|
||||
if self._request_context is None:
|
||||
raise ValueError("Context is not available outside of a request")
|
||||
return self._request_context
|
||||
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class MCPServer(Generic[LifespanResultT]):
|
|||
raise ValueError("Cannot specify both auth_server_provider and token_verifier")
|
||||
if not auth_server_provider and not token_verifier: # pragma: no cover
|
||||
raise ValueError("Must specify either auth_server_provider or token_verifier when auth is enabled")
|
||||
elif auth_server_provider or token_verifier: # pragma: no cover
|
||||
elif auth_server_provider or token_verifier:
|
||||
raise ValueError("Cannot specify auth_server_provider or token_verifier without auth settings")
|
||||
|
||||
self._auth_server_provider = auth_server_provider
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class Image:
|
|||
|
||||
def _get_mime_type(self) -> str:
|
||||
"""Get MIME type from format or guess from file extension."""
|
||||
if self._format: # pragma: no cover
|
||||
if self._format:
|
||||
return f"image/{self._format.lower()}"
|
||||
|
||||
if self.path:
|
||||
|
|
@ -39,14 +39,14 @@ class Image:
|
|||
".gif": "image/gif",
|
||||
".webp": "image/webp",
|
||||
}.get(suffix, "application/octet-stream")
|
||||
return "image/png" # pragma: no cover # default for raw binary data
|
||||
return "image/png" # default for raw binary data
|
||||
|
||||
def to_image_content(self) -> ImageContent:
|
||||
"""Convert to MCP ImageContent."""
|
||||
if self.path:
|
||||
with open(self.path, "rb") as f:
|
||||
data = base64.b64encode(f.read()).decode()
|
||||
elif self.data is not None: # pragma: no cover
|
||||
elif self.data is not None:
|
||||
data = base64.b64encode(self.data).decode()
|
||||
else: # pragma: no cover
|
||||
raise ValueError("No image data available")
|
||||
|
|
@ -73,7 +73,7 @@ class Audio:
|
|||
|
||||
def _get_mime_type(self) -> str:
|
||||
"""Get MIME type from format or guess from file extension."""
|
||||
if self._format: # pragma: no cover
|
||||
if self._format:
|
||||
return f"audio/{self._format.lower()}"
|
||||
|
||||
if self.path:
|
||||
|
|
@ -86,14 +86,14 @@ class Audio:
|
|||
".aac": "audio/aac",
|
||||
".m4a": "audio/mp4",
|
||||
}.get(suffix, "application/octet-stream")
|
||||
return "audio/wav" # pragma: no cover # default for raw binary data
|
||||
return "audio/wav" # default for raw binary data
|
||||
|
||||
def to_audio_content(self) -> AudioContent:
|
||||
"""Convert to MCP AudioContent."""
|
||||
if self.path:
|
||||
with open(self.path, "rb") as f:
|
||||
data = base64.b64encode(f.read()).decode()
|
||||
elif self.data is not None: # pragma: no cover
|
||||
elif self.data is not None:
|
||||
data = base64.b64encode(self.data).decode()
|
||||
else: # pragma: no cover
|
||||
raise ValueError("No audio data available")
|
||||
|
|
|
|||
Loading…
Reference in a new issue