connect — Claude Code and Copilot subagent
A subagent that attaches one Prompt or Hosted agent to a Microsoft Foundry knowledge base, and can create the agent if it is missing.
/plugin marketplace add microsoft/skills
/plugin install foundry-iq-skills@skillsWhat connect does
connect handles the tedious half of a Foundry integration: it locates the agent in your project, reads its current state, drafts a change plan and asks for approval before writing anything. Both Prompt and Hosted agents are covered. On the Prompt side the link is an MCP tool named knowledge_base_retrieve; the Hosted path follows its own procedure.
Access to the Azure project and the right roles come first. The subagent needs the exact project identity.principalId, and Search Index Data Reader is assigned at Search-service scope. Miss that and retrieval does not run. Creating a new agent requires its own approval; declining an install is not consent. Answers must rest on retrieved evidence, so an unsupported question gets a literal I don't know back with no citations.
The rules are strict. Swapping the knowledge base model, or quietly normalising it, is blocked. Name collisions block as well: the connection name matters more than the endpoint, so an approved new name may share an endpoint with an older connection. Post-write checks include a knowledge_base_retrieve call with original citations plus an off-topic question that should return I don't know.
What it helps with
- attach a knowledge base to a single Prompt agent
- create a missing Foundry agent from an approved plan
- grant index-read roles to the project principal ID
- confirm the agent answers only from retrieved citations
- wire up a Hosted agent without disturbing its settings
Example prompts for the agent
- Connect the knowledge base to the agent in my project and show the plan first
- Verify the setup: run
knowledge_base_retrieveand ask something off-topic - No agent exists yet — walk me through installing one or creating it via Prompt CLI
How to install connect
1Plugin marketplace
/plugin marketplace add microsoft/skills/plugin install foundry-iq-skills@skills2Manually: put the files in place
.claude/agents/connect.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/connect.tomlCodex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/
Manually: put the files in place
.cursor/agents/connect.mdCursor also reads .claude/agents/
Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean
Questions about connect
How do I install connect in Claude Code?
Run /plugin marketplace add microsoft/skills first, then /plugin install foundry-iq-skills@skills. The subagent lands in .claude/agents/connect.md.
What does connect do?
It binds one Microsoft Foundry agent to a knowledge base. If the agent does not exist, it can create one, but only with separate approval.
Why does the connection fail without a role assignment?
Index reads need Search Index Data Reader at Search-service scope for the project identity.principalId. Without it, the knowledge_base_retrieve call cannot succeed.
Source text
connect.md · MIT
# Connect a knowledge base to an agent ## When to use Connect one Prompt/Hosted Agent; optionally create it if missing. KB: content; project connection: auth; agent MCP tool: versioned use. ## Do not use Do not replace agents, attach multiple base tools, or handle base-free lifecycle. Permission error is not absence; creation approval is separate. ## Inputs and discovery order Resolve prompt, session, workspace, exact Azure readback, default, then one focused question. Label sources; missing input blocks. Reads need no approval; silence approves nothing. | Input | Why needed | Required? | Discovery order | Safe default | If missing or unanswered | Reconfirmation trigger | |---|---|---|---|---|---|---| | Base return/MCP endpoint | Grounding | Required | Session, exact proof | None | Block | Base/API/evidence change | | Project ID/endpoint | Target | Required | Prompt, workspace, readback | None | Block | ID/tenant change | | Agent name/inventory/type | Identity | Required | Prompt, readback | Never latest/type | Block ambiguity | Inventory/type | | Definition/model/baseline; Hosted telemetry | Preservation | By branch | Exact readback | Preserve unrelated fields | Block | Protected state | | Connection/tool; Hosted toolbox/environment | Binding | By branch | Full readback | One retrieve binding | Block conflict | Binding/endpoint | | Principal/reader role | Retrieval | Before assignment | Readback | Exact Search scope | Block | Assignment | | Grounding delta | Evidence | Required | Instructions | Base/citations/`I don't know` | Block loss | Delta | | Acceptance/unrelated questions | Verification | Before invocation | Authorized evidence | None | Propose candidate | Questions | | Cleanup/retention owner | Ownership | Required | Prompt/session | None | Block | Owner | | Provider/install or CLI choice | Missing agent | Conditional | Runtime, then choice | No automatic fallback | Block | Availability/choice | ## Decisions Use [policy diagnostics](../references/search-substrate.md#azure-policy-diagnostics-after-creation-failure) only after a creation failure implicates policy, never as a gate. Read exact IDs/all scoped pages; inaccessible is not absent: - **Prompt:** refresh the selected version and all its scoped version pages after portal add/remove; never assume latest. Exact is zero-write. Collision is the connection NAME, not KB endpoint: an approved new name can share that endpoint, preserving legacy/key connections. Same-name mismatch blocks. An explicit selected-tool switch creates a version, preserving all unrelated fields/tools. - **Hosted:** inspect remote project, exact agent/version, KB MCP, runtime principal and connection/toolbox/binding first: no source path for inspection or exact reuse. Bind source/config digest for agent edits/redeployment. Conflicts block. Read [Hosted connection](connect-hosted.md) before plans or verification. Only for a missing agent, load [missing-agent creation](create-missing-agent.md) before questions/plans. Prefer `microsoft-foundry`: delegate approved identity/configuration and known requirements. Otherwise offer installation or Prompt CLI creation. Installation refusal is not creation approval. Require a typed return with project, agent, version/deployment, model/status/identity and definition/source/config/environment. Independently read back; use fresh discovery and a new fingerprinted connection plan; never carry creation approval. Incomplete returns block. Read the authenticated `knowledgebases` API, never generated indexes or `foundryextensions_knowledge_index_list`. Existing multi-source KBs are valid. Preserve valid KB effort/output/models; preview MCP supports reasoning/synthesis. Use the exact preview API in SDK; native GA minimal/extractive MCP exists. KB model: low or medium with supported output; preview minimal/answerSynthesis is valid. Use the approved [KB transition](../knowledge-bases/create.md#agent-compatible-minimal-transition) only when an explicit model-free normalization is needed. Never change the KB implicitly or add a model as a workaround. Only when authenticated Foundry MCP is unavailable or lacks a required operation, load [typed Prompt SDK fallback](connect-prompt-sdk-fallback.md). Denial/conflict blocks. Bind the surface; switching requires fresh review, never bypass. ## Proposed plan List delta, API, identity/scope, network/data, cost, verification, owner and retained IDs. ## Confirmation Approve concrete changes once; `plan_fingerprint` stays internal, with `cleanup_approved: false`. Delegated creation is separate. A Hosted principal known only after deploy requires a separate RBAC plan. Material/protected-state drift invalidates approval; disclose bounded Prompt warnings below. ## Mutation After confirmation, use exact identities; never retry another name. **Prompt:** Use the planned MCP or SDK surface; never invent operations. Reconcile one `2025-10-01-preview` `RemoteTool` connection with `ProjectManagedIdentity`, Search audience, and the `2026-08-01-preview` KB MCP endpoint. Require the exact Search-service-scoped `Search Index Data Reader` assignment to observed PROJECT `identity.principalId`, not agent identity. Preserve all fields; add/switch at most one same-label `MCPTool` with exact endpoint/connection, `allowed_tools: ["knowledge_base_retrieve"]`, and `require_approval: "never"`. Under the same agent name, require retrieval for every question, including unrelated questions. Answer from retrieved evidence, not general knowledge; unsupported answers are exactly `I don't know` without citations; retrieval errors must remain errors. Approve exact appended instructions; preserve previous instructions/versions. Duplicate labels block. Search provisioning alone is not a connection-write blocker when the KB GET is healthy; warn, never claim retrieval readiness. Failed/auth/deletion states block. After exact identity/binding checks, `type` metadata differences and boolean `isSharedToAll: true`-to-`false` restriction warn without rewriting. Missing/malformed sharing, broader access, wrong target/auth/audience/category/required metadata block. Apply the same rules to reuse; require actual agent tests below. **Hosted:** Follow the selected [Hosted connection](connect-hosted.md) procedure. Only approved missing resources, binding differences and required deployments are writes; exact existing state skips them all. Never replace agents; source edits need separate review/handoff. ## Verification Verify protected fields, a `knowledge_base_retrieve` call with original citations, and unrelated `I don't know` without citations. Preserve behavior; rerun with stable IDs and zero configuration writes. Account separately for requested invocations, conversations/sessions and their usage. Record actual tool execution and returned evidence separately from answer behavior; unavailable payloads leave payload-level faithfulness unverified, not an inferred empty result. ## Failure and partial completion Preserve first status/message/request ID. Denial, conflict, incomplete delegation, failed citations, unknown principal or drift blocks. Record writes, evidence, ownership, recovery and warnings; never widen state. ## Cleanup Separate fingerprinted cleanup deletes only run-owned artifacts in reverse. Prompt uses `helpers/prompt_cleanup.py` with exact digests. Hosted returns `hosted-cleanup-unsupported`, zero writes, retaining all resources. Unclear ownership blocks. ## Return contract Return `planned`/`completed`/`blocked`/`partial`: exact actions/resources, invocation/readback evidence, ownership, failure, warnings and cleanup status. ## References - [Shared audit schemas](../references/platform-contracts.md). - [Interface versions](../references/platform-interfaces.md). Authorities: failure/conflict/uncertainty only. - [Connect Agents to Foundry IQ knowledge bases](https://learn.microsoft.com/azure/foundry/agents/how-to/foundry-iq-connect)
© Microsoft · MIT · microsoft/skills