Initial curated ITWorx_MCP_Hub source from 368fba691ea8d23403b4d56b53b5ec670d7c5020
This commit is contained in:
commit
cb5be898ea
663 files changed
+82674
No files matched your search
@@ -0,0 +1,69 @@
|
||||
"""Deterministic MCP discovery/invocation matrix for supported client profiles."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from .models import ClientKind
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class MatrixResult:
|
||||
client_kind: ClientKind
|
||||
protocol_version: str
|
||||
connector: str
|
||||
tool: str
|
||||
discovered: bool
|
||||
invoked: bool
|
||||
detail: str
|
||||
|
||||
|
||||
class FakeVirtualServer:
|
||||
"""Offline project virtual server used for the client matrix and negative cases."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.tools = {
|
||||
"gitea": "gitea.repository.get",
|
||||
"knowledge": "knowledge.document.search",
|
||||
"unraid": "unraid.container.inspect",
|
||||
}
|
||||
self.revoked: set[str] = set()
|
||||
|
||||
def discover(self, client_key: str, protocol_version: str) -> tuple[str, ...]:
|
||||
if client_key in self.revoked:
|
||||
raise PermissionError("client revoked")
|
||||
if protocol_version not in {"2026-07-28", "2025-11-25"}:
|
||||
raise ValueError("unsupported protocol version")
|
||||
return tuple(self.tools.values())
|
||||
|
||||
def invoke(
|
||||
self, client_key: str, tool: str, arguments: dict[str, Any] | None = None
|
||||
) -> dict[str, Any]:
|
||||
del arguments
|
||||
if client_key in self.revoked:
|
||||
raise PermissionError("client revoked")
|
||||
if tool not in self.tools.values():
|
||||
raise LookupError("tool not found")
|
||||
return {"tool": tool, "ok": True, "truncated": False}
|
||||
|
||||
|
||||
def run_matrix(server: FakeVirtualServer) -> tuple[MatrixResult, ...]:
|
||||
profiles = (
|
||||
(ClientKind.NATIVE_2026, "2026-07-28"),
|
||||
(ClientKind.COMPATIBILITY_2025, "2025-11-25"),
|
||||
(ClientKind.STDIO_BRIDGE, "2026-07-28"),
|
||||
(ClientKind.INSPECTOR, "2026-07-28"),
|
||||
)
|
||||
results: list[MatrixResult] = []
|
||||
for kind, revision in profiles:
|
||||
client_key = kind.value
|
||||
tools = server.discover(client_key, revision)
|
||||
for connector, tool in server.tools.items():
|
||||
invoked = bool(server.invoke(client_key, tool)["ok"])
|
||||
results.append(
|
||||
MatrixResult(
|
||||
kind, revision, connector, tool, tool in tools, invoked, "fixture success"
|
||||
)
|
||||
)
|
||||
return tuple(results)
|
||||
Reference in new issue
Block a user