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,51 @@
|
||||
"""Control-plane service for independently scoped MCP clients."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from uuid import UUID
|
||||
|
||||
from packages.hub_clients import (
|
||||
BootstrapHandle,
|
||||
ClientConfig,
|
||||
ClientKind,
|
||||
ClientRecord,
|
||||
ClientRegistry,
|
||||
generate_config,
|
||||
)
|
||||
|
||||
|
||||
class ClientService:
|
||||
def __init__(self, registry: ClientRegistry | None = None) -> None:
|
||||
self.registry = registry or ClientRegistry()
|
||||
|
||||
def create(
|
||||
self, *, name: str, project: str, environment: str, kind: ClientKind
|
||||
) -> tuple[ClientRecord, BootstrapHandle, ClientConfig]:
|
||||
record = self.registry.create(
|
||||
name=name, project=project, environment=environment, kind=kind
|
||||
)
|
||||
bootstrap = self.registry.issue_bootstrap(record.id)
|
||||
return record, bootstrap, generate_config(record)
|
||||
|
||||
def list(self) -> tuple[ClientRecord, ...]:
|
||||
return self.registry.list()
|
||||
|
||||
def config(self, client_id: UUID, kind: ClientKind | None = None) -> ClientConfig:
|
||||
record = self.registry.get(client_id)
|
||||
if record is None:
|
||||
raise KeyError(client_id)
|
||||
selected = (
|
||||
record
|
||||
if kind is None or kind is record.kind
|
||||
else record.model_copy(update={"kind": kind})
|
||||
)
|
||||
return generate_config(selected)
|
||||
|
||||
def disable(self, client_id: UUID) -> ClientRecord:
|
||||
return self.registry.disable(client_id)
|
||||
|
||||
def revoke(self, client_id: UUID) -> ClientRecord:
|
||||
return self.registry.revoke(client_id)
|
||||
|
||||
def bootstrap(self, client_id: UUID) -> BootstrapHandle:
|
||||
return self.registry.issue_bootstrap(client_id)
|
||||
Reference in new issue
Block a user