fmt
This commit is contained in:
@@ -319,22 +319,26 @@ class WfMcpService:
|
||||
statuses: list[dict[str, Any]] = []
|
||||
for connection in self.connections.list_all():
|
||||
snapshot = self.store.load_catalog(connection.id)
|
||||
statuses.append({
|
||||
"connection_id": connection.id,
|
||||
"server": connection.server,
|
||||
"account": connection.account,
|
||||
"enabled": connection.enabled,
|
||||
"has_snapshot": snapshot is not None,
|
||||
"fetched_at_epoch_ms": None
|
||||
if snapshot is None
|
||||
else snapshot.fetched_at_epoch_ms,
|
||||
"max_age_seconds": None
|
||||
if snapshot is None
|
||||
else snapshot.max_age_seconds,
|
||||
"node_count": 0 if snapshot is None else len(snapshot.nodes),
|
||||
"resource_count": 0 if snapshot is None else len(snapshot.resources),
|
||||
"prompt_count": 0 if snapshot is None else len(snapshot.prompts),
|
||||
})
|
||||
statuses.append(
|
||||
{
|
||||
"connection_id": connection.id,
|
||||
"server": connection.server,
|
||||
"account": connection.account,
|
||||
"enabled": connection.enabled,
|
||||
"has_snapshot": snapshot is not None,
|
||||
"fetched_at_epoch_ms": None
|
||||
if snapshot is None
|
||||
else snapshot.fetched_at_epoch_ms,
|
||||
"max_age_seconds": None
|
||||
if snapshot is None
|
||||
else snapshot.max_age_seconds,
|
||||
"node_count": 0 if snapshot is None else len(snapshot.nodes),
|
||||
"resource_count": 0
|
||||
if snapshot is None
|
||||
else len(snapshot.resources),
|
||||
"prompt_count": 0 if snapshot is None else len(snapshot.prompts),
|
||||
}
|
||||
)
|
||||
return statuses
|
||||
|
||||
def list_resources(
|
||||
|
||||
+37
-27
@@ -94,20 +94,26 @@ async def _refresh_all(service, connection_id: str | None) -> list[dict[str, Any
|
||||
try:
|
||||
await service.refresh_connection_catalog(target_id)
|
||||
snapshot = service.get_connection_snapshot(target_id)
|
||||
results.append({
|
||||
"connection_id": target_id,
|
||||
"refreshed": snapshot is not None,
|
||||
"node_count": 0 if snapshot is None else len(snapshot.nodes),
|
||||
"resource_count": 0 if snapshot is None else len(snapshot.resources),
|
||||
"prompt_count": 0 if snapshot is None else len(snapshot.prompts),
|
||||
})
|
||||
results.append(
|
||||
{
|
||||
"connection_id": target_id,
|
||||
"refreshed": snapshot is not None,
|
||||
"node_count": 0 if snapshot is None else len(snapshot.nodes),
|
||||
"resource_count": 0
|
||||
if snapshot is None
|
||||
else len(snapshot.resources),
|
||||
"prompt_count": 0 if snapshot is None else len(snapshot.prompts),
|
||||
}
|
||||
)
|
||||
except Exception as exc:
|
||||
results.append({
|
||||
"connection_id": target_id,
|
||||
"refreshed": False,
|
||||
"error_type": type(exc).__name__,
|
||||
"error": str(exc),
|
||||
})
|
||||
results.append(
|
||||
{
|
||||
"connection_id": target_id,
|
||||
"refreshed": False,
|
||||
"error_type": type(exc).__name__,
|
||||
"error": str(exc),
|
||||
}
|
||||
)
|
||||
return results
|
||||
|
||||
|
||||
@@ -132,16 +138,18 @@ def main(argv: list[str] | None = None) -> int:
|
||||
service = _service_from_config(args.config)
|
||||
|
||||
if args.command == "connections":
|
||||
_json_dump([
|
||||
{
|
||||
"id": connection.id,
|
||||
"server": connection.server,
|
||||
"account": connection.account,
|
||||
"enabled": connection.enabled,
|
||||
"metadata": connection.metadata,
|
||||
}
|
||||
for connection in service.connections.list_all()
|
||||
])
|
||||
_json_dump(
|
||||
[
|
||||
{
|
||||
"id": connection.id,
|
||||
"server": connection.server,
|
||||
"account": connection.account,
|
||||
"enabled": connection.enabled,
|
||||
"metadata": connection.metadata,
|
||||
}
|
||||
for connection in service.connections.list_all()
|
||||
]
|
||||
)
|
||||
return 0
|
||||
|
||||
if args.command == "status":
|
||||
@@ -154,10 +162,12 @@ def main(argv: list[str] | None = None) -> int:
|
||||
|
||||
if args.command == "refresh":
|
||||
results = asyncio.run(_refresh_all(service, args.connection_id))
|
||||
_json_dump({
|
||||
"results": results,
|
||||
"catalog": service.get_catalog().as_payload(),
|
||||
})
|
||||
_json_dump(
|
||||
{
|
||||
"results": results,
|
||||
"catalog": service.get_catalog().as_payload(),
|
||||
}
|
||||
)
|
||||
if any(not result["refreshed"] for result in results):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
@@ -38,10 +38,12 @@ def connection_to_fastmcp_server_config(
|
||||
def broker_config_to_fastmcp_config(config: BrokerConfig) -> MCPConfig:
|
||||
"""Convert broker config into FastMCP's multi-server config object."""
|
||||
validate_proxy_config(config)
|
||||
return MCPConfig.from_dict({
|
||||
"mcpServers": {
|
||||
connection.id: connection_to_fastmcp_server_config(connection)
|
||||
for connection in config.connections
|
||||
if connection.enabled
|
||||
return MCPConfig.from_dict(
|
||||
{
|
||||
"mcpServers": {
|
||||
connection.id: connection_to_fastmcp_server_config(connection)
|
||||
for connection in config.connections
|
||||
if connection.enabled
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
@@ -46,11 +46,13 @@ class ResourceLinkRewritingTool(Tool):
|
||||
rewrite_uri: Callable[[str], str],
|
||||
) -> ResourceLinkRewritingTool:
|
||||
"""Copy one tool's public schema while replacing only execution."""
|
||||
return cls.model_validate({
|
||||
**tool.model_dump(),
|
||||
"parent_tool": tool,
|
||||
"rewrite_uri": rewrite_uri,
|
||||
})
|
||||
return cls.model_validate(
|
||||
{
|
||||
**tool.model_dump(),
|
||||
"parent_tool": tool,
|
||||
"rewrite_uri": rewrite_uri,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class ResourceLinkNamespace(Transform):
|
||||
|
||||
Reference in New Issue
Block a user