Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,221 changes: 1,626 additions & 595 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
},
"devDependencies": {
"@anthropic-ai/mcpb": "^1.2.0",
"@modelcontextprotocol/ext-apps": "^1.0.1",
"@types/node": "^20.17.24",
"commander": "^13.1.0",
"esbuild": "^0.27.2",
Expand Down
19 changes: 7 additions & 12 deletions src/handlers/filesystem-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
} from '../tools/schemas.js';
import path from 'path';
import os from 'os';
import { buildUiToolMeta, FILE_PREVIEW_RESOURCE_URI } from '../ui/contracts.js';
import { resolvePreviewFileType } from '../ui/file-preview/shared/preview-file-types.js';

/**
Expand Down Expand Up @@ -137,10 +136,8 @@ export async function handleReadFile(args: unknown): Promise<ServerResult> {
structuredContent: {
fileName: path.basename(resolvedFilePath),
filePath: resolvedFilePath,
fileType: 'unsupported',
content: ''
fileType: 'unsupported' as const,
},
_meta: buildUiToolMeta(FILE_PREVIEW_RESOURCE_URI, true)
};
}

Expand All @@ -163,27 +160,25 @@ export async function handleReadFile(args: unknown): Promise<ServerResult> {
fileName: path.basename(resolvedFilePath),
filePath: resolvedFilePath,
fileType: 'image',
content: imageSummary,
imageData,
mimeType: fileResult.mimeType
},
_meta: buildUiToolMeta(FILE_PREVIEW_RESOURCE_URI, true)
}
};
} else {
// For all other files, return as text
// For all other files, return as text.
// structuredContent carries only file metadata (no content duplication);
// the widget reads text from the MCP content array.
const textContent = typeof fileResult.content === 'string'
? fileResult.content
: fileResult.content.toString('utf8');
const previewFileType = resolvePreviewFileType(resolvedFilePath);
const fileType = resolvePreviewFileType(resolvedFilePath);
return {
content: [{ type: "text", text: textContent }],
structuredContent: {
fileName: path.basename(resolvedFilePath),
filePath: resolvedFilePath,
fileType: previewFileType,
content: textContent
fileType,
},
_meta: buildUiToolMeta(FILE_PREVIEW_RESOURCE_URI, true)
};
}
};
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export interface FilePreviewStructuredContent {
fileName: string;
filePath: string;
fileType: PreviewFileType;
content: string;
imageData?: string;
mimeType?: string;
}
Expand Down
Loading