Expose only the tools you allow from a vendor's MCP server
December 02, 2026
A vendor ships a remote MCP server with 40 tools. You want Copilot Cowork or Copilot Studio to use four of them. You can’t edit the vendor’s server, and the vendor has no reason to build you an allowlist. The Copilot Plugin Filtered MCP Template sits between your agent and that server as a Power Platform custom connector, forwards only the tools you name, and keeps the rest invisible.
Clone the folder once per upstream server, point it at the real endpoint, and name the tools you want. Everything the upstream server advertises that you didn’t name stays permanently uncallable, because nothing in the connector ever references its name.
One allowlist, two consumption paths
This connector gets called two different ways, and each one needs its own filter.
Copilot Cowork invokes a Power Platform connector by its REST operation Id, not by MCP tool name. It never consults the upstream server’s tools/list for this path — the only tools Cowork can reach are the ones with their own typed operation in apiDefinition.swagger.json.
Copilot Studio, and any other MCP client, talks to the connector’s InvokeMCP operation as real MCP JSON-RPC. For that path, script.csx fetches the upstream server’s actual tools/list, filters it down to the allowlist before returning it, and rejects tools/call for anything that isn’t on that list.
Both paths read from the same dictionary:
private static readonly Dictionary<string, string> AllowedTools = new Dictionary<string, string>
{
// TODO: generated entries go here, e.g.:
// ["SearchTickets"] = "search_tickets",
["ExampleTool"] = "example_tool"
};
Add a tool here once, and it’s reachable from both surfaces. Leave it out, and it’s reachable from neither, no matter what the upstream server advertises.
ExecuteAsync() dispatches on this.Context.OperationId. If the operation matches an AllowedTools key, it calls that tool directly. If it’s InvokeMCP, it hands off to the JSON-RPC switch for initialize, tools/list, and tools/call — each filtered against the same map.
Setting it up
- Copy the folder to a new top-level connector named for the service you’re wrapping, for example
Contoso MCP Proxy/. - Point it at the real server. In
apiDefinition.swagger.json, sethostto the upstream server’s hostname, and make sure the/mcppath matches its real JSON-RPC endpoint. If the path differs, update both the swagger path and theUpstreamMcpPathconstant inscript.csx. - Set the upstream credential. The template ships with a static API key (
connectionParameters.api_key), forwarded asAuthorization: Bearer <key>through asetheaderpolicy. If the upstream server needs full OAuth instead, swap that connection parameter for anoauthSettingblock —script.csxalready reuses whatever the platform attaches to the inbound request’sAuthorizationheader, so no script changes are needed either way. - Choose which tools to allow, using the prompt below.
- Remove the
ExampleToolplaceholder from all three files once you’ve added at least one real tool. - Validate and deploy: run
ppcv ./<your-connector-folder>, then deploy with the PAC CLI.
Generating the wrappers
generate-tool-wrappers.prompt.md does the repetitive part. Point it at the real upstream server — a URL and credentials, or a pasted tools/list response — and tell it which tools to expose. For each one, it produces three artifacts that have to stay in sync:
- A typed Swagger operation in
apiDefinition.swagger.json - One entry in the
AllowedToolsdictionary inscript.csx - The operationId appended to
scriptOperationsinapiProperties.json
Given an upstream tool like this:
{
"name": "search_tickets",
"description": "Search support tickets by status, assignee, or free-text query.",
"inputSchema": {
"type": "object",
"properties": {
"query": { "type": "string", "description": "Free-text search terms." },
"status": { "type": "string", "enum": ["open", "pending", "solved", "closed"] }
},
"required": ["query"]
}
}
The prompt emits a SearchTickets Swagger operation at a synthetic path (/connector-tools/search-tickets — never sent upstream, since script.csx always redirects allowed-tool calls to the real UpstreamMcpPath), the matching AllowedTools entry, and the scriptOperations append. It keeps the upstream tool’s own description verbatim, because that’s what grounds Copilot’s tool selection, and it never emits $ref — nested schema is inlined, since Power Platform’s schema UI handles flat objects far better than $ref/$defs.
Wiring the result into a plugin or agent
For Cowork, add the deployed connector as an OpenAPI connector reference, not a remote-mcp one, since Cowork calls its REST operations directly:
wiqd plugin add connector --kind openapi --name "<Service> (filtered)" `
--description "Curated subset of <Service> MCP tools" `
--auth-reference-id "<deployed-connector-logical-name>" --dev-preview
--dev-preview is required — OpenAPI connector references in a plugin manifest are devPreview-only.
For Copilot Studio, add the deployed connector directly as an MCP tool. It calls InvokeMCP, which is already filtered to the same allowlist, so there’s nothing extra to configure on that side.
What it costs you
No cross-call session caching. Each script execution is stateless, so every allowed-tool call runs its own initialize handshake against the upstream server before the real call — one extra round trip, every time. SendUpstreamRpcWithHandshakeAsync is where that handshake lives; if your upstream server accepts a bare tools/call or tools/list without it, you can call SendUpstreamRpcAsync directly and skip the extra hop.
Response pass-through is unmodified. The template returns the upstream tool’s result as-is. If upstream responses are too large or need reshaping for Power Platform, add that trimming in InvokeAllowedToolAsync or HandleFilteredToolsCallAsync.
One allowlist, two files to update. Forgetting to append a tool to scriptOperations — even though it’s in AllowedTools and has a Swagger operation — means Power Platform never routes that operation into the script at all. It fails silently as an unscripted call instead of telling you what’s missing.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| A typed operation returns “Unknown operation” | Added to AllowedTools but not to scriptOperations |
Add the operationId to scriptOperations in apiProperties.json |
tools/call through InvokeMCP returns “Tool not available through this connector” |
The MCP client requested a tool name not in AllowedTools.Values |
Confirm the exact upstream tool name is case-sensitive, and add it with the generator prompt |
| 401 from the upstream server | Credential not attached, or the upstream auth type doesn’t match the setheader policy |
Confirm the upstream server’s auth scheme and header name match apiProperties.json |
| Upstream calls time out or fail intermittently | The server expects a persisted Mcp-Session-Id across more than two calls |
Extend SendUpstreamRpcAsync/SendUpstreamRpcWithHandshakeAsync to carry the session ID through any extra calls your tool needs |
When this isn’t the right template
| You have | Use |
|---|---|
| An existing remote MCP server you can’t change, and you want to expose only some of its tools | This template |
| No existing server — you’re authoring tools from scratch against a REST API | Power MCP Template, or Power Mission Control Template for a large API surface |
If you own the API, build typed tools directly instead of proxying through a filter. The value here is specifically for servers you don’t control and can’t trim at the source.