Skip to main content

Class: TemporalMCPClient

strands.TemporalMCPClient

Workflow-side handle to an MCP server registered on the worker.

The transport factory and tool discovery live worker-side via StrandsPlugin({ mcpClients: { server: () => new McpClient(...) } }). This handle only carries the server name (which selects the registered factory) and the per-call activity options.

Extends McpClient so it can be passed directly in an AgentConfig.tools | Agent.tools array (Strands' flattenTools dispatches on instanceof McpClient). connect() and disconnect() are no-ops; listTools() returns lightweight TemporalMCPTool wrappers whose stream() dispatches to the per-server {server}-callTool activity registered by StrandsPlugin.

Hierarchy​

  • McpClient

    ↳ TemporalMCPClient

Constructors​

constructor​

• new TemporalMCPClient(options): TemporalMCPClient

Parameters​

NameType
optionsTemporalMCPClientOptions

Returns​

TemporalMCPClient

Overrides​

McpClient.constructor

Properties​

cacheTools​

• Readonly cacheTools: boolean

Whether the agent lists this server's tools once or re-lists each turn.


DEFAULT_POLL_TIMEOUT​

▪ Static Readonly DEFAULT_POLL_TIMEOUT: 300000

Default poll timeout for task completion in milliseconds (5 minutes).

Inherited from​

McpClient.DEFAULT_POLL_TIMEOUT


DEFAULT_TTL​

▪ Static Readonly DEFAULT_TTL: 60000

Default TTL for task polling in milliseconds (60 seconds).

Inherited from​

McpClient.DEFAULT_TTL

Accessors​

client​

• get client(): Client<{ method: string ; params?: { _meta?: { io.modelcontextprotocol/related-task?: { taskId: string } ; progressToken?: string | number } } }, { method: string ; params?: { _meta?: { io.modelcontextprotocol/related-task?: { taskId: string } ; progressToken?: string | number } } }, { _meta?: { io.modelcontextprotocol/related-task?: { taskId: string } ; progressToken?: string | number } }>

Returns​

Client<{ method: string ; params?: { _meta?: { io.modelcontextprotocol/related-task?: { taskId: string } ; progressToken?: string | number } } }, { method: string ; params?: { _meta?: { io.modelcontextprotocol/related-task?: { taskId: string } ; progressToken?: string | number } } }, { _meta?: { io.modelcontextprotocol/related-task?: { taskId: string } ; progressToken?: string | number } }>

Inherited from​

McpClient.client


clientName​

• get clientName(): string

Returns​

string

Inherited from​

McpClient.clientName


connectionState​

• get connectionState(): McpConnectionState

Returns​

McpConnectionState

Inherited from​

McpClient.connectionState


continueOnError​

• get continueOnError(): boolean

Returns​

boolean

Inherited from​

McpClient.continueOnError


onToolsChanged​

• set onToolsChanged(callback): void

Sets a callback invoked when the MCP server's tool list changes at runtime.

Parameters​

NameTypeDescription
callbackundefined | (oldTools: string[], newTools: McpTool[]) => voidHandler receiving the previous tool names and the refreshed tool instances, or undefined to remove the callback.

Returns​

void

Inherited from​

McpClient.onToolsChanged


serverCapabilities​

• get serverCapabilities(): undefined | { completions?: object ; experimental?: {} ; logging?: object ; prompts?: { listChanged?: boolean } ; resources?: { listChanged?: boolean ; subscribe?: boolean } ; tasks?: { cancel?: object ; list?: object ; requests?: { tools?: { call?: object } } } ; tools?: { listChanged?: boolean } }

Returns​

undefined | { completions?: object ; experimental?: {} ; logging?: object ; prompts?: { listChanged?: boolean } ; resources?: { listChanged?: boolean ; subscribe?: boolean } ; tasks?: { cancel?: object ; list?: object ; requests?: { tools?: { call?: object } } } ; tools?: { listChanged?: boolean } }

Inherited from​

McpClient.serverCapabilities


serverInstructions​

• get serverInstructions(): undefined | string

Returns​

undefined | string

Inherited from​

McpClient.serverInstructions


serverVersion​

• get serverVersion(): undefined | { description?: string ; icons?: { mimeType?: string ; sizes?: string[] ; src: string ; theme?: "light" | "dark" }[] ; name: string ; title?: string ; version: string ; websiteUrl?: string }

Returns​

undefined | { description?: string ; icons?: { mimeType?: string ; sizes?: string[] ; src: string ; theme?: "light" | "dark" }[] ; name: string ; title?: string ; version: string ; websiteUrl?: string }

Inherited from​

McpClient.serverVersion

Methods​

[asyncDispose]​

▸ [asyncDispose](): Promise<void>

Enables the await using pattern for automatic resource cleanup. Delegates to McpClient.disconnect.

Returns​

Promise<void>

Inherited from​

McpClient.[asyncDispose]


callTool​

▸ callTool(tool, args, options?): Promise<JSONValue>

Invoke a tool on the connected MCP server using an McpTool instance.

When tasksConfig was provided to the client constructor, uses experimental task-based invocation which supports long-running tools with progress tracking. Otherwise, calls tools directly without task management.

Parameters​

NameTypeDescription
toolMcpToolThe McpTool instance to invoke.
argsJSONValueThe arguments to pass to the tool.
options?McpCallToolOptionsOptional settings for the request.

Returns​

Promise<JSONValue>

A promise that resolves with the result of the tool invocation.

Inherited from​

McpClient.callTool


connect​

▸ connect(): Promise<void>

Returns​

Promise<void>

Overrides​

McpClient.connect


disconnect​

▸ disconnect(): Promise<void>

Returns​

Promise<void>

Overrides​

McpClient.disconnect


listTools​

▸ listTools(): Promise<never[]>

Returns​

Promise<never[]>

Overrides​

McpClient.listTools


refreshTools​

▸ refreshTools(registry): Promise<void>

Re-list this server's tools and reconcile them into the agent's tool registry, dropping tools that no longer exist and adding new ones. TemporalAgent calls this on each agent turn when cacheTools is false so a mid-workflow MCP-server restart is reflected in the next call.

Parameters​

NameType
registryToolRegistryView

Returns​

Promise<void>