skills/add-knowledge/SKILL.md
Add a knowledge source (public website or SharePoint) to a Copilot Studio agent. Use when the user asks to add a knowledge source, documentation URL, website, or SharePoint site for the agent to search.
npx skillsauth add microsoft/skills-for-copilot-studio skills/add-knowledgeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Add a knowledge source to the agent. Supports Public Website, SharePoint, and Custom API sources.
Auto-discover the agent directory:
Glob: **/agent.mcs.yml
NEVER hardcode an agent name.
Parse the arguments to extract:
Determine the source type from the user's request:
sharepoint.com → use SharePointSearchSource (but first normalize the URL — see below)OnKnowledgeRequested (see Custom API section below)PublicSiteSearchSourceIf SharePoint: normalize the URL before using it. Copilot Studio requires a direct folder path like:
https://contoso.sharepoint.com/sites/MySite/Shared%20Documents/MyFolder
Users often paste URLs in other formats. Handle them as follows:
| URL pattern | Example | Action |
|---|---|---|
| Direct path (/sites/.../Shared%20Documents/...) | https://x.sharepoint.com/sites/Site/Shared%20Documents/Folder | Use as-is — this is the correct format |
| AllItems.aspx with ?id= param (...AllItems.aspx?id=...) | https://x.sharepoint.com/.../AllItems.aspx?id=%2Fsites%2FSite%2FShared%20Documents%2FFolder&viewid=... | Extract and decode the id query parameter. URL-decode it to get the path (e.g. /sites/Site/Shared%20Documents/Folder), then prepend the origin (https://x.sharepoint.com) to build the direct path. Drop all query parameters (?id=, &viewid=, etc.) |
| Sharing link (/:f:/s/... or /:x:/s/...) | https://x.sharepoint.com/:f:/s/Site/EncodedToken?e=abc | Cannot convert — these are opaque sharing tokens with no extractable folder path. Ask the user: "That's a SharePoint sharing link — I can't extract the folder path from it. Could you navigate to the folder in SharePoint, copy the URL from the browser address bar, and paste it here?" |
Encoding rule: Spaces in the final URL must be encoded as %20 (e.g. Shared%20Documents, not Shared Documents).
Look up the knowledge source schema:
node ${CLAUDE_SKILL_DIR}/../../scripts/schema-lookup.bundle.js resolve KnowledgeSourceConfiguration
Generate the knowledge source YAML.
Public Website:
PublicSiteSearchSourceuses Bing search to find relevant snippets within the scoped URL. It does not crawl or summarize full pages. The URL defines a search scope (not a specific page), and supports a maximum depth of 2 levels beyond the domain (e.g.https://example.com/docs/apiworks,https://example.com/docs/api/v2is too deep and will be ignored).
# Name: <Name>
# <Description of what this knowledge source provides>
kind: KnowledgeSourceConfiguration
source:
kind: PublicSiteSearchSource
site: https://www.example.com/docs
SharePoint:
# Name: <Name>
# <Description of what this knowledge source provides>
kind: KnowledgeSourceConfiguration
source:
kind: SharePointSearchSource
site: https://contoso.sharepoint.com/sites/MySite/Shared%20Documents/MyFolder
Always include # Name: and a description comment at the top. These are important for identifying the knowledge source.
Save to the agent's knowledge/<descriptive-name>.knowledge.mcs.yml directory
When the user wants to connect a proprietary search API or database not natively supported by Copilot Studio, use the OnKnowledgeRequested trigger. This is a YAML-only capability with no UI designer — it intercepts knowledge search requests and lets you call a custom API to populate results.
How it works:
OnKnowledgeRequested triggerSystem.SearchQuery (the AI-rewritten query) as input to your API callContent, ContentLocation, TitleSystem.SearchResults with the transformed resultsUse the template: ${CLAUDE_SKILL_DIR}/../../templates/topics/custom-knowledge-source.topic.mcs.yml
Prerequisites: The user needs a connector action (in actions/) that calls their search API. If they don't have one yet, they should create it through the Copilot Studio UI or VS Code extension first.
Knowledge source URLs support {VariableName} placeholders — typically global variables — for dynamic routing based on user context. This is powerful for scenarios where different users need different knowledge sources (e.g., geolocation-specific SharePoint folders, region-specific documentation).
Pattern: Define a global variable (via /copilot-studio:add-global-variable), populate it early in the conversation (e.g., in an OnActivity/conversation-init topic based on user profile or geolocation), then reference it in the knowledge source URL with Power Fx string interpolation.
SharePoint example — a workforce agent that routes to different SharePoint folders per region:
# Name: Regional HR KB
# This knowledge source provides HR information from the {Global.UserKBURL} SharePoint.
kind: KnowledgeSourceConfiguration
source:
kind: SharePointSearchSource
site: =$"{Global.UserKBURL}"
Public website example — documentation site with region-specific subpaths:
# Name: Regional Docs
# Documentation for the user's region at {Global.Region}.
kind: KnowledgeSourceConfiguration
source:
kind: PublicSiteSearchSource
site: =$"https://docs.example.com/{Global.Region}/api"
CRITICAL: URL format for the global variable value. The variable must contain a direct, clean URL — not a SharePoint UI URL with query parameters. Copilot Studio cannot resolve AllItems.aspx links.
| Correct (set this in the global variable) | Wrong (will not work) |
|---|---|
| https://contoso.sharepoint.com/sites/MySite/Shared Documents/MyFolder | https://contoso.sharepoint.com/.../AllItems.aspx?id=%2Fsites%2F...&viewid=... |
Note: spaces are OK in the variable value (unlike static site: values which need %20), because the Power Fx $"{Global.UserKBURL}" expression handles encoding at runtime.
Implementation checklist when the user asks for dynamic knowledge:
/copilot-studio:add-global-variable (e.g., UserKBURL, Region)=$"{Global.VariableName}" syntax in the site: fieldFor detailed guidance on how knowledge retrieval works, source selection, content quality, security, maintenance, and advanced patterns like triggerCondition, see knowledge-guide.md.
This skill can create Public Website and SharePoint knowledge sources.
For other types, inform the user:
"The following knowledge source types must be created through the Copilot Studio UI as they require Power Platform configuration:
- Dataverse tables
- Uploaded files
- AI Search
- SQL Server
Please create these in the portal, then clone the solution to edit them here."
testing
Validate Copilot Studio agent YAML files using the LSP binary's full diagnostics (YAML structure, Power Fx, schema, cross-file references). Use when the user asks to check, validate, or verify YAML files.
development
Authenticate for Copilot Studio evaluation API and SDK chat. Caches a token that is shared across run-eval and chat-sdk skills. Run this before any eval or SDK chat workflow. Requires an App Registration with MakerOperations and Copilots.Invoke permissions.
development
Run a batch test suite via the Copilot Studio Kit (Dataverse API). Uses the Power CAT Copilot Studio Kit to execute test cases against a published agent and produces pass/fail results with latencies. Requires the Kit installed in the environment, an App Registration with Dataverse permissions, and a published agent.
development
Run evaluations against a Copilot Studio agent via the Power Platform Evaluation API. Works on DRAFT agents — no publish step required. Lists test sets, starts a run, polls until complete, fetches results, and proposes YAML fixes for failures. Use when the user wants to test agent changes without publishing.