Skip to content

Add per-agent scoping to skill add --mcp - #522

Merged
xsh310 merged 3 commits into
xshen/per-client-skill-scopesfrom
xshen/skill-per-agent-add
Sep 11, 2026
Merged

Add per-agent scoping to skill add --mcp#522
xsh310 merged 3 commits into
xshen/per-client-skill-scopesfrom
xshen/skill-per-agent-add

Conversation

@xsh310

@xsh310 xsh310 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

What

Adds an --agents option to ucode skill add --mcp so a skill schema can be added to a chosen subset of configured coding agents instead of all of them. This mirrors ucode mcp add --agents, closing the gap between how the skills MCP path and the general MCP path scope work per agent.

How

  • add_skills_command(locations, agents=None) forwards agents to setup_mcp_clients, which scopes the returned client set. The per-client skill-location map is updated only for the targeted clients; the rest keep their scope untouched.
  • In cli.py, skill add gains the --agents option, bootstraps any named agent that is not configured yet via _configure_agents_for_mcp, and guards that --agents is only valid with --mcp (downloaded skills use shared directory families and cannot be agent scoped).
  • Without --agents, behavior is unchanged: every configured agent is updated.

Tests

  • test_mcp.py: per-agent add touches only the named client's scope and re-registers only that client; a global add reaches every configured client while preserving per-client divergence; adding a schema an agent already has is a no-op.
  • test_cli.py: --agents is parsed, bootstrapped, and forwarded for --mcp; an empty --agents list is rejected; --agents is rejected in download mode.

uv run pytest tests/test_mcp.py tests/test_cli.py tests/test_lint.py is green.

Manual verification (installed build)

Installed the stack tip with uv tool install --reinstall . (ucode 0.1.0+91.g5c0dc1e) and exercised the command in an isolated sandbox: a temporary HOME, stub claude/codex binaries that record every registration ucode issues, and DATABRICKS_BEARER set so auth is satisfied offline. State was seeded with both agents configured and no skills.

Scenario Command Result
Global add (all agents) ucode skill add --location shared.skills --mcp Both agents scoped to shared.skills; each re-registered once
Per-agent add add_skills_command(["claude.only"], agents={"claude"}) claude=[shared.skills, claude.only], codex=[shared.skills]; only claude re-registered; summary showed divergent per-client URLs
Guard: no --location ucode skill add ERROR --location is required for ucode skill add.
Guard: --agents without --mcp ucode skill add --location a.b --agents claude ERROR --agents is only supported when using --mcp
Guard: empty --agents ucode skill add --location a.b --mcp --agents , ERROR No agents provided for --agents ...

The --agents add path first runs an interactive agent bootstrap, so the per-agent case drove add_skills_command(..., agents=...) directly against the installed package with only that prompt stubbed; state I/O and per-client agent registration ran for real. CLI parsing and bootstrap are covered by the mocked unit tests.

Stacking

This is the first of a stacked series that adds per-agent scoping to the skills MCP connection, built on top of xshen/per-client-skill-scopes (per-client skill scope map) and skill-managed-download-only (managed skills delivered by download only). Reviewing the diff against its base branch shows just this change. It rebuilds behavior originally designed by Arthur Jenoudet on the current per-client-map state model.

This pull request and its description were written by Isaac.

@xsh310
xsh310 force-pushed the xshen/skill-per-agent-add branch from 3e8757f to a3378e8 Compare September 8, 2026 05:43
@xsh310
xsh310 force-pushed the xshen/skill-per-agent-add branch from a3378e8 to 4918b2d Compare September 8, 2026 18:25
@xsh310
xsh310 force-pushed the xshen/skill-per-agent-add branch from 4918b2d to b1219a3 Compare September 8, 2026 19:09
@xsh310
xsh310 marked this pull request as ready for review September 8, 2026 20:31
@xsh310
xsh310 force-pushed the xshen/skill-per-agent-add branch 2 times, most recently from fdeee67 to 8589f8d Compare September 8, 2026 22:16
@xsh310
xsh310 removed this pull request from stack #521 September 10, 2026 21:22
@xsh310
xsh310 added this pull request to stack #556 September 10, 2026 21:22
Comment thread src/ucode/cli.py Outdated
@xsh310
xsh310 force-pushed the xshen/skill-per-agent-add branch from 879247f to 268881e Compare September 11, 2026 03:07
xsh310 and others added 3 commits September 11, 2026 03:27
Give `ucode skill add --mcp` an `--agents` option so a schema can be added to a
chosen subset of configured coding agents instead of all of them, mirroring
`ucode mcp add --agents`. `add_skills_command` takes an optional `agents` set and
forwards it to `setup_mcp_clients`, which scopes the client set; the per-client
map is updated only for the targeted clients. `--agents` is rejected outside
`--mcp` since downloaded skills use shared directory families.

The `--mcp --agents` path bootstraps only agents that are not configured for MCP
yet, so re-targeting an already-configured agent no longer re-runs the agent
setup (re-login, binary reinstall, re-validate). It computes the not-yet-ready
subset and passes just those to `_configure_agents_for_mcp`, while still scoping
the skills update to every named agent.

Co-authored-by: Arthur Jenoudet <arthur.jenoudet@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
`skill add --agents ""` (or `,`) raised a hard "No agents provided" error,
while the other agent-scoped commands (`mcp add`, `mcp remove`) fold an empty
--agents value to None and act globally. Match them so `skill add --mcp`
mirrors `ucode mcp add` exactly: an empty --agents now targets every configured
agent instead of erroring.

Co-authored-by: Arthur Jenoudet <arthur.jenoudet@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Push the skip-already-configured logic into _configure_agents_for_mcp and
have it return the full canonical scope, so `ug skill add --mcp --agents`
and `ug mcp add --agents` share one path. skills_add no longer reimplements
agent normalization, the cursor special-case, or the bootstrap loop; mcp add
now also skips reconfiguring already-set-up agents.

Co-authored-by: Isaac <no-reply@databricks.com>
@xsh310
xsh310 force-pushed the xshen/skill-per-agent-add branch from 268881e to caa792e Compare September 11, 2026 04:25
@xsh310
xsh310 merged commit fb3921f into main Sep 11, 2026
4 of 6 checks passed
@xsh310
xsh310 deleted the xshen/skill-per-agent-add branch September 11, 2026 16:42
xsh310 added a commit that referenced this pull request Sep 11, 2026
## What

`ug status` rendered a single `Skill MCP Locations` line from the flat
scope mirror. Once agents carry different skill scopes (which per-agent
add now makes possible), that single line hides the divergence. This
makes `status` report each agent's real scope.

## How

- The Skills section reads each configured client's scope with
`skill_locations_for_client`.
- When every agent shares the same scope, it collapses to the original
single `Skill MCP Locations` + `Configured` lines.
- When scopes diverge, it prints a per-agent line (`Claude Code skill
MCP locations: ...`, `Codex skill MCP locations: ...`), matching how
`_print_skills_summary` already reports scopes.

## Tests

- `test_cli.py`: a state whose per-client scopes diverge renders one
line per agent with that agent's own locations. The existing
uniform-scope and no-locations status tests still pass unchanged.

`uv run pytest tests/test_mcp.py tests/test_cli.py tests/test_lint.py`
is green.

### Manual verification (installed build)

Using the sandbox from the per-agent add PR (agents scoped to divergent
locations: claude `shared.skills, claude.only`, codex `shared.skills`),
ran `ucode status`. The Skills section rendered one line per agent:

```
Skills
  Claude Code skill MCP locations: shared.skills, claude.only
  Codex skill MCP locations: shared.skills
```

The new `ug skill add` / `ug skill remove --mcp` hint also appeared. The
uniform-scope collapse path is covered by the existing status tests.

## Stacking

Second in the stacked per-agent skills series, based on
`xshen/skill-per-agent-add` (#522). Reviewing the diff against that base
shows just this change. It rebuilds behavior originally designed by
Arthur Jenoudet on the current per-client-map state model.

This pull request and its description were written by Isaac.

---------

Co-authored-by: Arthur Jenoudet <arthur.jenoudet@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
xsh310 added a commit that referenced this pull request Sep 11, 2026
## What

Documents the per-agent skills behavior this stack introduced but the
README did not yet cover:

- `--agents` scoping on `ug skill add --mcp` (add schemas to specific
agents; any not set up yet are configured first).
- `ug skill remove --mcp`, with `--agents` to scope removal to named
agents.
- Each agent's skill MCP scope now shown by `ug status`.

## How

- Added a "Remove skill scopes" subsection, plus an `--agents` example
and note in "Add skill scopes".
- Added quick-reference rows for the per-agent `skill add` and both
`skill remove` forms.
- Updated the `ug status` row to mention per-agent skill MCP scope.
- Aligned the existing `skill add` examples from `ucode` to `ug` for
consistency with the rest of the README.

Docs only; no code changes.

## Stacking

Stacked on `xshen/skill-per-agent-remove` (#525), the top of the
per-agent skills series. It documents the user-facing surface added
across #520, #522, #523, #524, and #525.

This pull request and its description were written by Isaac.

Co-authored-by: Isaac <no-reply@databricks.com>
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