web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Copilot Agent for MCP:...
Copilot Studio
Suggested Answer

Copilot Agent for MCP: Parameterize MCP server url for an agent

(0) ShareShare
ReportReport
Posted on by
Hello Team, 
 
I am from Simplicontract and ours is a SaaS based product. We would like to create agents using Microsoft Copilot Studio that can connect to our MCP servers. We have created a sample agent and attached our mcp server using MCP tool and it works fine. But there is a probelm we see. We use Keycloak as identity provider and Spring AI for MCP servers. Keycloak exposes tenant specific token and authorization end points, they are unique for each tenant. The url to our mcp server is dynamic having tenant information in that. For example, for customer abc the mcp url is https://app.simplicontract.com/tenants/abc/mcp and for customer xyz the url is https://app.simplicontract.com/tenants/xyz/mcp. It has to be like this because, that is the only way our mcp server can identify issuer (Keycloak) and provide the mcp client with the appropriate issuer url during the initiali handshake between MCP client (Copilot agent) and our MCP server. But mcp server url is static and  I do not see an option to parameterize the mcp server url while configuring the MCP tool for the agent. This means that we need to create as many agents as the tenants and publish them. Is there a way to solve this problem? Your timely help is much appreciated.
 
Thanks,
 
Lakshmi
  • Suggested answer
    Mohsin Ali Profile Picture
    1,073 on at
    Hello @NH-10091149-0 -  As of now, Copilot Studio does not provide a way to dynamically parameterize the MCP server URL at runtime. The server URL is configured when the MCP server/tool is added.

    Instead of creating a separate agent for every tenant, I would suggest exposing a single MCP endpoint and handling tenant identification/routing within the MCP server, based on the authenticated user, token claims, or another tenant identifier. with this approach, following will be your setup.

    Copilot Studio → Single MCP endpoint → Identify tenant → Route to tenant backend

  • Suggested answer
    M Bilal Khan Profile Picture
    376 on at
    Hi @NH-10091149-0,

    I don't think you need to create one Copilot Studio agent per tenant, but I also don't see a supported way to directly parameterize the MCP Server URL in the MCP tool configuration.

    The current Copilot Studio MCP configuration expects a concrete HTTPS Server URL when the MCP server is added. Copilot Studio connects to that URL during the MCP handshake and reads the tools exposed by the server.

    So something like:

    https://app.simplicontract.com/tenants/{tenant}/mcp
    

    shouldn't be assumed to work as a runtime template.

    I would change the MCP architecture slightly

    Instead of making the tenant part of the MCP URL:

    Copilot Studio
          ↓
    https://app.simplicontract.com/tenants/abc/mcp
    https://app.simplicontract.com/tenants/xyz/mcp
    

    expose a single stable MCP endpoint:

    Copilot Studio
          ↓
    https://app.simplicontract.com/mcp
          ↓
    Tenant resolution / authentication
          ↓
    Keycloak
          ↓
    Tenant-specific backend
    

    Then make the tenant a property of the authenticated identity/context rather than part of the MCP server URL.

    This is particularly relevant because Copilot Studio's MCP authentication supports OAuth 2.0, including dynamic discovery and dynamic/manual configuration. The dynamic discovery option allows the MCP client to discover the required OAuth endpoints from the server's discovery mechanism.

    For your Keycloak scenario

    If each customer has a different Keycloak issuer, I'd investigate whether you can make the single MCP endpoint determine the tenant from the authenticated user/token and then select the appropriate issuer internally.

    Conceptually:

    User
      ↓
    Copilot Studio
      ↓
    https://app.simplicontract.com/mcp
      ↓
    Authenticate
      ↓
    Identify tenant = abc
      ↓
    Keycloak issuer for abc
      ↓
    Tenant-specific MCP operations
    

    rather than:

    Tenant ABC → /tenants/abc/mcp
    Tenant XYZ → /tenants/xyz/mcp
    

    The current Copilot Studio documentation explicitly supports OAuth 2.0 authentication for MCP servers, including dynamic discovery where the client discovers the necessary authorization endpoints.

    One important distinction

    If your reason for having a tenant-specific URL is only to allow the MCP server to discover which Keycloak issuer to use, I'd move that tenant-resolution logic behind the MCP endpoint if possible.

    If the tenant-specific URL is an actual hard security boundary and the server cannot determine the tenant from the authenticated identity/token, then I don't see a documented Copilot Studio feature that would dynamically substitute {tenant} into the MCP Server URL at runtime.

    In that case, your options would be closer to:

    Option A — Preferred
    One MCP endpoint
    → resolve tenant from identity/token
    → tenant-specific Keycloak/backend
    

    or:

    Option B
    One stable MCP gateway
    → determine tenant
    → proxy to /tenants/{tenant}/mcp
    

    or, if neither is possible:

    Option C
    One agent/MCP configuration per tenant
    

    I would not recommend Option C for a SaaS product with potentially hundreds or thousands of tenants unless there is no way to centralize the MCP endpoint.

    Also, because MCP support and authentication configuration are still evolving in Copilot Studio, I would avoid relying on undocumented URL templating or internal configuration values. Microsoft currently documents the Server URL as a configured endpoint, and the documented dynamic functionality is around OAuth discovery/authentication rather than runtime MCP URL substitution.

    So the architectural question I'd take back to the Simplicontract team is:

    Can the MCP gateway identify the tenant from the authenticated Keycloak identity/token instead of requiring the tenant in the MCP URL?

    If yes, a single Copilot Studio agent/MCP tool configuration should be a much cleaner SaaS architecture.

  • Suggested answer
    Mohsin Ali Profile Picture
    1,073 on at
    Hello @NH-10091149-0 - Just wanted to see if the suggestions provided above really help or pointed in right directions.
     

  • Suggested answer
    Dua Sadiq Profile Picture
    129 on at

    Hello @NH-10091149-0 Lakshami!

    The idea: instead of pointing Copilot Studio's native MCP tool at a fixed URL, build one custom connector in Power Platform that sits in front of your MCP server. The connector shows a dropdown of tenants, and a small script rewrites the outgoing request to the correct tenant path before it ever reaches your server.

     

    How it works:


    1. A small "catalog" endpoint (can live anywhere  even a lightweight endpoint on your existing backend) returns your list of tenant IDs/names.

    2. The custom connector's Swagger uses x-ms-dynamic-values on a tenantId parameter, pointing at that catalog  this renders as a dropdown when the tool is configured.

      [Screenshot: Swagger editor showing the ListInstances + InvokeMCP operations, with x-ms-dynamic-values visible]

    3. A C# script inside the connector (script.csx) intercepts the outgoing MCP call, reads whichever tenant was picked, and rewrites the request URL to https://app.simplicontract.com/tenants/{tenantId}/mcp  exactly the URL your server already expects. Nothing about your issuer-resolution logic changes.

    4. One agent, one connector  the tenant picker replaces the need to publish a separate agent per customer.


    5.  
     

    Proof it actually works: I tested this exact mechanism in my own Copilot Studio environment (using a stand-in catalog + a minimal fake MCP server to simulate two tenants, since I don't have access to Simplicontract's real backend). Picking a tenant from the dropdown correctly discovers that tenant's tools:



     

    This confirms end-to-end: dropdown selection → dynamic URL rewrite → correct tenant endpoint → correct tool discovery  all through a single connector/agent.

     

    Credit to the Microsoft Copilot Studio CAT team, who published the underlying pattern here: Dynamic MCP Routing in Copilot Studio I adapted their sample to a path-based multi-tenant scenario like yours.

     

    One caveat: this requires custom code (C#) in connectors to be allowed in your Power Platform environment  worth checking your DLP/governance settings first. If C# scripting is blocked, the fallback is a small API-gateway/proxy layer in front of your MCP server doing the same host-rewrite based on a header instead.

     

    Happy to share the Swagger/script if useful.

     

    Thanks,

    Dua

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Copilot Studio

#1
Mohsin Ali Profile Picture

Mohsin Ali 360

#2
Valantis Profile Picture

Valantis 253 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 184 Super User 2026 Season 2

Last 30 days Overall leaderboard