Skip to content

feat(core): add experimental MCP Skills support - #64157

Closed
rekram1-node wants to merge 7 commits into
devfrom
mcp-skills
Closed

rekram1-node wants to merge 7 commits into
devfrom
mcp-skills

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

N/A

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds experimental support for MCP Skills, a beta MCP extension that lets a server publish skills. Guarded by the mcp_skills flag.

  • Discovery: when a connected server offers the extension, OpenCode lists its skills with the SDK's SkillsClient and shows each one as <server>:<name>, for example team:deploy. Listing reads no files, as the spec requires.
  • Loading: the existing skill tool fetches only that skill's SKILL.md, after the permission check, and the SDK verifies its size, SHA-256 and frontmatter.
  • Supporting files: the existing read tool on skill://team:deploy/... fetches and verifies only the requested file. Listing a directory uses the skill's manifest and fetches nothing. Built-in virtual files (the opencode skill's api.md and api/*.md when opencode_api is on) go through the same path.
  • Skill.Service: keeps list, get and files. add also takes content as an Effect that runs on load, and file values can be a string, bytes or an Effect. { content: false } returns summaries without loading anything, files(id) returns paths and files(id, path) reads one file. Plain list() still returns only skills whose body is already there, so nothing inside core gets an empty body by accident; anything that needs the body loads it with get.
  • Listing: GET /api/skill and ctx.skill.list now list MCP skills too, with content: "". Disk, built-in and Console skills fill content exactly as before, and the response shape doesn't change. Nothing is fetched to build the list.
  • content is deprecated: Skill.Info.content now says it's deprecated, may be empty for skills whose body loads on demand, and points at GET /api/skill/{skillID}/content. openapi.json marks it "deprecated": true (the generator now passes the deprecated annotation through). The field stays required.
  • New endpoint: GET /api/skill/{skillID}/content (skill.content, client.skill.content, and ctx.skill.content for plugins) returns { location, data: { content } }, loading the body on demand. 404 SkillNotFoundError for an unknown skill, 502 SkillLoadError when the body can't be loaded (server down, digest mismatch). It doesn't wait for plugins to load. It's stable from the start rather than under /api/experimental, which AGENTS.md asks for new endpoints; that's a deliberate call so clients can move off the deprecated content field. It's also listed in the opencode skill's API reference.
  • App: the skill:// file viewer (packages/app/src/workspaces/files/model.tsx) now reads SKILL.md through the new endpoint for every skill instead of using content from the list.
  • Policy: managed skill.use deny rules also remove MCP skills, and a server's skills are hidden from the model while the session can use none of its tools.
 GET /api/skill
 [
   { "id": "deploy", "name": "deploy", "path": "/repo/.opencode/skills/deploy/SKILL.md", "content": "Deploy steps..." },
+  { "id": "team:deploy", "name": "team:deploy", "description": "Deploy the app", "path": "skill://team:deploy/SKILL.md", "content": "" }
 ]

+GET /api/skill/team:deploy/content
+{ "location": { ... }, "data": { "content": "Deploy steps from the team server..." } }

I checked the other readers of the list: the TUI skill dialog and autocomplete, the app composer, Extensions settings and the tab strip only use id, name, description or path, so they didn't need to change. The file viewer was the only one showing the body.

Not yet: skills marked "dynamic" (skipped), caching fetched files, and a separate per-skill approval for remote skills (approvals stay plain skill permission rules). Extensions settings treats any skill:// skill as a Console skill while signed in, so an MCP skill there can get a Console link it shouldn't; skills have no source field yet. If one server lists two skills with the same name, both are kept and told apart by the path segments that differ, as the spec requires: acme/billing/refunds and acme/support/refunds become team:billing.refunds and team:support.refunds. MCP skills register after every other skill source, so one whose ID is already taken is skipped and logged instead of silently replacing it.

How did you verify your code works?

  • bun run check at the root.
  • 839 core tests across skills, MCP skills, skill/read tools, session prompt and skills, the opencode API skill, config skills, policy and plugins; 266 more across test/mcp* and session prompt.
  • test/mcp-skills.test.ts runs a real MCP server built with the SDK's SkillsExtension and counts its requests: discovery reads nothing, the public listing shows the skill with empty content and reads nothing, loading reads only SKILL.md, a supporting file reads only that file, a directory reads nothing, a digest mismatch fails cleanly, same-named skills get distinct path-based IDs, a taken ID keeps the existing skill, policy deny removes the skill, and the flag off doesn't declare the extension.
  • New server test for the content endpoint: returns a disk skill's body and 404s an unknown skill.
  • The app e2e "Extensions lists open config files and skills" passes against a mocked content endpoint.
  • Protocol check:generated and tests pass; client generate leaves no diff.

Screenshots / recordings

N/A

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" stroke="currentColor" font-family="ui-monospace,monospace" font-size="8">
<style>@media (prefers-reduced-motion:no-preference){.f{animation:f 3s ease-in-out infinite}.g{animation:f 3s ease-in-out 1s infinite}}@keyframes f{0%,20%{opacity:.15}45%,80%{opacity:1}100%{opacity:.15}}</style>
<rect x="6" y="14" width="64" height="44" rx="6" opacity=".5"/>
<text x="16" y="40" fill="currentColor" stroke="none">team</text>
<path d="M74 36h30" opacity=".4" stroke-dasharray="3 3"/>
<rect x="108" y="10" width="126" height="16" rx="4" opacity=".6"/>
<text x="114" y="21" fill="currentColor" stroke="none">team:deploy</text>
<g class="f"><rect x="116" y="30" width="110" height="14" rx="4" opacity=".8"/><text x="122" y="40" fill="currentColor" stroke="none">SKILL.md</text></g>
<g class="g"><rect x="116" y="48" width="110" height="14" rx="4" opacity=".8"/><text x="122" y="58" fill="currentColor" stroke="none">examples/staging.md</text></g>
</svg>

Flag: mcp_skills (on in local and dev builds, off in releases; experimental.mcp_skills or OPENCODE_FLAGS=mcp_skills to try it). The listing change and the stable content endpoint aren't behind it, but without the flag no lazy skills exist, so the list looks exactly like before.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@opencodejr opencodejr Bot 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.

No blocking issues found. I ran the new test/mcp-skills.test.ts (a real SDK skills server over HTTP, counting its requests) and test/skill.test.ts: all 18 pass. Nearby MCP, skill, read/skill tool and session-skill tests: 190 pass, 1 fails (terminates MCP descendants…), and it fails the same way on the base. tsc is clean in core and server; I didn't run the schema and client type checks. The test covers the main claims: listing reads no files, SKILL.md is fetched only after the permission check, a file read fetches only that file, directory reads fetch nothing, digest mismatches are refused, a policy deny removes the skill, and nothing is declared with the flag off. I didn't drive the TUI, because the change isn't visible there.

Public API: adds the mcp_skills flag (experimental.mcp_skills in config, OPENCODE_FLAGS=mcp_skills) to the config schema, OpenAPI and generated client types. This is backwards compatible. GET /api/skill, ctx.skill and the plugin skill editor are unchanged and still return only eager skills. Inside core, Skill.Service (get/files/list overloads, files(id) now returning paths, get able to fail with Skill.LoadError) and Skill.prepare changed, but all callers in the repository were updated. A new internal bus event mcp.skills.changed is added; it is not part of the OpenAPI spec.

@opencodejr opencodejr Bot 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.

The new commits look sound, and there were no open threads from my earlier review. Same-named skills from one server now get IDs from the end of their paths (team:billing.refunds, team:support.refunds), with a URI hash when the paths never differ. McpSkillPlugin now runs after the SDK, instance and config skill plugins and before the policy plugin, so a taken ID is skipped and logged rather than replaced, and managed deny rules still apply. I ran the MCP skills, skill, skill/read tool and session-skill tests in packages/core: 63 pass, including the new ones for same-named skills and taken IDs. tsc -b for core and its tests is clean. The public API is unchanged by these commits; the PR as a whole still only adds the experimental mcp_skills flag, which is backwards compatible.

@opencodejr opencodejr Bot 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.

The new commit works as described. The model's skill list hides an MCP server's skills when the server has tools and all of them are denied, and keeps them for a server that serves only skills. I ran the MCP skills, skill, skill-instructions, MCP-instructions, skill tool and session-skill tests in packages/core (45 pass) and tsc -b (clean). This commit doesn't change the public API: the new server field on skill summaries is internal and can't reach GET /api/skill. The PR as a whole still only adds the experimental mcp_skills flag, which is backwards compatible. One gap, not blocking, noted inline: only the list is filtered, so a hidden skill can still be loaded by its ID.

// An MCP server's skills are hidden while the Session can use none of the tools it has; a server serving only
// skills keeps them.
const tools = listed.some((skill) => skill.server !== undefined) ? yield* mcp.tools() : []
const blocked = (server: string) => {

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.

This only hides the skill from the list shown to the model. The skill and read tools don't check it, so a skill hidden here can still be loaded by its ID (team:deploy), and that sends requests to the server whose tools are all denied. If denying all of a server's tools is meant to cut the server off, the same check should probably go in the skill and read tools. Otherwise, a note that this filter is only meant to keep the list short would make the intent clear.

@jjjermiah

Copy link
Copy Markdown
Contributor

Claude Code shipped Skills over MCP as a public beta today (v2.1.331), and Anthropic named Shopify, HubSpot and Atlassian as servers already publishing skills: https://claude.com/resources/articles/skills-over-mcp-tasks-and-more

This PR looks like the right shape for OpenCode: SKILL.md loads only when used, through the existing skill and read tools. It now conflicts with dev. Any chance it can be rebased and landed behind the flag, so we can try it against real servers? It would be great to have this natively.

@rekram1-node

Copy link
Copy Markdown
Member Author

Replaced by #66197 (lazy skill loading) and #66201 (MCP skills behind the mcp_skills flag).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants