Skip to content

Python: Add MCP Skills extension discovery with manifest-bound listed skills - #10569

Draft
Jose Alvarez (jpalvarezl) wants to merge 3 commits into
jpalvarezl/mcp-skills/01-sdk-foundationfrom
jpalvarezl/mcp-skills/02-listed-skill-runtime
Draft

Jose Alvarez (jpalvarezl) wants to merge 3 commits into
jpalvarezl/mcp-skills/01-sdk-foundationfrom
jpalvarezl/mcp-skills/02-listed-skill-runtime

Conversation

@jpalvarezl

@jpalvarezl Jose Alvarez (jpalvarezl) commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 681d6c00b34922482dcb934ac77434e126c502ef

Dimension Assessment Rationale
Change confidence 8/10 ↑ Focused MCP and skills tests pass: 3242 passed, 17 skipped.
↑ End-to-end tests against an in-memory SDK server cover the negotiated path, legacy fallback (not opted in, not advertised, caller-owned ClientSession), no downgrade after a failure, malformed descriptors and dynamic manifests.
↑ Tests cover redacted logging with sensitive data on and off, and the legacy fallback for SDKs without the Skills extension module.
↓ pyright and mypy reported only existing errors elsewhere in _skills.py earlier and were not rerun after the latest changes.
↓ The pre-commit poe check could not run because dependency downloads failed; CI has not been inspected.
↓ Ruff passed only with cached 0.17.3, not the pinned 0.17.5.

Motivation & Context

This is the second layer in the Python MCP Skills PR stack, rebased onto the current #10568 head (da8ac7a, which loads Skills only when extensions are selected and rejects unsupported extensions). It depends on #10568 (base branch jpalvarezl/mcp-skills/01-sdk-foundation). It adds discovery through the MCP Skills extension (skills/list) to MCPSkillsSource, together with the runtime model for listed skills, so this layer can be tested end to end.

Description & Review Guide

  • What are the major changes?
    • Discovery path:
      • MCPSkillsSource.get_skills() calls typed skills/list only when both conditions hold:
        • the caller opted in with MCPSkillsExtension, so the SDK Skills() extension is registered on the Client;
        • the server advertises io.modelcontextprotocol/skills.
      • In every other case, including a caller-owned ClientSession, it uses the legacy skill://index.json discovery as before.
    • No downgrade: if skills/list raises, or returns a malformed skill descriptor, the error is logged and raised. Discovery never falls back to the index and never returns a partial list.
    • Dynamic manifests: skills whose resource list is dynamic are skipped with a warning, through a separate code path. A later layer will build an allowlist for them with resources/directory/read.
    • Listed-skill runtime:
      • A private _ListedMCPSkill (subclass of MCPSkill) keeps a detached, deep-copied SDK Skill descriptor and the originating server name.
      • It reads SKILL.md and supporting resources only when requested, and only URIs listed exactly in the static manifest. The existing _validate_resource_name path-safety checks still apply.
      • It borrows the Client it was listed on and never enters or closes it (ADR 0050).
      • Advertised allowed-tools never grants tool permissions.
    • SDK compatibility: if the installed mcp release lacks the Skills extension module (for example 2.3.0), discovery uses the legacy index instead of failing.
    • Logging: discovery failures log through _log_mcp_exception, so server errors and descriptor URIs are redacted unless sensitive-data logging is enabled.
    • Docstring: MCPSkill now describes either discovery source instead of only skill://index.json.
  • What is the impact of these changes?
    • No new public symbols, and the existing API is unchanged.
    • Discovery behaves differently only for callers who opted in with MCPSkillsExtension and connect to a server that advertises the extension.
  • What do you want reviewers to focus on?
    • The conditions for choosing the discovery path, and the no-downgrade rule.
    • The read restriction to manifest URIs, and the connection-ownership boundaries.

Known gaps (later layers):

  • The SDK's list_skills() currently fetches every page itself, with no limits or cache metadata.
  • Listed skills stay tied to the Client they were found on. After a reconnect, discovery has to run again.

Out of scope, planned for later layers:

  • skills/list paging limits, cache metadata (ttl_ms / cache_scope) and atomic catalog updates.
  • Allowlists for dynamic-manifest skills built with resources/directory/read.
  • Frontmatter comparison, digest and size checks, and resource limits.
  • Foundry Toolbox, samples and docs.

Related Issue

Part of #9582 (umbrella issue, remains open). Depends on #10568.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: implementation, tests, and this PR description.

Validation:

  • uv run --no-sync pytest packages/core/tests/core/test_mcp_skills.py packages/core/tests/core/test_mcp.py packages/core/tests/core/test_skills.py -p no:cacheprovider --disable-warnings: 3242 passed, 17 skipped.
  • uvx --offline ruff check and ruff format --check on the changed files: passed with cached Ruff 0.17.3. The pinned 0.17.5 could not be downloaded.
  • pyright 1.1.414 and mypy 2.4.1 found only existing errors elsewhere in _skills.py; the test file was clean. They were not rerun after the latest changes.
  • Not run: the full poe check. The pre-commit poe hook failed while downloading dependencies, so the commits were made with --no-verify.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

@github-actions github-actions Bot added the python Usage: [Issues, PRs], Target: Python label Dec 3, 2026
@github-code-quality

github-code-quality Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: Python

Python / code-coverage/python

jpalvarezl/mcp-skill... ea621c7 jpalvarezl/mcp-skill... 681d6c0 +/-
92% 92% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated December 03, 2026 14:31 UTC

Copilot AI balanced review requested due to automatic review settings December 3, 2026 13:46
@jpalvarezl Jose Alvarez (jpalvarezl) changed the title Python: Add listed MCP skill runtime with manifest-bound lazy resources Python: Add MCP Skills extension discovery with manifest-bound listed skills Dec 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unconditional Skills imports break legacy discovery with supported MCP versions, and warning logs expose sensitive exception details when sensitive-data logging is disabled.

2 open issues
What changed in this PR

Adds opt-in MCP Skills discovery to Python’s MCPSkillsSource, building on #10568 toward Python/.NET parity tracked in #9582.

Changes:

  • Uses negotiated skills/list discovery while preserving legacy fallback without downgrading after extension failures.
  • Adds lazy, static-manifest-restricted skill reads bound to the originating client; skips dynamic manifests.
  • Adds tests for negotiation, failures, resource restrictions, and connection ownership.
File Description
python/​packages/​core/​tests/​core/​test_mcp_skills.py Tests listed-skill behavior and extension discovery.
python/​packages/​core/​agent_framework/​_skills.py Implements discovery, manifest-bound runtime behavior, and updated docstrings.

Review effort: Balanced

Introduce a private listed-skill runtime that retains server provenance, the advertised descriptor, and a static resource manifest, borrows the originating Client, and lazily fetches SKILL.md and supporting resources only for manifest URIs.
Use typed skills/list when the client opted in with MCPSkillsExtension and the server advertises io.modelcontextprotocol/skills; otherwise keep the legacy skill://index.json discovery. Extension failures and malformed listed skills propagate without falling back to the index or returning a partial catalog. Dynamic-manifest skills are skipped with a warning until directory-read allowlists land.
…ills extension

- Fall back to the legacy skill://index.json when the installed mcp SDK lacks the Skills extension module.
- Log skills/list failures and non-conformant descriptors via _log_mcp_exception so sensitive details are redacted unless sensitive-data logging is enabled.
- Trim the MCPSkillsSource docstring.
@jpalvarezl
Jose Alvarez (jpalvarezl) force-pushed the jpalvarezl/mcp-skills/02-listed-skill-runtime branch from 887a0d9 to 681d6c0 Compare December 3, 2026 14:25

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants