agentbay_project_read_file
Read a specific file from a project using its project ID and file path to retrieve the file contents.
Instructions
Read a single file from a project
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID | |
| path | Yes | File path within the project (e.g. "src/index.ts") |
Implementation Reference
- src/index.ts:1047-1052 (handler)The tool handler function that executes the 'agentbay_project_read_file' logic. It takes projectId and path parameters, calls the API endpoint to read a file from the project, and returns the file content with metadata (version, size).
async ({ projectId, path }) => { const data = await apiGet(`/api/v1/projects/${projectId}/files/${path}`); if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] }; return { content: [{ type: 'text' as const, text: `# ${data.path} (v${data.version}, ${(data.sizeBytes / 1024).toFixed(1)}KB)\n\n\`\`\`\n${data.content}\n\`\`\`` }] }; } ); - src/index.ts:1043-1046 (schema)Input schema for the tool. Defines 'projectId' (string, required) and 'path' (string, required) as Zod-validated parameters.
{ projectId: z.string().describe('Project ID'), path: z.string().describe('File path within the project (e.g. "src/index.ts")'), }, - src/index.ts:1039-1052 (registration)Registration of the tool via server.tool() call with the name 'agentbay_project_read_file' and description 'Read a single file from a project'.
// Tool 38: Project Read File server.tool( 'agentbay_project_read_file', 'Read a single file from a project', { projectId: z.string().describe('Project ID'), path: z.string().describe('File path within the project (e.g. "src/index.ts")'), }, async ({ projectId, path }) => { const data = await apiGet(`/api/v1/projects/${projectId}/files/${path}`); if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] }; return { content: [{ type: 'text' as const, text: `# ${data.path} (v${data.version}, ${(data.sizeBytes / 1024).toFixed(1)}KB)\n\n\`\`\`\n${data.content}\n\`\`\`` }] }; } );