mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 23:58:31 -06:00
route edits
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { LocalCourseSettings } from "@/models/local/localCourseSettings";
|
import { LocalCourseSettings } from "@/models/local/localCourseSettings";
|
||||||
import { groupByStartDate } from "@/models/local/utils/timeUtils";
|
import { groupByStartDate } from "@/models/local/utils/timeUtils";
|
||||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||||
|
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||||
import { createMcpHandler } from "mcp-handler";
|
import { createMcpHandler } from "mcp-handler";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
@@ -31,6 +32,79 @@ const handler = createMcpHandler(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
server.tool(
|
||||||
|
"get_assignments_for_course",
|
||||||
|
"gets assignments and modules for a course",
|
||||||
|
{
|
||||||
|
courseName: z.string(),
|
||||||
|
},
|
||||||
|
async ({ courseName }) => {
|
||||||
|
const modules = await fileStorageService.modules.getModuleNames(
|
||||||
|
courseName
|
||||||
|
);
|
||||||
|
const assignments = (
|
||||||
|
await Promise.all(
|
||||||
|
modules.map(async (moduleName) => {
|
||||||
|
const assignments =
|
||||||
|
await fileStorageService.assignments.getAssignments(
|
||||||
|
courseName,
|
||||||
|
moduleName
|
||||||
|
);
|
||||||
|
return assignments.map((assignment) => ({
|
||||||
|
assignmentName: assignment.name,
|
||||||
|
moduleName,
|
||||||
|
}));
|
||||||
|
})
|
||||||
|
)
|
||||||
|
).flat();
|
||||||
|
|
||||||
|
return {
|
||||||
|
content: assignments.map((a) => ({
|
||||||
|
type: "resource_link",
|
||||||
|
uri: `canvas:///courses/${courseName}/module/${a.moduleName}/assignments/${a.assignmentName}`,
|
||||||
|
name: `${a.assignmentName}.md`,
|
||||||
|
mimeType: "text/markdown",
|
||||||
|
description: "An canvas assignment",
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
server.registerResource(
|
||||||
|
"course_assignment",
|
||||||
|
new ResourceTemplate(
|
||||||
|
"canvas:///courses/{courseName}/module/{moduleName}/assignments/{assignmentName}",
|
||||||
|
{ list: undefined }
|
||||||
|
),
|
||||||
|
{
|
||||||
|
title: "Course Assignment",
|
||||||
|
description: "Markdown representation of a course assignment",
|
||||||
|
},
|
||||||
|
async (uri, { courseName, moduleName, assignmentName }) => {
|
||||||
|
if (
|
||||||
|
typeof courseName !== "string" ||
|
||||||
|
typeof moduleName !== "string" ||
|
||||||
|
typeof assignmentName !== "string"
|
||||||
|
) {
|
||||||
|
throw new Error(
|
||||||
|
"courseName, moduleName, and assignmentName must be strings"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const assignment = await fileStorageService.assignments.getAssignment(
|
||||||
|
courseName,
|
||||||
|
moduleName,
|
||||||
|
assignmentName
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
contents: [
|
||||||
|
{
|
||||||
|
uri: uri.href,
|
||||||
|
text: assignment.description,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serverInfo: {
|
serverInfo: {
|
||||||
|
|||||||
Reference in New Issue
Block a user