Add dynamic MCP server dependency loading (port from skillsdotnet)#58
Draft
olaservo wants to merge 2 commits intomodelcontextprotocol:add-skills-as-resources-examplefrom
Draft
Conversation
Port the skill dependency resolution pattern from skillsdotnet's SkillCatalog to TypeScript. Skills can now declare MCP server dependencies in frontmatter (e.g. dependencies: [everything-server]), and a client-side SkillCatalog fires an onDependenciesRequired callback when loading a skill with dependencies, enabling the host to connect required servers on demand. SDK changes: - Parse dependencies in discoverSkills() and parseSkillFrontmatter() - Expose dependencies in resource descriptions via (requires: ...) suffix - Add SkillDependencyRequest type and SkillCatalog class - Include <dependencies> element in XML generation New files: - catalog.ts: SkillCatalog with addClient, removeClient, loadSkill, onDependenciesRequired callback, getLoadSkillToolDefinition - explore-everything sample skill with dependencies: [everything-server] - dynamic-server-loading example (TypeScript port of DynamicMcpServers) Tests: 106 passing (44 new) covering catalog, dependency parsing, XML generation, and smoke tests. Co-Authored-By: Peder Holdgaard Pedersen <127606677+PederHP@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use path.resolve with __dirname instead of URL.pathname to avoid the /C:/... double-prefix issue on Windows. Co-Authored-By: Peder Holdgaard Pedersen <127606677+PederHP@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dependencies: [server-name])SkillCatalogclass (TypeScript port of skillsdotnet's SkillCatalog) discovers skills, caches frontmatter context, and fires anonDependenciesRequiredcallback when loading a skill with dependencies — enabling the host to connect required servers on demanddiscoverSkills()parses dependencies, resource descriptions include(requires: ...)suffixparseSkillFrontmatter()andlistSkillResources()extract dependencies;buildSkillsSummary()and XML generators include dependency infoNew files
typescript/sdk/src/catalog.ts—SkillCatalogwithaddClient,removeClient,loadSkill,onDependenciesRequired,getLoadSkillToolDefinitionexamples/sample-skills/explore-everything/SKILL.md— sample skill withdependencies: [everything-server]examples/dynamic-server-loading/typescript/— end-to-end demo (TypeScript port of skillsdotnet's DynamicMcpServers sample)Test plan
onDependenciesRequiredcallback → dynamically connects@modelcontextprotocol/server-everythingvia npx → 11 tools discovered🤖 Generated with Claude Code
Co-authored with @PederHP (skillsdotnet)