Skip to main content
GitHub Copilot provides inline code completions and agent workflows. Copilot CLI, VS Code Agent mode, and the cloud coding agent can run shell commands, edit files, and call external tools. TrustGuard hooks evaluate prompt submissions, tool calls, and tool results. Local hooks run on the developer’s machine; cloud coding-agent jobs use hooks committed to the repository. Cloud coding-agent jobs have no interactive user, so Copilot treats Ask as denied. Microsoft Copilot Studio is a separate product. See Microsoft Copilot Studio.

NeuralTrust controls

Install TrustGuard from the trustguard-copilot-plugin. Configure TrustGate separately as a remote MCP server in Copilot’s MCP config.

Deployment options

Use separate credentials for TrustGuard and TrustGate. The hooks use a tgk_… collector key in copilot.json. MCP authenticates as a consumer with OAuth or an ag_… API key. A tgk_… key does not authenticate MCP.

Before you start

Create the policy in Observe mode. Observe records decisions in Activity without enforcing them. Review the results, then switch the policy to Enforce. See Policies.
Developers do not need NeuralTrust accounts for the hooks path.

Set up prompt and tool screening (TrustGuard)

Pilot: Copilot CLI plugin

  1. Add the marketplace and install the plugin:
  2. Write the API key config to ~/.trustguard/copilot.json and chmod 600 it:
Environment variables override that file. See Configuration.

Enterprise: policy hooks

IT deploys policy hooks, which Copilot CLI loads machine-wide before user, repository and plugin hooks. Developers cannot disable them: disableAllHooks does not apply to policy hooks. The Kandji scripts install four pieces: The managed config is the same JSON shape as the pilot file, carrying the org tgk_… key. The policy hook file calls the wrapper, not the collector directly. TRUSTGUARD_COPILOT_BIN overrides the platform-specific binary lookup.

VS Code Agent mode

Install the plugin from your organization marketplace. Agent hooks are currently a VS Code preview feature, so confirm enterprise policy permits hooks and controls which marketplace sources are allowed before you roll out.

Cloud coding agent

Cloud jobs do not load local plugins, user hooks, MDM files, or policy hooks. They load hooks committed under .github/hooks/*.json. Configure them as follows:
  1. Commit a Copilot hook file under .github/hooks/.
  2. Make the collector binary available in the job image, or use an HTTP hook endpoint that accepts Copilot’s event payload.
  3. Add the TrustGuard host to the cloud-agent firewall allowlist.
  4. Provide credentials through the approved GitHub environment mechanism.
Ask behavior in cloud jobs. The collector still returns permissionDecision: "ask", but no interactive user is available to respond. Copilot treats the unresolved approval as denied. Use a Block policy action for cloud jobs that must stop the tool call. userPromptSubmitted remains audit-only there too.

Set up governed tool access (TrustGate)

Copilot treats TrustGate as a remote HTTP MCP server: one url per MCP consumer, and Copilot Chat sees the merged toolkit that consumer is routed to. Copy the endpoint from the consumer’s Connect tab:
Create .vscode/mcp.json in the workspace, or use the user MCP config your VS Code version provides. OAuth2 consumers (recommended). Use OAuth2 where Copilot can complete the browser login. Omit headers:
API-key consumers. Send the ag_… consumer key as a header. Do not use a TrustGuard tgk_… key:
Private (Hybrid) data plane. Add the gateway slug to headers:
Reload the window. In Copilot Chat, enable the TrustGate MCP server if it is listed but disabled; the first OAuth connect may open a browser.
The top-level key is servers or mcpServers, depending on your VS Code and Copilot version. If the file is ignored, paste the JSON tab from the consumer’s Connect page into the MCP configuration UI instead.

Verify

Hooks.
  1. Run Copilot CLI, send a test prompt, then trigger a shell tool call.
  2. Confirm both events in TrustGuard Activity. They carry source.application = copilot-plugin. The prompt is audit-only; enforcement applies at tool events.
Smoke-test the binary (optional):
MCP.
  1. In Copilot Chat, list tools or invoke one bound on the consumer.
  2. Confirm the call in TrustGate telemetry. See Metrics.

Reference

Coverage

TrustGuard receives prompt submissions, tool calls, and tool results from Copilot CLI, VS Code Agent mode, and cloud coding-agent jobs. Copilot discards command-hook output at userPromptSubmitted, so prompts are audit-only. Block and Ask apply to tool calls; a Block on a tool result flags or replaces the result after the call has run. Ask. Copilot honors Ask on tool calls by displaying its approval prompt. There is no user to prompt in the cloud coding agent, so Copilot treats the unresolved approval as denied. Use a Block policy action for cloud jobs that must stop the call. Limits. Inline code completions (ghost text) expose no hooks. The hooks also do not evaluate model responses or tool declarations. Use TrustGate to control which tools are available. Tool-result handling depends on the payload. For a native Copilot payload, a Block verdict adds untrusted-result guidance to additionalContext and replaces the entire tool output with [Tool result redacted by TrustGuard] through modifiedResult. For a VS Code-compatible snake_case payload, it emits decision: "block" with a reason and leaves the result intact. Neither behavior can undo a tool call that has already run. Full comparison: Coverage.

What is evaluated

Every hook calls POST /v1/evaluate with the collector tgk_… key, and the policy’s detectors decide the verdict. MCP tool calls pass through the hooks like any other tool call, including tools served by TrustGate.

Configuration

copilot.json (TrustGuard only). Keys: data_url, api_key, fail_mode, plus optional consumer_id. The managed copy is deployed by MDM to the per-OS path in the table above; the pilot copy lives at ~/.trustguard/copilot.json (chmod 600). Environment variables override the user file:
Hook precedence. Copilot CLI loads policy hooks machine-wide before user, repository and plugin hooks, and disableAllHooks does not apply to them. That ordering prevents developers from disabling the MDM-deployed hooks. Failure behavior. Normal data-plane errors follow the configured fail_mode. Two installation failures are handled separately, and only by the policy-hook wrapper: The marketplace plugin bootstrap does not make that distinction: it fails open in both cases. If a personal install is incomplete it emits {} and exits 0 on purpose, because Copilot’s preToolUse command hooks fail closed on non-zero exits. This prevents an incomplete plugin installation from blocking Copilot. mcp.json (TrustGate only). Workspace file .vscode/mcp.json, or the user MCP config your VS Code version uses. TrustGate is always "type": "http" with a url. Auth is X-AG-API-Key with an ag_… consumer key, plus X-AG-Gateway-Slug on a private (Hybrid) data plane; OAuth2 consumers send no headers. The top-level key is servers or mcpServers depending on version. Deployment ownership.

Attributes

  • attributes.source.application = "copilot-plugin"
  • attributes.copilot.*, containing the full hook stdin JSON
  • consumer_id is sent only when configured explicitly, via TRUSTGUARD_CONSUMER_ID or consumer_id in copilot.json
Every decision appears in Activity under source.application = copilot-plugin. Gate on source.application and the tool name or command. Set consumer_id explicitly for per-developer attribution; this collector does not infer one.

Troubleshooting