> ## Documentation Index
> Fetch the complete documentation index at: https://openidea.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent resources and lifecycle

> How Plugins, Memory, MCP, Tools, and Skills fit together during an OpenIDEA agent task, including what enters the LLM context window.

An OpenIDEA agent task coordinates five distinct resources: **Plugin**, **Memory**, **MCP**, **Tool**, and **Skill**. Each has a different responsibility, persistence lifetime, and footprint in the LLM context window.

## Mental model at a glance

| Resource | What it is | Lives across tasks? | Loaded into the LLM context window? |
| - | - | - | - |
| **Plugin** | Installable capability bundle (an OpenIDEA WASM plugin or an agent CLI plugin) packaging MCP tools and skills | Yes (installed in the host or CLI) | **Never directly.** Plugin code stays outside the prompt; only tool schemas and skill metadata/bodies are exposed. |
| **Memory** | Persistent facts, user preferences, and repository rules (`AGENTS.md`, custom instructions, notes, checkpoints) | Yes | **Yes** — relevant rules and recalled facts are injected at session start or on demand. |
| **MCP** | Model Context Protocol bridge connecting an agent to OpenIDEA or external servers (`tools/list`, `tools/call`) | Server config persists; live connection is per session | **No** — MCP is the transport/registry. Only the **tool definitions** it advertises enter context. |
| **Tool** | Single executable function with a JSON Schema (`view`, `edit`, `bash`, `OpenIDEA-check_files`, `k8s__get_pod_logs`) | Registered per session | **Yes** — tool schema at session start (unless disabled/deferred), plus each call and result per turn. |
| **Skill** | Reusable playbook (`SKILL.md`) teaching the model how to combine tools for a workflow | Yes (on disk) | **Two-stage:** only `name` + short `description` at session start; full `SKILL.md` body **on demand** when invoked. |

In short: **Plugins** *package* capabilities, **MCP** *connects* them, **Tools** *execute* actions, **Skills** *instruct* how to orchestrate tools, and **Memory** *remembers* context and rules across tasks.

## Architecture and data flow

```mermaid theme={null}
flowchart LR
  subgraph Host["OpenIDEA Host (Persistent)"]
    P["OpenIDEA WASM Plugin<br/>(plugin.toml)"]
    IMCP["OpenIDEA Built-in MCP Server<br/>(ide-host/src/mcp)"]
    SH["Skills Hub<br/>(SKILL.md registry)"]
    P -- "contributes.mcpTools" --> IMCP
    P -- "contributes.skills" --> SH
  end

  subgraph Ext["Agent CLI Plugin / External (Persistent Config)"]
    EP["CLI Plugin (.mcp.json)"]
    EMCP["Standalone MCP Server<br/>(process / HTTP)"]
    EP -- "bundles / launches" --> EMCP
  end

  MEM["Memory<br/>(AGENTS.md, user rules, notes)"]

  subgraph Session["Agent Task Session (LLM Context Window)"]
    SYS["System Prompt<br/>(Memory + Skill Index)"]
    CAT["Tool Catalog<br/>(Built-in + MCP Tool Schemas)"]
    CONV["Conversation Turns<br/>(Active Skill Body + Tool Calls/Results)"]
  end

  MEM --> SYS
  SH -- "name + description (init)" --> SYS
  SH -- "full SKILL.md (on demand)" --> CONV
  IMCP -- "tools/list -> schemas" --> CAT
  EMCP -- "tools/list -> schemas" --> CAT
  CONV -. "tools/call (JSON-RPC)" .-> IMCP
  CONV -. "tools/call (JSON-RPC)" .-> EMCP
```

## Plugin tools vs. the LLM context window

It helps to separate **(a) where a plugin tool is registered and executed** from **(b) whether its schema enters the LLM context window**.

### OpenIDEA WASM plugin (`plugin.toml`)

* **Registered in OpenIDEA's built-in MCP server:** A plugin declaring `[[contributes.mcpTools]]` registers its tools into OpenIDEA's built-in [MCP server](https://openidea.sh/en/guide/mcp.md) under `<plugin_id>__<tool_name>` (see [Plugin MCP tools](https://openidea.sh/en/plugins/guides/mcp.md)).
* **Enters context indirectly via MCP:** When a task starts, OpenIDEA attaches its built-in `OpenIDEA` MCP server to the session. The agent CLI calls `tools/list` and loads the returned tool names, descriptions, and JSON Schemas into the LLM's tool catalog — unless the `OpenIDEA` MCP server is disabled for that session via `/mcp`, or the agent uses deferred/lazy tool loading.
* **Code stays out of context:** The plugin's WASM binary and source code never enter the prompt. On `tools/call`, OpenIDEA dispatches to the sandboxed plugin host under its granted capabilities and `readOnly` / `destructive` approval rules.

### Agent CLI plugin bundling `.mcp.json`

* OpenIDEA plugins (`plugin.toml`) do not spawn standalone MCP server processes; they export WASM tools into OpenIDEA's built-in MCP server.
* **Agent CLI plugins** (for example Copilot CLI plugins with `.mcp.json` or Claude plugins with `mcpServers` in `.claude-plugin/plugin.json`) bundle their own standalone MCP servers. When active or imported under **Settings › Agents › MCP Connections**, the agent connects to that separate MCP server at session start, calls `tools/list`, and injects its tool schemas into the LLM context window in the same way — as a sibling MCP server alongside `OpenIDEA`.

| Dimension | OpenIDEA WASM plugin (`plugin.toml`) | Agent CLI plugin (`.mcp.json` / `plugin.json`) |
| - | - | - |
| **Hosting / registry** | OpenIDEA's built-in MCP server (`ide-host`) | Standalone MCP server process or remote URL |
| **Execution sandbox** | In-process `wasmtime` actor + OpenIDEA capability grants | External process or network service |
| **How schemas reach the LLM** | `tools/list` on `OpenIDEA` MCP server → LLM tool catalog | `tools/list` on bundled MCP server → LLM tool catalog |
| **Code in context window?** | No (only schema + call arguments/result) | No (only schema + call arguments/result) |

## End-to-end lifecycle walkthrough

Suppose you have:

* **Plugin:** A `kubernetes` OpenIDEA plugin that contributes an MCP tool (`k8s__get_pod_logs`) and a skill (`/debug-crashloop`).
* **External MCP:** A GitHub/Slack MCP server configured for your workspace.
* **Memory:** Persistent instructions stating *"staging namespace is `payments-stg`; always rebase onto `origin/main` before pushing."*

You start a new agent task and send:

```text theme={null}
/debug-crashloop Fix why the payments pod is crashing in staging and open a PR
```

```mermaid theme={null}
sequenceDiagram
  autonumber
  actor User
  participant Host as OpenIDEA Host & Plugins
  participant MCP as MCP Servers (Built-in + External)
  participant Agent as Agent Runtime (Context Window)

  Note over Host: Phase 1 — Host Startup (before task exists)
  Host->>Host: Load kubernetes WASM plugin
  Host->>MCP: Register k8s__get_pod_logs in built-in MCP
  Host->>Host: Index /debug-crashloop SKILL.md in Skills Hub

  Note over Agent: Phase 2 — Session Initialization
  Host->>Agent: Inject Memory (AGENTS.md + user rules)
  Host->>Agent: Inject lightweight Skill index (name + description)
  Agent->>MCP: Connect & call tools/list
  MCP-->>Agent: Return tool JSON schemas -> LLM Tool Catalog

  Note over User,Agent: Phase 3 — Skill Activation (Turn 1)
  User->>Agent: /debug-crashloop Fix why payments pod is crashing...
  Agent->>Host: Load full debug-crashloop/SKILL.md playbook
  Host-->>Agent: Playbook injected into conversation context

  Note over Agent,Host: Phase 4 — Execution Loop (Think -> Tool -> Observe)
  Agent->>MCP: tools/call k8s__get_pod_logs(ns="payments-stg")
  MCP->>Host: Route to kubernetes WASM plugin (permission check)
  Host-->>Agent: Stack trace: BillingService.java:84
  Agent->>Agent: Built-in view + edit patch line 84
  Agent->>MCP: OpenIDEA-check_files + bash tests
  MCP-->>Agent: Build & tests pass
  Agent->>Agent: Follow Memory rules -> rebase & open PR via gh

  Note over Agent,Host: Phase 5 — Completion & Teardown
  Agent->>Host: Save durable Memory updates / checkpoints
  Agent-xMCP: Close per-session MCP connections & clear tool catalog
```

**1. Phase 1 — Host startup (before the task exists)**

OpenIDEA loads enabled **Plugins** in its sandboxed host. The `kubernetes` plugin registers `k8s__get_pod_logs` in
OpenIDEA's built-in **MCP** server and indexes `debug-crashloop/SKILL.md` in the **Skills** hub. Nothing is in an
LLM context window yet.

**2. Phase 2 — Session initialization (before Turn 1)**

**Memory** is injected into the system prompt (`AGENTS.md`, user rules, recalled facts). **MCP** clients connect to
enabled servers and call `tools/list`, populating the **Tool** catalog with built-in and MCP tool schemas.
**Skills** contribute only their compact `name` + `description` index, keeping unused playbooks out of the token
budget.

**3. Phase 3 — Skill activation (Turn 1)**

Because you invoked `/debug-crashloop` (or the model matched its description in **Auto** mode), the agent loads the
full `debug-crashloop/SKILL.md` playbook into the conversation context, giving the model a structured recipe: *fetch
pod logs → locate stack trace → patch and test → open PR*.

**4. Phase 4 — Agent execution loop (Think → Tool Call → Observe)**

Combining the **Skill** recipe with **Memory** (`payments-stg`), the model invokes `k8s__get_pod_logs` over **MCP**.
OpenIDEA routes the call to the sandboxed `kubernetes` **Plugin**, returning `BillingService.java:84`. Built-in
**Tools** (`view`, `edit`) patch the bug, OpenIDEA's **MCP Tool** (`OpenIDEA-check_files`) and `bash` verify
compilation and tests, and **Memory** rules guide rebasing and opening the pull request.

**5. Phase 5 — Completion and teardown**

**Plugins**, **Memory** (including any newly saved durable facts or checkpoints), and **Skill** files remain on disk
for future tasks. Per-session **MCP** connections close or idle out, the session **Tool** catalog clears, and the
loaded **Skill** body stays scoped to that conversation.

## Related guides

> [card] [Agents](https://openidea.sh/en/guide/agents.md)
>
> Configure built-in and ACP agents, external MCP servers, and skills in OpenIDEA.

> [card] [MCP server](https://openidea.sh/en/guide/mcp.md)
>
> Enable OpenIDEA's built-in MCP server and connect IDE or external clients.

> [card] [Plugin MCP tools](https://openidea.sh/en/plugins/guides/mcp.md)
>
> Contribute sandboxed WASM tools from an OpenIDEA plugin to the built-in MCP server.

> [card] [Plugin manifest](https://openidea.sh/en/plugins/manifest.md)
>
> Declare skills, MCP tools, and capabilities in `plugin.toml`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.