Skip to content

Commit ac2530a

Browse files
committed
fix: add type assertions in MCP client to fix TypeScript errors
1 parent d7fdadd commit ac2530a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

common/src/mcp/client.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ export function listMCPTools(
111111
function getResourceData(
112112
resource: TextResourceContents | BlobResourceContents,
113113
): string {
114-
if ('text' in resource) return resource.text
115-
if ('blob' in resource) return resource.blob
114+
if ('text' in resource) return resource.text as string
115+
if ('blob' in resource) return resource.blob as string
116116
return ''
117117
}
118118

@@ -154,9 +154,12 @@ export async function callMCPTool(
154154
mediaType: c.resource.mimeType ?? 'text/plain',
155155
} satisfies ToolResultOutput
156156
}
157+
const fallbackValue = 'uri' in c && typeof (c as { uri: unknown }).uri === 'string'
158+
? (c as { uri: string }).uri
159+
: JSON.stringify(c)
157160
return {
158161
type: 'json',
159-
value: c.uri,
162+
value: fallbackValue,
160163
} satisfies ToolResultOutput
161164
})
162165
}

0 commit comments

Comments
 (0)