canvas_get_file
Retrieve detailed information about a specific file in Canvas LMS by providing its file ID using this tool within the Canvas MCP Server V2.0.
Instructions
Get information about a specific file
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_id | Yes | ID of the file |
Input Schema (JSON Schema)
{
"properties": {
"file_id": {
"description": "ID of the file",
"type": "number"
}
},
"required": [
"file_id"
],
"type": "object"
}
Implementation Reference
- src/index.ts:1071-1073 (registration)Registration of all tools including canvas_get_file via ListToolsRequestSchema handler returning the TOOLS arraythis.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
- src/index.ts:296-305 (schema)Tool schema definition for canvas_get_file in the TOOLS array used for tool listingname: "canvas_get_file", description: "Get information about a specific file", inputSchema: { type: "object", properties: { file_id: { type: "number", description: "ID of the file" } }, required: ["file_id"] } },
- src/index.ts:1249-1257 (handler)Handler implementation in CallToolRequestSchema switch that extracts file_id, calls CanvasClient.getFile, and returns JSON responsecase "canvas_get_file": { const { file_id } = args as { file_id: number }; if (!file_id) throw new Error("Missing required field: file_id"); const file = await this.client.getFile(file_id); return { content: [{ type: "text", text: JSON.stringify(file, null, 2) }] }; }
- src/client.ts:395-398 (helper)CanvasClient helper method that performs the actual API call to retrieve file details from Canvas APIasync getFile(fileId: number): Promise<CanvasFile> { const response = await this.client.get(`/files/${fileId}`); return response.data; }
- src/types.ts:476-500 (schema)TypeScript interface defining the CanvasFile type returned by getFileexport interface CanvasFile { id: number; uuid: string; folder_id: number; display_name: string; filename: string; content_type: string; url: string; size: number; created_at: string; updated_at: string; unlock_at?: string; locked: boolean; hidden: boolean; lock_at?: string; hidden_for_user: boolean; thumbnail_url?: string; modified_at: string; mime_class: string; media_entry_id?: string; locked_for_user: boolean; lock_explanation?: string; preview_url?: string; }