docs(sdk): contrat d'exposition des tools MCP par les plugins — #293 (manifest: section MCP Servers And Agent Tools — contributes.mcpServers est le seul canal IdeA-native, aucun registerMcpTool/registerServer dans activate(ctx), règles id/displayName/transport stdio/autoStart requis pour la réconciliation MCP/command relatif résolu sous pluginRoot vs absolu refusé sans allowAbsoluteCommand/cwd défaut ${pluginRoot}, assignation par triplet pluginId/serverId/toolName devant matcher tools/list du serveur, example manifest aligné contributes.skills, guidance script packagé exécutable vs lancement via binaire hôte; activation-context: activate n'expose pas d'API d'enregistrement de tools MCP — ils viennent du process serveur stdio externe et de sa réponse tools/list, ctx.pluginRoot officialisé vs import.meta.url; project-plugin-assignments: assignation résolue vers serveurs manifestés autoStart uniquement, flow skill → serveur MCP → tools assignés sans chemins relatifs depuis le Markdown servi par idea_skill_read; QA verte reconfirmée par Git: npm run check — build, typecheck:examples, package:hello-plugin)
This commit is contained in:
@ -45,12 +45,23 @@ focused project at invocation/render time.
|
|||||||
The context never exposes internal IdeA gateways or Tauri commands. Use
|
The context never exposes internal IdeA gateways or Tauri commands. Use
|
||||||
`ctx.services` and the registration APIs instead.
|
`ctx.services` and the registration APIs instead.
|
||||||
|
|
||||||
|
`activate(ctx)` does not expose an API for registering MCP tools directly.
|
||||||
|
Agent-callable plugin tools are provided by stdio MCP servers declared in
|
||||||
|
`idea-plugin.json` under `contributes.mcpServers`. The plugin runtime can
|
||||||
|
register menu commands and layouts in-process, but MCP tools come from the
|
||||||
|
external server process and its MCP `tools/list` response.
|
||||||
|
|
||||||
`pluginRoot` identifies the committed package currently loaded by IdeA. It is
|
`pluginRoot` identifies the committed package currently loaded by IdeA. It is
|
||||||
not the original source directory or archive path and may change after reinstall.
|
not the original source directory or archive path and may change after reinstall.
|
||||||
Treat it as read-only, do not persist it, and resolve packaged scripts/assets
|
Treat it as read-only, do not persist it, and resolve packaged scripts/assets
|
||||||
under it only while the plugin is active. Workspace services remain confined to
|
under it only while the plugin is active. Workspace services remain confined to
|
||||||
project-owned paths.
|
project-owned paths.
|
||||||
|
|
||||||
|
Use `ctx.pluginRoot` as the official way to resolve packaged scripts/assets from
|
||||||
|
runtime code. `import.meta.url` can still be useful inside a bundle for ordinary
|
||||||
|
module-relative JavaScript resolution, but it is not the host/plugin contract
|
||||||
|
for the installed package root.
|
||||||
|
|
||||||
## Disposal
|
## Disposal
|
||||||
|
|
||||||
Push every returned disposable to `ctx.subscriptions`:
|
Push every returned disposable to `ctx.subscriptions`:
|
||||||
|
|||||||
@ -115,6 +115,7 @@ development loop.
|
|||||||
"capabilities": ["ui", "tooling"],
|
"capabilities": ["ui", "tooling"],
|
||||||
"activationScope": "app",
|
"activationScope": "app",
|
||||||
"contributes": {
|
"contributes": {
|
||||||
|
"skills": [],
|
||||||
"menus": [],
|
"menus": [],
|
||||||
"menuItems": [],
|
"menuItems": [],
|
||||||
"layouts": [],
|
"layouts": [],
|
||||||
@ -247,6 +248,57 @@ Contribution ids are part of the runtime contract:
|
|||||||
- `services.windows.open({ layoutType })` only accepts a layout type declared by
|
- `services.windows.open({ layoutType })` only accepts a layout type declared by
|
||||||
the calling plugin.
|
the calling plugin.
|
||||||
|
|
||||||
|
## MCP Servers And Agent Tools
|
||||||
|
|
||||||
|
`contributes.mcpServers` is the IdeA-native contract for plugin-provided
|
||||||
|
agent tools. A plugin does not register individual MCP tools from `activate(ctx)`.
|
||||||
|
Instead, the plugin ships or references a stdio MCP server process, declares it
|
||||||
|
in the manifest, and that server advertises its own tools through the MCP
|
||||||
|
`tools/list` protocol.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"capabilities": ["mcp"],
|
||||||
|
"contributes": {
|
||||||
|
"mcpServers": [
|
||||||
|
{
|
||||||
|
"id": "unity-editor",
|
||||||
|
"displayName": "Unity Editor Tools",
|
||||||
|
"command": "scripts/unity-mcp-server.mjs",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${pluginRoot}",
|
||||||
|
"transport": "stdio",
|
||||||
|
"autoStart": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
MCP server contribution rules:
|
||||||
|
|
||||||
|
- `id` is stable within the plugin and is used by project/agent assignments.
|
||||||
|
- `displayName` is the human-readable server name shown in plugin settings.
|
||||||
|
- `transport` must currently be `"stdio"`.
|
||||||
|
- `autoStart: true` is required for IdeA to start the server during plugin MCP
|
||||||
|
reconciliation. Non-auto-start servers are manifest metadata only today.
|
||||||
|
- A relative `command` is resolved under the installed plugin package root.
|
||||||
|
- An absolute `command` is rejected unless `allowAbsoluteCommand: true` is set.
|
||||||
|
Use this only for an intentional dependency on a host binary.
|
||||||
|
- `cwd` defaults to `${pluginRoot}` when omitted.
|
||||||
|
|
||||||
|
The tools an agent can call are assigned with the triplet
|
||||||
|
`pluginId`/`serverId`/`toolName` in project plugin settings. `toolName` must
|
||||||
|
match a tool name advertised by the MCP server. IdeA does not currently provide
|
||||||
|
a runtime API such as `ctx.mcp.registerTool()` or `ctx.mcp.registerServer()`.
|
||||||
|
|
||||||
|
For multi-harness workflows, keep `contributes.skills` as instructions and
|
||||||
|
expose executable behavior through assigned MCP tools. Do not make skill
|
||||||
|
Markdown depend on filesystem paths relative to the Markdown returned by
|
||||||
|
`idea_skill_read`; that body is served as read-only content, not mounted as a
|
||||||
|
working directory. If a skill needs packaged scripts, put the script behind a
|
||||||
|
manifest-declared MCP server and tell the agent to call the assigned tool.
|
||||||
|
|
||||||
## MCP Server Paths
|
## MCP Server Paths
|
||||||
|
|
||||||
`contributes.mcpServers` entries are resolved by the host before starting a
|
`contributes.mcpServers` entries are resolved by the host before starting a
|
||||||
@ -260,6 +312,12 @@ Runtime handlers receive the same installed package location separately as
|
|||||||
`ctx.pluginRoot`; `ctx.services.tasks.runCommand()` does not perform placeholder
|
`ctx.pluginRoot`; `ctx.services.tasks.runCommand()` does not perform placeholder
|
||||||
substitution, and workspace APIs remain project-confined.
|
substitution, and workspace APIs remain project-confined.
|
||||||
|
|
||||||
|
Prefer a packaged executable script for plugin-owned MCP servers, for example
|
||||||
|
`command: "scripts/unity-mcp-server.mjs"` with an appropriate shebang and file
|
||||||
|
mode. If the server must be launched through a host executable such as Node,
|
||||||
|
use an absolute command with `allowAbsoluteCommand: true` and keep plugin-owned
|
||||||
|
paths in `args`, for example `${pluginRoot}/scripts/unity-mcp-server.mjs`.
|
||||||
|
|
||||||
## Validation
|
## Validation
|
||||||
|
|
||||||
Use the SDK validator in tests or build tooling:
|
Use the SDK validator in tests or build tooling:
|
||||||
|
|||||||
@ -69,6 +69,12 @@ An agent MCP tool reference contains:
|
|||||||
- `toolName`: the exact tool name advertised by that MCP server. The UI accepts
|
- `toolName`: the exact tool name advertised by that MCP server. The UI accepts
|
||||||
this name as text because a dynamic MCP tool catalogue is not yet available.
|
this name as text because a dynamic MCP tool catalogue is not yet available.
|
||||||
|
|
||||||
|
IdeA resolves plugin MCP assignments to manifest-declared servers, not to
|
||||||
|
in-process handlers registered from `activate(ctx)`. A tool assignment is useful
|
||||||
|
only when the plugin is enabled, runtime-active, the referenced MCP server has
|
||||||
|
`autoStart: true`, and the server process advertises the named tool through MCP
|
||||||
|
`tools/list`.
|
||||||
|
|
||||||
Missing `plugins`, `agents`, `skills`, or `tools` arrays default to empty arrays
|
Missing `plugins`, `agents`, `skills`, or `tools` arrays default to empty arrays
|
||||||
when IdeA reads the document. Prefer writing them explicitly for clarity and
|
when IdeA reads the document. Prefer writing them explicitly for clarity and
|
||||||
forward-compatible review.
|
forward-compatible review.
|
||||||
@ -152,3 +158,10 @@ These actions solve different problems:
|
|||||||
When both package content and assignments changed, reload the plugin first,
|
When both package content and assignments changed, reload the plugin first,
|
||||||
confirm it is enabled for the project, update the assignments, then relaunch the
|
confirm it is enabled for the project, update the assignments, then relaunch the
|
||||||
agent.
|
agent.
|
||||||
|
|
||||||
|
If a plugin skill describes a workflow backed by packaged scripts, prefer this
|
||||||
|
flow: ship the scripts in the plugin package, expose them through a
|
||||||
|
manifest-declared MCP server, assign the specific MCP tools to the target agent,
|
||||||
|
and have the skill instruct the agent to call those tools. Avoid relative paths
|
||||||
|
from the skill Markdown to packaged scripts; the Markdown served by
|
||||||
|
`idea_skill_read` is content, not a stable filesystem anchor.
|
||||||
|
|||||||
Reference in New Issue
Block a user