# Load portable Agent Plugins

[Agent Plugins](https://agent-plugins.org/specification) is a cross-platform specification for declarative Agent extension packages. Each package bundles prompt skills (`skills/`) and MCP servers (`mcp.json`) in a single folder, enabling plug-and-play reuse across projects with no Python code required.

The [`bub-agent-plugins`](https://github.com/bubbuild/bub-contrib/tree/main/packages/bub-agent-plugins) plugin lets Bub discover and load these packages automatically.

## Quick start {#get-started}

Below you will create a plugin package containing a summary skill and a time server. The verification commands call the skill and tool directly and do not require a model API key.

Before starting, [install the Bub app](/docs/getting-started/install/#app-install) and ensure `uvx` is on your `PATH`.

1. **Install the integration plugins**

   ```bash
   bub install bub-mcp@main bub-agent-plugins@main
   bub hooks
   ```

   `bub-agent-plugins` depends on `bub-mcp` for MCP connection management (install both even if you only use skills). Verify `agent-plugins` appears under `load_state` and `provide_channels` in `bub hooks`.

2. **Create a plugin package**

   Create `.agents/plugins/portable-notes/` in your workspace:

   - .agents/
     - plugins/
       - portable-notes/
         - **plugin.json**
         - skills/
           - plugin-summary/
             - **SKILL.md**
         - **mcp.json**

   Create `plugin.json` (`$schema` and `name` are required, and `name` must match the directory name):

   ```json title=".agents/plugins/portable-notes/plugin.json"
   {
     "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
     "name": "portable-notes",
     "version": "1.0.0",
     "description": "A summary skill and a time server for Bub"
   }
   ```

   Create `skills/plugin-summary/SKILL.md`:

   ```markdown title=".agents/plugins/portable-notes/skills/plugin-summary/SKILL.md"
   ---
   name: plugin-summary
   description: Summarize notes into decisions and next actions.
   ---

   Read the supplied notes:
1. List the key decisions made;
2. List remaining actions and their owners (mark unassigned items explicitly).
   ```

   Create `mcp.json` (`$schema` is required, and every server must declare `type`: `stdio`, `streamable-http`, or `sse`):

   ```json title=".agents/plugins/portable-notes/mcp.json"
   {
     "$schema": "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json",
     "mcpServers": {
       "time": {
         "type": "stdio",
         "command": "uvx",
         "args": ["mcp-server-time"]
       }
     }
   }
   ```

3. **Verify the skill**

   Run these commands in the workspace:

   ```bash
   bub --workspace . run ',skill'
   bub --workspace . run ',skill name=plugin-summary'
   ```

   The first command lists `plugin-summary`; the second prints its path and body (skills do not need a background channel, so `bub run` works directly).

4. **Verify the MCP tool**

   Start `bub chat` (which starts the `agent-plugins.mcp` background channel):

   ```bash
   bub --workspace . chat
   ```

   Once connected, call the plugin's time tool directly (prefixed with `mcp.<plugin>.`):

   ```text
   ,mcp.portable-notes.time_get_current_time timezone=UTC
   ```

   On first launch, `uvx` may take a moment to download the server. If you see `command not found`, check the startup logs and retry once the tool registers.

Once you have [configured a model](/docs/app/configure/), you can also let the model call the time tool directly or use `$plugin-summary` to summarize notes.

## Coexistence with global MCP servers {#with-mcp}

MCP servers inside Agent Plugins are isolated from global `~/.bub/mcp.json` servers:

| Source | Config file | Lifecycle channel | Tool name format |
| --- | --- | --- | --- |
| Global config | `~/.bub/mcp.json` | `mcp.lifecycle` | `mcp.<server>_<tool>` |
| Agent Plugin | `<plugin>/mcp.json` | `agent-plugins.mcp` | `mcp.<plugin>.<server>_<tool>` |

Both can define a `time` server without name collisions. Note that `bub mcp list` / `add` / `remove` manage only `~/.bub/mcp.json`.

## Configure discovery paths and toggles {#discovery-paths}

By default, Bub scans immediate subdirectories of:
1. **Workspace directory**: `<workspace>/.agents/plugins/`
2. **User global directory**: `~/.agents/plugins/`

Customize discovery paths or toggle components in `~/.bub/config.yml`:

```yaml title="~/.bub/config.yml"
agent-plugins:
  paths:
    - /opt/agent-plugins/reporting
  auto_discover: true
  skills_enabled: true
  mcp_enabled: true
  data_root: ~/.bub/agent-plugins
```

| Field | Default | Purpose |
| --- | --- | --- |
| `paths` | `[]` | Explicit plugin root directories (each containing `plugin.json`; relative paths resolve against the workspace) |
| `auto_discover` | `true` | Scan default `.agents/plugins` directories; set `false` to load only `paths` |
| `skills_enabled` / `mcp_enabled` | `true` | Enable or disable plugin skills and MCP servers independently |
| `data_root` | `~/.bub/agent-plugins` | Root directory for persistent plugin data |

**Priority**: explicit `paths` > workspace directory > user global directory (first valid package wins on name collisions; workspace `.agents/skills/` always overrides plugin skills of the same name).

Override via `BUB_AGENT_PLUGINS_` environment variables (use JSON for lists):

```bash
export BUB_AGENT_PLUGINS_PATHS='["/opt/agent-plugins/reporting"]'
export BUB_AGENT_PLUGINS_AUTO_DISCOVER=false
```

For `stdio` MCP servers, Bub sets the working directory to the plugin root and injects `PLUGIN_ROOT` and `PLUGIN_DATA` environment variables. You can also interpolate `${PLUGIN_ROOT}` and `${PLUGIN_DATA}` in `args`, `env` values, and `cwd`:

```json
{
  "command": "python",
  "args": ["${PLUGIN_ROOT}/server.py"]
}
```

After downloading or updating a plugin package, restart Bub to load the new content.

## Troubleshooting {#troubleshooting}

| Symptom | What to check |
| --- | --- |
| `agent-plugins` missing from `bub hooks` | Confirm both `bub-mcp` and `bub-agent-plugins` are installed in the active environment |
| Skill not discovered | Verify `name` in `plugin.json` matches the plugin folder name, and the skill's `name` matches its subfolder name |
| `mcp.<plugin>...` tool not found | Use `bub chat` or `bub gateway` (`bub run` does not start background MCP channels) |
| Same-named skill ignored | Workspace `.agents/skills/` takes precedence over plugin skills; rename the conflicting skill |