Python: support MCP skills of mcp-resource-template type#6648
Python: support MCP skills of mcp-resource-template type#6648vaibhav-patel wants to merge 1 commit into
Conversation
Add support for the `mcp-resource-template` skill kind in the MCP skills
source. Per the SEP-2640 binding of the Agent Skills Discovery v0.2.0
schema, an `mcp-resource-template` index entry omits `name` and carries an
RFC 6570 URI template in `url` (e.g. `skill://docs/{product}/SKILL.md`)
that resolves to a `SKILL.md` resource once its variables are bound. One
template stands in for a family of skills, one per variable binding.
Introduce `MCPSkillResourceTemplate`, which parses such an entry, exposes
its template variables, and materializes a concrete `MCPSkill` from an
explicit variable binding (RFC 6570 Level-1 simple string expansion, with
values percent-encoded so they cannot inject extra path segments).
`MCPSkillsSource` gains `get_resource_templates()`, which surfaces template
entries separately from `get_skills()`. Concrete skills are not
auto-materialized during discovery because the template variable values are
not part of the index; callers bind them explicitly via `materialize()`.
This keeps `get_skills()` behavior unchanged (template entries remain
excluded from the concrete skill list).
Addresses microsoft#6118.
|
@vaibhav-patel please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
Adds Python support for MCP skill index entries of type mcp-resource-template (RFC 6570 URI templates) by introducing a resource-template abstraction and a parallel discovery path that surfaces templates separately from concrete skills.
Changes:
- Introduces
MCPSkillResourceTemplatewith variable extraction, safe URI expansion (percent-encoding), and explicitmaterialize()to produce concreteMCPSkillinstances. - Extends
MCPSkillsSourcewithget_resource_templates()to discover template entries without auto-materializing skills. - Adds unit tests covering template parsing/expansion/materialization and discovery behavior, and exports the new type from
agent_framework.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| python/packages/core/agent_framework/_skills.py | Adds MCPSkillResourceTemplate and MCPSkillsSource.get_resource_templates() to support discovery/materialization of mcp-resource-template entries. |
| python/packages/core/agent_framework/init.py | Exports MCPSkillResourceTemplate from the package surface (__all__ + imports). |
| python/packages/core/tests/core/test_mcp_skills.py | Adds tests for template behavior and for discovering templates separately from concrete skills. |
| if not url_template or not url_template.strip(): | ||
| raise ValueError("url_template cannot be empty.") | ||
|
|
||
| self.description = description | ||
| self.url_template = url_template | ||
| self._client = client |
| def test_empty_url_template_raises(self) -> None: | ||
| client = AsyncMock() | ||
| with pytest.raises(ValueError, match="url_template cannot be empty"): | ||
| MCPSkillResourceTemplate(description="docs", url_template=" ", client=client) | ||
|
|
Summary
Adds support for the
mcp-resource-templateskill kind to the MCP skills source,addressing #6118.
Per the SEP-2640 binding of Agent Skills Discovery v0.2.0, an
mcp-resource-templateentry in
skill://index.jsonomitsnameand carries an RFC 6570 URI template inurl(e.g.skill://docs/{product}/SKILL.md) that resolves to aSKILL.mdresourceonce its variables are bound. One template represents a family of skills — one per
variable binding. (Mirrors the .NET
McpSkillIndexEntrycontract inMicrosoft.Agents.AI.Mcp.)Changes
MCPSkillResourceTemplate(exported, experimentalMCP_SKILLS):variables— template variable names (RFC 6570 Level-1).expand(variables)— simple string expansion; values percent-encoded so they can'tinject path segments/schemes; errors on missing variables.
materialize(*, name, variables, description=None)— returns a concreteMCPSkillreusing existing fetch machinery.
MCPSkillsSource.get_resource_templates()— surfaces template entries separatelyfrom
get_skills(). Concrete skills are not auto-materialized at discovery because thevariable values aren't in the index; callers bind them explicitly.
get_skills()behavior is unchanged.
materialize, discovery, and end-to-end resolution.Open design question (for maintainers)
Auto-enumerating concrete skills during discovery requires a source of variable values
(host/user config, or
resources/templates/list+ completion). That decision is left openintentionally; this PR provides the parsing, validation, and explicit-materialization
primitives. Happy to extend with an auto-materialization strategy once the sourcing
approach is decided. This also keeps Python aligned with .NET #6117, which currently skips
templates as well.
Verification
uv run pytest packages/core/tests/core/test_mcp_skills.py→ 68 passed.ruff check/ruff format --checkclean on changed files.Addresses #6118.