Skip to main content
Glama
assignment-content.ts1.42 kB
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js"; import { canvasApiRequest } from "../api/canvas-client.js"; import { CanvasAssignment } from "../types/canvas.js"; export function registerAssignmentContentResource(server: McpServer) { server.resource( "assignment_content", new ResourceTemplate("canvas://courses/{courseId}/assignments/{assignmentId}", { list: undefined }), async (uri, { courseId, assignmentId }) => { try { const assignment = await canvasApiRequest<CanvasAssignment>(`/courses/${courseId}/assignments/${assignmentId}`); // Format the content nicely const content = [ `# ${assignment.name}`, ``, `**Due Date:** ${assignment.due_at ? new Date(assignment.due_at).toLocaleString() : 'No due date'}`, `**Points Possible:** ${assignment.points_possible}`, `**Submission Type:** ${assignment.submission_types?.join(', ') || 'Not specified'}`, ``, `## Description`, ``, assignment.description || 'No description available' ].join('\n'); return { contents: [{ uri: uri.href, text: content, mimeType: "text/markdown" }] }; } catch (error) { throw new Error(`Failed to fetch assignment content: ${(error as Error).message}`); } } ); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/brendan-ch/canvas-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server