feat: expose read-only admin surface
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
from dataclasses import asdict
|
||||
from typing import Any
|
||||
|
||||
from wf_api import WorkflowSourceAdminApi, WorkflowSourceAdminSurface
|
||||
from wf_api import (
|
||||
WorkflowAdminApi,
|
||||
WorkflowAdminSurface,
|
||||
WorkflowSourceAdminApi,
|
||||
WorkflowSourceAdminSurface,
|
||||
)
|
||||
from wf_mcp.broker.service import WfMcpService
|
||||
from wf_mcp.broker.service.workflow_operation_context import context_from_service
|
||||
from wf_mcp.shared.errors import error_payload
|
||||
@@ -15,18 +19,18 @@ class BrokerAdminHandlers:
|
||||
self.sources: WorkflowSourceAdminSurface = WorkflowSourceAdminApi(
|
||||
context_from_service(service)
|
||||
)
|
||||
self.admin: WorkflowAdminSurface = WorkflowAdminApi(
|
||||
connections=service.connection_service,
|
||||
events=service.events,
|
||||
)
|
||||
|
||||
def list_connections(self) -> list[dict[str, Any]]:
|
||||
return [
|
||||
asdict(connection)
|
||||
for connection in sorted(
|
||||
self.service.connections.list_all(),
|
||||
key=lambda connection: connection.id,
|
||||
)
|
||||
]
|
||||
async def list_connections(self) -> list[dict[str, Any]]:
|
||||
payload = await self.admin.list_connections()
|
||||
return payload["connections"]
|
||||
|
||||
def get_connection_statuses(self) -> list[dict[str, Any]]:
|
||||
return self.service.connection_statuses()
|
||||
async def get_connection_statuses(self) -> list[dict[str, Any]]:
|
||||
payload = await self.admin.get_connection_statuses()
|
||||
return payload["statuses"]
|
||||
|
||||
async def refresh_connection_catalog(self, connection_id: str) -> dict[str, Any]:
|
||||
try:
|
||||
@@ -93,5 +97,6 @@ class BrokerAdminHandlers:
|
||||
**error_payload(exc),
|
||||
}
|
||||
|
||||
def get_broker_events(self) -> list[dict[str, Any]]:
|
||||
return [asdict(event) for event in self.service.list_events()]
|
||||
async def get_broker_events(self) -> list[dict[str, Any]]:
|
||||
payload = await self.admin.list_events()
|
||||
return payload["events"]
|
||||
|
||||
@@ -46,7 +46,7 @@ def register_service_admin_tools(
|
||||
description="List configured MCP connections known to this server.",
|
||||
)
|
||||
async def list_connections() -> list[dict[str, Any]]:
|
||||
return handlers.list_connections()
|
||||
return await handlers.list_connections()
|
||||
|
||||
@server.tool(
|
||||
name=name("get_connection_statuses"),
|
||||
@@ -54,7 +54,7 @@ def register_service_admin_tools(
|
||||
description="Show configured MCP connection status and catalog counts.",
|
||||
)
|
||||
async def get_connection_statuses() -> list[dict[str, Any]]:
|
||||
return handlers.get_connection_statuses()
|
||||
return await handlers.get_connection_statuses()
|
||||
|
||||
@server.tool(
|
||||
name=name("refresh_connection_catalog"),
|
||||
@@ -177,4 +177,4 @@ def register_service_admin_tools(
|
||||
description="Return locally recorded broker/platform events.",
|
||||
)
|
||||
async def get_events() -> list[dict[str, Any]]:
|
||||
return handlers.get_broker_events()
|
||||
return await handlers.get_broker_events()
|
||||
|
||||
Reference in New Issue
Block a user