MCP install targets
An MCP install target owns one client's Terminay MCP registration. Terminay supplies the server command; the target writes exactly that into the client's own configuration file.
Manifest contribution
"permissions": ["mcp-registration"],
"contributes": {
"mcpInstallTargets": [{
"id": "com.example.agent/example-agent",
"displayName": "Example Agent"
}]
} displayName is the client's name as Install Terminay MCP shows it.
A manifest may declare up to 16 targets.
Runtime contract
context.subscriptions.add(
context.mcp.registerInstallTarget(
'com.example.agent/example-agent',
exampleMcpInstallTarget,
),
);
The runtime implements status, install, and uninstall, and
optionally replace. Each receives one request object.
| Request member | Meaning |
|---|---|
server.command, server.args, server.env? | The host-supplied launch command for the Terminay MCP server. Write exactly this and nothing else. |
signal | Aborts on the call's deadline or when the target is disposed. |
import { defineMcpInstallTarget } from '@terminay/extension-api';
const sameServer = (entry, server) =>
JSON.stringify(entry) ===
JSON.stringify({
command: server.command,
args: server.args,
env: server.env ?? {},
});
export const exampleMcpInstallTarget = defineMcpInstallTarget({
async status({ server }) {
try {
const entry = (await readConfig()).mcpServers?.terminay;
if (entry === undefined)
return { state: 'not-installed', configPath: configPath() };
return sameServer(entry, server)
? { state: 'installed', configPath: configPath() }
: {
state: 'changed',
configPath: configPath(),
message: 'The terminay entry points at a different command',
};
} catch {
return {
state: 'error',
configPath: configPath(),
message: 'The configuration file is not valid JSON',
};
}
},
async install({ server }) {
const config = await readConfig();
const entry = config.mcpServers?.terminay;
if (entry !== undefined && !sameServer(entry, server))
return { ok: false, installed: true, error: 'The terminay entry has changed; review it before replacing it.' };
return write(config, server);
},
// Optional, API 3.7: the user asked to overwrite a changed entry.
async replace({ server }) {
return write(await readConfig(), server);
},
async uninstall() {
const config = await readConfig();
if (config.mcpServers?.terminay !== undefined) {
delete config.mcpServers.terminay;
await writeConfig(config);
}
return { ok: true, installed: false };
},
});
async function write(config, server) {
config.mcpServers = {
...config.mcpServers,
terminay: {
command: server.command,
args: server.args,
env: server.env ?? {},
},
};
await writeConfig(config); // Write a temporary file, then rename it.
return { ok: true, installed: true };
}Results
| Method | Returns |
|---|---|
status | state, configPath (the file the target inspects), and an optional message. |
install, uninstall, replace | Booleans ok and installed, with optional message and error. |
| State | Meaning |
|---|---|
not-installed | The client has no Terminay entry. |
installed | The entry matches the supplied command. |
changed | An entry exists but differs from the supplied command. |
unavailable | The target cannot be used on this server. |
error | The configuration could not be read. |
install must refuse a changed entry. replace, added in API 3.7,
writes the supplied command over the existing Terminay entry, changed or not, and is the only
operation that may overwrite a changed one. Terminay calls it only when the user chooses
Replace on a changed row; for a target without replace, that action fails
with an error.
Results are closed objects. message and error are at most 1,024
characters and configPath at most 4,096. When the server has no MCP server
command, Terminay reports every target unavailable and does not call the extension.