Skip to content

Commit fc943a0

Browse files
committed
include office xml formats in desktop mode/treat as text
1 parent 3e9b32e commit fc943a0

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
9999
return {
100100
content: [
101101
{
102-
type: `text`,
103-
text: await workingDir.generateResourceTable(),
102+
type: `resource`,
103+
resource: {
104+
uri: `/available-files`,
105+
mimeType: `text/markdown`,
106+
text: await workingDir.generateResourceTable(),
107+
},
104108
},
105109
],
106110
};

src/mime_types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ export const FALLBACK_MIME_TYPE='application/octet-stream';
4040
export function treatAsText(mimetype: string){
4141
if(mimetype.startsWith('text/')) return true;
4242
if(textBasedMimeTypes.includes(mimetype as any)) return true;
43+
if(mimetype.indexOf('vnd.openxmlformats') > 0) return true;
4344
return false;
4445
}

src/working_directory.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Dirent, promises as fs } from "fs";
22
import path from "path";
33
import mime from "mime";
44
import { pathToFileURL } from "url";
5-
import { FALLBACK_MIME_TYPE } from "./mime_types.js";
5+
import { FALLBACK_MIME_TYPE, treatAsText } from "./mime_types.js";
66
import { claudeSupportedMimeTypes } from "./mime_types.js";
77

88
export interface ResourceFile {
@@ -64,7 +64,6 @@ export class WorkingDirectory {
6464
return pathToFileURL(path.resolve(this.directory, filename)).href;
6565
}
6666

67-
// Rename isSupported to isSupportedFile for clarity
6867
async isSupportedFile(filename: string): Promise<boolean> {
6968
if (!this.claudeDesktopMode) return true;
7069

@@ -74,7 +73,7 @@ export class WorkingDirectory {
7473

7574
const mimetype = mime.getType(filename);
7675
if (!mimetype) return false;
77-
76+
if(treatAsText(mimetype)) return true;
7877
return claudeSupportedMimeTypes.some((supported) => {
7978
if (!supported.includes("/*")) return supported === mimetype;
8079
const supportedMainType = supported.split("/")[0];

0 commit comments

Comments
 (0)