more functions out of the Big Tool registers
This commit is contained in:
@@ -1,33 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import asdict
|
||||
from typing import Any, Protocol
|
||||
from typing import Any
|
||||
|
||||
from fastmcp import FastMCP
|
||||
|
||||
from ..control import BrokerConfigManager
|
||||
from ..models import BrokerConfig
|
||||
|
||||
|
||||
class ProxyAdminRuntime(Protocol):
|
||||
manager: BrokerConfigManager | None
|
||||
|
||||
def current_config(self) -> BrokerConfig: ...
|
||||
|
||||
def require_manager(self) -> BrokerConfigManager: ...
|
||||
|
||||
def reload(self) -> dict[str, Any]: ...
|
||||
|
||||
async def list_proxy_tools_page(
|
||||
self,
|
||||
*,
|
||||
connection_id: str | None = None,
|
||||
query: str | None = None,
|
||||
limit: int = 50,
|
||||
cursor: str | None = None,
|
||||
) -> dict[str, Any]: ...
|
||||
|
||||
async def get_proxy_tool(self, proxy_name: str) -> dict[str, Any]: ...
|
||||
from ..admin_surface import ProxyAdminRuntime, TransparentAdminHandlers
|
||||
|
||||
|
||||
def create_proxy_admin_server(
|
||||
@@ -38,46 +15,23 @@ def create_proxy_admin_server(
|
||||
"wf-mcp-admin",
|
||||
instructions="Administrative tools for this wf-mcp proxy instance.",
|
||||
)
|
||||
handlers = TransparentAdminHandlers(runtime)
|
||||
|
||||
@admin.tool()
|
||||
async def list_connections() -> list[dict[str, Any]]:
|
||||
return [
|
||||
asdict(connection)
|
||||
for connection in sorted(
|
||||
runtime.current_config().connections,
|
||||
key=lambda connection: connection.id,
|
||||
)
|
||||
]
|
||||
return handlers.list_connections()
|
||||
|
||||
@admin.tool()
|
||||
async def get_connection_statuses() -> list[dict[str, Any]]:
|
||||
return [
|
||||
{
|
||||
"connection_id": connection.id,
|
||||
"server": connection.server,
|
||||
"account": connection.account,
|
||||
"enabled": connection.enabled,
|
||||
"transport": connection.metadata.get("transport"),
|
||||
}
|
||||
for connection in sorted(
|
||||
runtime.current_config().connections,
|
||||
key=lambda connection: connection.id,
|
||||
)
|
||||
]
|
||||
return handlers.get_connection_statuses()
|
||||
|
||||
@admin.tool()
|
||||
async def get_config() -> dict[str, Any]:
|
||||
if runtime.manager is not None:
|
||||
return runtime.manager.get_payload()
|
||||
config = runtime.current_config()
|
||||
return {
|
||||
"store_root": str(config.store_root),
|
||||
"connections": [asdict(connection) for connection in config.connections],
|
||||
}
|
||||
return handlers.get_config()
|
||||
|
||||
@admin.tool()
|
||||
async def reload_config() -> dict[str, Any]:
|
||||
return runtime.reload()
|
||||
return handlers.reload_config()
|
||||
|
||||
@admin.tool()
|
||||
async def list_proxy_tools(
|
||||
@@ -86,7 +40,7 @@ def create_proxy_admin_server(
|
||||
limit: int = 50,
|
||||
cursor: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
return await runtime.list_proxy_tools_page(
|
||||
return await handlers.list_proxy_tools(
|
||||
connection_id=connection_id,
|
||||
query=query,
|
||||
limit=limit,
|
||||
@@ -95,7 +49,7 @@ def create_proxy_admin_server(
|
||||
|
||||
@admin.tool()
|
||||
async def get_proxy_tool(proxy_name: str) -> dict[str, Any]:
|
||||
return await runtime.get_proxy_tool(proxy_name)
|
||||
return await handlers.get_proxy_tool(proxy_name)
|
||||
|
||||
@admin.tool()
|
||||
async def add_connection(
|
||||
@@ -105,7 +59,7 @@ def create_proxy_admin_server(
|
||||
metadata: dict[str, Any] | None = None,
|
||||
enabled: bool = True,
|
||||
) -> dict[str, Any]:
|
||||
return runtime.require_manager().add_connection(
|
||||
return handlers.add_connection(
|
||||
connection_id=connection_id,
|
||||
server=server,
|
||||
account=account,
|
||||
@@ -121,7 +75,7 @@ def create_proxy_admin_server(
|
||||
metadata: dict[str, Any] | None = None,
|
||||
enabled: bool | None = None,
|
||||
) -> dict[str, Any]:
|
||||
return runtime.require_manager().update_connection(
|
||||
return handlers.update_connection(
|
||||
connection_id=connection_id,
|
||||
server=server,
|
||||
account=account,
|
||||
@@ -131,20 +85,14 @@ def create_proxy_admin_server(
|
||||
|
||||
@admin.tool()
|
||||
async def enable_connection(connection_id: str) -> dict[str, Any]:
|
||||
return runtime.require_manager().set_connection_enabled(
|
||||
connection_id,
|
||||
enabled=True,
|
||||
)
|
||||
return handlers.enable_connection(connection_id)
|
||||
|
||||
@admin.tool()
|
||||
async def disable_connection(connection_id: str) -> dict[str, Any]:
|
||||
return runtime.require_manager().set_connection_enabled(
|
||||
connection_id,
|
||||
enabled=False,
|
||||
)
|
||||
return handlers.disable_connection(connection_id)
|
||||
|
||||
@admin.tool()
|
||||
async def remove_connection(connection_id: str) -> dict[str, Any]:
|
||||
return runtime.require_manager().remove_connection(connection_id)
|
||||
return handlers.remove_connection(connection_id)
|
||||
|
||||
return admin
|
||||
|
||||
Reference in New Issue
Block a user