Publish curated Unraid-AppOps-Gateway source from 28831bd43867347a132f1c2b0f388632b9cb561e
This commit is contained in:
1 parent
41fd48f0bc
commit
2d50064a8f
4 files changed
+92
-7
No files matched your search
@@ -13,6 +13,7 @@ from time import perf_counter
|
||||
from typing import Any
|
||||
|
||||
from mcp.server import MCPServer
|
||||
from mcp.server.mcpserver.exceptions import ToolError
|
||||
from mcp.server.transport_security import TransportSecuritySettings
|
||||
from mcp.types import ToolAnnotations
|
||||
from pydantic import StrictBool, ValidationError
|
||||
@@ -215,7 +216,19 @@ def run_read_only_canary() -> dict[str, Any]:
|
||||
return dict(_CANARY_STATUS)
|
||||
|
||||
|
||||
appops_mcp = MCPServer(
|
||||
class _InputRedactingMCPServer(MCPServer):
|
||||
async def call_tool(self, name: str, arguments: dict[str, Any], context: Any = None) -> Any:
|
||||
try:
|
||||
return await super().call_tool(name, arguments, context)
|
||||
except ToolError as error:
|
||||
# The SDK wraps argument validation before calling our typed handlers.
|
||||
# Do not let its input-bearing error text or cause reach the wire/logger.
|
||||
if type(error) is ToolError and isinstance(error.__cause__, ValidationError):
|
||||
raise ToolError("invalid_tool_arguments") from None
|
||||
raise
|
||||
|
||||
|
||||
appops_mcp = _InputRedactingMCPServer(
|
||||
"Unraid AppOps Gateway",
|
||||
version=APP_VERSION,
|
||||
instructions=(
|
||||
|
||||
Reference in new issue
Block a user