get_file_info
Retrieve file metadata including download URL for a specific file in a Canvas course. Provide course ID and file ID to get the file's details.
Instructions
Get file metadata including download url.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| course_id | Yes | ||
| file_id | Yes |
Implementation Reference
- canvas_local_mcp/server.py:108-111 (handler)The MCP tool handler for 'get_file_info'. It accepts course_id and file_id, and calls the Canvas API to fetch file metadata including download URL.
@mcp.tool() def get_file_info(course_id: int, file_id: int) -> dict: """Get file metadata including download url.""" return _get(f"/api/v1/courses/{course_id}/files/{file_id}") - canvas_local_mcp/server.py:108-109 (registration)The tool is registered via the @mcp.tool() decorator from FastMCP, which is defined on line 14 with 'mcp = FastMCP("canvas-local")'.
@mcp.tool() def get_file_info(course_id: int, file_id: int) -> dict: - canvas_local_mcp/server.py:30-49 (helper)Helper function that performs the actual HTTP GET request against the Canvas API. Since get_file_info returns a single dict (not a list), _get returns the JSON response directly (the else branch on line 42).
def _get(path: str, **params) -> Any: params.setdefault("per_page", 100) url = f"{BASE}{path}" out = [] with httpx.Client(headers=HEAD, timeout=30) as c: while url: r = c.get(url, params=params) r.raise_for_status() data = r.json() if isinstance(data, list): out.extend(data) else: return data url = None params = {} link = r.headers.get("Link", "") for part in link.split(","): if 'rel="next"' in part: url = part[part.find("<")+1:part.find(">")] return out