From 2f27e117f7940d43840ce5c28c14c66b4bee334e Mon Sep 17 00:00:00 2001 From: Dhruvkumar-Microsoft Date: Tue, 14 Jul 2026 17:28:23 +0530 Subject: [PATCH] fix the HR scenario issue by implementing the tools filtering and updated the azure.yaml --- azure.yaml | 16 +++++----- src/backend/config/mcp_config.py | 51 ++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/azure.yaml b/azure.yaml index ddadfe000..1c9e81f82 100644 --- a/azure.yaml +++ b/azure.yaml @@ -1,7 +1,7 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json name: multi-agent-custom-automation-engine-solution-accelerator -metadata: - template: multi-agent-custom-automation-engine-solution-accelerator@1.0 +# metadata: +# template: multi-agent-custom-automation-engine-solution-accelerator@1.0 requiredVersions: azd: '>= 1.18.0 != 1.23.9' hooks: @@ -18,12 +18,12 @@ hooks: Write-Host "" Write-Host " Build and push the backend/frontend/mcp_server container images to ACR, then point the container app and webapp at them:" -ForegroundColor White - Write-Host " 👉 Run the following command in Bash:" -ForegroundColor White + Write-Host " 👉 STEP 1: Run the following command in Bash:" -ForegroundColor White Write-Host " bash infra/scripts/post-provision/build_and_push_images.sh" -ForegroundColor Cyan Write-Host "" Write-Host " Upload Team Configurations, index sample data and create the Knowledge base from content Packs" -ForegroundColor White - Write-Host " 👉 Run the following command in Bash:" -ForegroundColor White + Write-Host " 👉 STEP 2: Run the following command in Bash:" -ForegroundColor White Write-Host " bash infra/scripts/post-provision/post_deploy.sh" -ForegroundColor Cyan Write-Host "" @@ -39,12 +39,12 @@ hooks: Write-Host "" Write-Host " Build and push the backend/frontend/mcp_server container images to ACR, then point the container app and webapp at them:" -ForegroundColor White - Write-Host " 👉 Run the following command in PowerShell:" -ForegroundColor White + Write-Host " 👉 STEP 1: Run the following command in PowerShell:" -ForegroundColor White Write-Host " .\infra\scripts\post-provision\Build-And-Push-Images.ps1" -ForegroundColor Cyan Write-Host "" Write-Host " Upload Team Configurations, index sample data and create the Knowledge base from content Packs" -ForegroundColor White - Write-Host " 👉 Run the following command in PowerShell:" -ForegroundColor White + Write-Host " 👉 STEP 2: Run the following command in PowerShell:" -ForegroundColor White Write-Host " .\infra\scripts\post-provision\post_deploy.ps1" -ForegroundColor Cyan Write-Host "" @@ -69,11 +69,11 @@ hooks: printf "${Yellow}===============================================================${NC}\n\n" printf "Build and push the backend/frontend/mcp_server container images to ACR, then point the container app and webapp at them:\n" - printf " 👉 Run the following command in Bash:\n" + printf " 👉 STEP 1: Run the following command in Bash:\n" printf " ${Blue}bash infra/scripts/post-provision/build_and_push_images.sh${NC}\n\n" printf "Upload Team Configurations, index sample data and create the Knowledge base from content Packs:\n" - printf " 👉 Run the following command in Bash:\n" + printf " 👉 STEP 2: Run the following command in Bash:\n" printf " ${Blue}bash infra/scripts/post-provision/post_deploy.sh${NC}\n\n" printf "🌐 Access your deployed Frontend application at:\n" diff --git a/src/backend/config/mcp_config.py b/src/backend/config/mcp_config.py index ae17e7caf..91948e7dd 100644 --- a/src/backend/config/mcp_config.py +++ b/src/backend/config/mcp_config.py @@ -20,7 +20,34 @@ # so the LLM only sees the relevant subset (avoids cross-pack tool confusion when # the MCP server exposes every function at the base /mcp endpoint). DOMAIN_ALLOWED_TOOLS: dict[str, list[str]] = { - "image": ["generate_marketing_image"], + "hr": [ + "get_workflow_blueprint", + "schedule_orientation_session", + "assign_mentor", + "register_for_benefits", + "provide_employee_handbook", + "initiate_background_check", + "request_id_card", + "set_up_payroll", + ], + "tech_support": [ + "get_workflow_blueprint", + "send_welcome_email", + "set_up_office_365_account", + "configure_laptop", + "setup_vpn_access", + "create_system_accounts", + ], + "marketing": [ + "generate_press_release", + "handle_influencer_collaboration", + ], + "product": [ + "get_product_info", + ], + "image": [ + "generate_marketing_image", + ], } @@ -55,10 +82,24 @@ def from_env(cls, domain: str | None = None) -> "MCPConfig": if not all([url, name, description, tenant_id, client_id]): raise ValueError(f"{cls.__name__}: missing required environment variables") - # NOTE: URL rewriting to //mcp is disabled because the - # currently-deployed MCP server only exposes the catch-all /mcp - # endpoint. We rely on the client-side ``allowed_tools`` filter - # below to scope the LLM's tool surface to the right domain. + # Rewrite base URL to the domain-scoped endpoint so the agent + # connects to e.g. ``http://host:9000/hr/mcp`` instead of the + # catch-all ``/mcp``. The MCP server mounts per-domain FastMCP + # sub-apps at ``/`` (see mcp_server.py), each serving + # only that domain's tools plus shared services (ask_user). + # The ``allowed_tools`` client-side filter below acts as a + # redundant safety net in case the server layout changes. + if domain: + stripped = url.rstrip("/") + if stripped.endswith("/mcp"): + # Base URL includes the /mcp path (e.g. https://host/mcp) + # → insert domain before /mcp: https://host/hr/mcp + stripped = stripped[: -len("/mcp")] + url = stripped + f"/{domain}/mcp" + else: + # Base URL has no /mcp suffix → append /{domain} + url = stripped + f"/{domain}" + allowed_tools = DOMAIN_ALLOWED_TOOLS.get(domain) if domain else None return cls(