Skip to content

Commit 4fb952e

Browse files
committed
fix(mcp): type image tool responses
1 parent a852e3b commit 4fb952e

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

packages/mcp/src/index.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ type JsonRpcRequest = {
3131
params?: Record<string, unknown>;
3232
};
3333

34+
type McpTextContent = {
35+
type: "text";
36+
text: string;
37+
};
38+
39+
type McpImageContent = {
40+
type: "image";
41+
data: string;
42+
mimeType: string;
43+
};
44+
45+
type McpContentItem = McpTextContent | McpImageContent;
46+
3447
// ---------------------------------------------------------------------------
3548
// Tool definitions — HTTP format (used by /tools endpoint)
3649
// ---------------------------------------------------------------------------
@@ -390,7 +403,7 @@ async function handleMcpToolCall(
390403
toolArgs: Record<string, unknown>,
391404
registryUrl: string,
392405
env: Env,
393-
): Promise<{ content: Array<{ type: string; text: string }> }> {
406+
): Promise<{ content: McpContentItem[] }> {
394407
if (toolName === "search_shaders") {
395408
const results = await handleSearchShaders(
396409
toolArgs as {
@@ -471,7 +484,7 @@ async function handleMcpToolCall(
471484
playgroundEnv,
472485
);
473486

474-
const content: Array<{ type: string; text?: string; data?: string; mimeType?: string }> = [];
487+
const content: McpContentItem[] = [];
475488

476489
// Always include text status
477490
content.push({

0 commit comments

Comments
 (0)