Skip to content

Commit bb352be

Browse files
committed
use compatibility type rather than type assertion
1 parent 86085f6 commit bb352be

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/mcp-client/src/McpClient.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import type { Transport } from "@modelcontextprotocol/sdk/shared/transport";
1616
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
1717
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
1818
import { ResultFormatter } from "./ResultFormatter.js";
19-
import type { CallToolResult } from "@modelcontextprotocol/sdk/types";
2019

2120
type ToolName = string;
2221

@@ -198,7 +197,7 @@ export class McpClient {
198197
const client = this.clients.get(toolName);
199198
if (client) {
200199
const result = await client.callTool({ name: toolName, arguments: toolArgs, signal: opts.abortSignal });
201-
toolMessage.content = ResultFormatter.format(result as CallToolResult);
200+
toolMessage.content = ResultFormatter.format(result);
202201
} else {
203202
toolMessage.content = `Error: No session found for tool: ${toolName}`;
204203
}

packages/mcp-client/src/ResultFormatter.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import type { CallToolResult, TextResourceContents, BlobResourceContents } from "@modelcontextprotocol/sdk/types";
1+
import type {
2+
TextResourceContents,
3+
BlobResourceContents,
4+
CompatibilityCallToolResult,
5+
} from "@modelcontextprotocol/sdk/types";
26

37
/**
48
* A utility class for formatting CallToolResult contents into human-readable text.
@@ -13,7 +17,7 @@ export class ResultFormatter {
1317
* @param result The CallToolResult to format
1418
* @returns A human-readable string representation of the result contents
1519
*/
16-
static format(result: CallToolResult): string {
20+
static format(result: CompatibilityCallToolResult): string {
1721
if (!result.content || !Array.isArray(result.content) || result.content.length === 0) {
1822
return "[No content]";
1923
}

0 commit comments

Comments
 (0)