|
20 | 20 | # so the LLM only sees the relevant subset (avoids cross-pack tool confusion when |
21 | 21 | # the MCP server exposes every function at the base /mcp endpoint). |
22 | 22 | DOMAIN_ALLOWED_TOOLS: dict[str, list[str]] = { |
23 | | - "image": ["generate_marketing_image"], |
| 23 | + "hr": [ |
| 24 | + "get_workflow_blueprint", |
| 25 | + "schedule_orientation_session", |
| 26 | + "assign_mentor", |
| 27 | + "register_for_benefits", |
| 28 | + "provide_employee_handbook", |
| 29 | + "initiate_background_check", |
| 30 | + "request_id_card", |
| 31 | + "set_up_payroll", |
| 32 | + ], |
| 33 | + "tech_support": [ |
| 34 | + "get_workflow_blueprint", |
| 35 | + "send_welcome_email", |
| 36 | + "set_up_office_365_account", |
| 37 | + "configure_laptop", |
| 38 | + "setup_vpn_access", |
| 39 | + "create_system_accounts", |
| 40 | + ], |
| 41 | + "marketing": [ |
| 42 | + "generate_press_release", |
| 43 | + "handle_influencer_collaboration", |
| 44 | + ], |
| 45 | + "product": [ |
| 46 | + "get_product_info", |
| 47 | + ], |
| 48 | + "image": [ |
| 49 | + "generate_marketing_image", |
| 50 | + ], |
24 | 51 | } |
25 | 52 |
|
26 | 53 |
|
@@ -55,10 +82,24 @@ def from_env(cls, domain: str | None = None) -> "MCPConfig": |
55 | 82 | if not all([url, name, description, tenant_id, client_id]): |
56 | 83 | raise ValueError(f"{cls.__name__}: missing required environment variables") |
57 | 84 |
|
58 | | - # NOTE: URL rewriting to /<domain>/mcp is disabled because the |
59 | | - # currently-deployed MCP server only exposes the catch-all /mcp |
60 | | - # endpoint. We rely on the client-side ``allowed_tools`` filter |
61 | | - # below to scope the LLM's tool surface to the right domain. |
| 85 | + # Rewrite base URL to the domain-scoped endpoint so the agent |
| 86 | + # connects to e.g. ``http://host:9000/hr/mcp`` instead of the |
| 87 | + # catch-all ``/mcp``. The MCP server mounts per-domain FastMCP |
| 88 | + # sub-apps at ``/<domain>`` (see mcp_server.py), each serving |
| 89 | + # only that domain's tools plus shared services (ask_user). |
| 90 | + # The ``allowed_tools`` client-side filter below acts as a |
| 91 | + # redundant safety net in case the server layout changes. |
| 92 | + if domain: |
| 93 | + stripped = url.rstrip("/") |
| 94 | + if stripped.endswith("/mcp"): |
| 95 | + # Base URL includes the /mcp path (e.g. https://host/mcp) |
| 96 | + # → insert domain before /mcp: https://host/hr/mcp |
| 97 | + stripped = stripped[: -len("/mcp")] |
| 98 | + url = stripped + f"/{domain}/mcp" |
| 99 | + else: |
| 100 | + # Base URL has no /mcp suffix → append /{domain} |
| 101 | + url = stripped + f"/{domain}" |
| 102 | + |
62 | 103 | allowed_tools = DOMAIN_ALLOWED_TOOLS.get(domain) if domain else None |
63 | 104 |
|
64 | 105 | return cls( |
|
0 commit comments