Skip to content

Commit 48a91be

Browse files
Don't use resources for file list (#60)
* Update read tool call * prettier * make file write labeling consistent * Update read and write tools descriptions * prettier * Don't use resources for file list * prettier
1 parent 4844953 commit 48a91be

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

apps/sandbox-container/server/containerMcp.ts

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,40 @@ export class ContainerMcpAgent extends McpAgent<Env, Props> {
9595
}
9696
)
9797
this.server.tool('container_files_list', 'List working directory file tree', {}, async ({}) => {
98-
const files = await this.container_ls()
98+
// This approach relies on resources, which aren't handled well by Claude right now. Until that's sorted, we can just use file read, since it lists all files in a directory if a directory is passed to it.
99+
//const files = await this.container_ls()
99100

100-
// this is a bit of a hack around the poor handling of resources in claude desktop
101-
const resources: {
102-
type: 'resource'
103-
resource: { uri: string; text: string; mimeType: string }
104-
}[] = files.resources.map((r) => {
105-
return {
106-
type: 'resource',
107-
resource: {
108-
uri: r.uri,
109-
text: r.uri,
110-
mimeType: 'text/plain',
111-
},
112-
}
113-
})
101+
// const resources: {
102+
// type: 'resource'
103+
// resource: { uri: string; text: string; mimeType: string }
104+
// }[] = files.resources.map((r) => {
105+
// return {
106+
// type: 'resource',
107+
// resource: {
108+
// uri: r.uri,
109+
// text: r.uri,
110+
// mimeType: 'text/plain',
111+
// },
112+
// }
113+
// })
114114

115+
// return {
116+
// content: resources,
117+
// }
118+
119+
// Begin workaround using container read rather than ls:
120+
const { blob, mimeType } = await this.container_file_read('.')
115121
return {
116-
content: resources,
122+
content: [
123+
{
124+
type: 'resource',
125+
resource: {
126+
text: await blob.text(),
127+
uri: `file://`,
128+
mimeType: mimeType,
129+
},
130+
},
131+
],
117132
}
118133
})
119134
this.server.tool(

0 commit comments

Comments
 (0)