MCPcopy Create free account
hub / github.com/MicrosoftDocs/mcp / tryDirectToolCall

Method tryDirectToolCall

cli/src/mcp/client.ts:185–207  ·  view source on GitHub ↗
(
    kind: ToolKind,
    toolName: string,
    args: Record<string, unknown>,
  )

Source from the content-addressed store, hash-verified

183 }
184
185 private async tryDirectToolCall(
186 kind: ToolKind,
187 toolName: string,
188 args: Record<string, unknown>,
189 ): Promise<ToolCallResult | undefined> {
190 try {
191 return await this.callMappedToolDirectly(toolName, args);
192 } catch (error) {
193 const action = classifyToolError(error);
194
195 if (action === 'reset-session') {
196 await this.resetConnection(true);
197 return undefined;
198 }
199
200 if (action === 'refresh-tools') {
201 await this.clearToolCache();
202 return undefined;
203 }
204
205 throw new OperationError(`Failed to invoke the ${kind} Learn MCP tool directly.`, { cause: error });
206 }
207 }
208
209 private async callMappedToolWithSdk(kind: ToolKind, args: Record<string, unknown>): Promise<ToolCallResult> {
210 await this.ensureConnected();

Callers 1

callMappedToolMethod · 0.95

Calls 4

resetConnectionMethod · 0.95
clearToolCacheMethod · 0.95
classifyToolErrorFunction · 0.85

Tested by

no test coverage detected