src/vs/platform/agentHost/node/shared/serverToolGroups.ts
72 LOC · 70 covered · 2 uncovered · 9 ranges · 2730 concepts · 5 introducers · 1264 tests
File neighbourhood
The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.
Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.
/*---------------------------------------------------------------------------------------------
serverToolGroups.ts ×2
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { feedbackServerToolGroup } from './agentFeedbackServerTools.js';
import { createSessionServerToolGroup, type ISessionServerToolAccessor } from './sessionServerTools.js';
import type { IServerToolDisplay, IServerToolDisplayResult, IServerToolGroup } from './agentServerToolHost.js';
/**
* Builds the server-tool groups contributed to every agent host session, in
* priority order. This is the single source of truth wired into the
* {@link AgentServerToolHost} at startup (see `agentService.ts`) and — via
* {@link getServerToolDisplay} — consulted by each provider's display layer.
*
* Adding a group here makes its tools available to all providers (Copilot,
* Claude, Codex, …) and — if the group implements
* {@link IServerToolGroup.getDisplay} — gives them nice display everywhere for
* free.
*
* `sessionAccessor` is the runtime dependency of the session-management group
* (list/create/delete sessions); it is provided by the host at construction.
* When omitted (the pure display path) the session group's `execute` is inert,
* but its definitions and display remain available.
*/
export function buildServerToolGroups(sessionAccessor?: ISessionServerToolAccessor): readonly IServerToolGroup[] {
return [feedbackServerToolGroup, createSessionServerToolGroup(sessionAccessor)];
}
/**
* The groups used by the pure {@link getServerToolDisplay} path. Built without a
* session accessor since display never invokes `execute`.
*/
const serverToolGroupsForDisplay: readonly IServerToolGroup[] = buildServerToolGroups();
/**
* Whether {@link toolName} (a tool name as seen on a tool call) refers to the
* server tool {@link bareName}. Accepts both the bare name and a transport
* prefix such as Claude's `mcp__<server>__<name>` (matched as a `__`-delimited
* suffix), mirroring the convention in `agentFeedbackAnnotations.ts`.
*/
function matchesServerToolName(toolName: string, bareName: string): boolean {
serverToolGroups.ts ×4
return toolName === bareName || toolName.endsWith(`__${bareName}`);
}
/**
* Resolves the {@link IServerToolDisplay} for a server tool call, authored by
* the group that owns the tool. Returns `undefined` when no contributed group
* owns {@link toolName} or the owning group has no bespoke display, so each
* provider's display layer can fall back to its generic behavior.
*
* Pure over the contributed groups (it does not need the constructed
* {@link AgentServerToolHost}) so the providers' history-replay paths — which
* build display from pure functions without a host instance — can call it too.
*
* @param toolName The tool name as seen on the call (bare or transport-prefixed).
* @param args The parsed tool arguments.
* @param result The tool result, once it has completed; absent while running.
*/
export function getServerToolDisplay(toolName: string, args: unknown, result?: IServerToolDisplayResult): IServerToolDisplay | undefined {
if (!group.getDisplay) {
continue;
}
if (matchesServerToolName(toolName, def.name)) {
}
}