mcp-quiz-server
Version:
🧠AI-Powered Quiz Management via Model Context Protocol (MCP) - Create, manage, and take quizzes directly from VS Code, Claude, and other AI agents.
136 lines (135 loc) • 4.34 kB
JavaScript
;
/**
* @moduleName: Quiz Tools Index
* @version: 2.0.0
* @since: 2025-07-25
* @lastUpdated: 2025-07-27
* @projectSummary: Enhanced MCP Quiz Server - Modular Architecture
* @techStack: TypeScript, JSON-RPC 2.0, MCP Protocol
* @dependency: Individual quiz tool modules
* @interModuleDependency: create-quiz, list-quizzes, get-quiz, delete-quiz, analytics-results
* @requirementsTraceability:
* {@link Requirements.REQ_ARCH_003} (Modular Tool Organization)
* {@link Requirements.REQ_CONFIG_004} (Dynamic Tool Loading)
* {@link Requirements.REQ_CONFIG_005} (Tool Configuration Management)
* @briefDescription: Central index for all quiz-related tools and handlers
* @methods: Export aggregation for quiz tools
* @contributors: GitHub Copilot
* @examples:
* - import { quizTools, quizHandlers } from './index'
* @vulnerabilitiesAssessment: No direct vulnerabilities - aggregation module only
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.allQuizHandlers = exports.allQuizTools = exports.quizHandlers = exports.quizToolDefinitions = void 0;
const analytics_results_1 = require("./analytics-results");
const create_quiz_1 = require("./create-quiz");
const delete_quiz_1 = require("./delete-quiz");
const get_quiz_1 = require("./get-quiz");
const list_quizzes_1 = require("./list-quizzes");
// Initialize tool instances
const createQuizInstance = new create_quiz_1.CreateQuizTool();
const listQuizzesInstance = new list_quizzes_1.ListQuizzesTool();
const getQuizInstance = new get_quiz_1.GetQuizTool();
const deleteQuizInstance = new delete_quiz_1.DeleteQuizTool();
/**
* Quiz tool definitions
*/
exports.quizToolDefinitions = [
createQuizInstance.definition,
listQuizzesInstance.definition,
getQuizInstance.definition,
deleteQuizInstance.definition,
...analytics_results_1.analyticsTools,
];
/**
* Simple wrapper handlers that match our expected signature
* Now properly throw errors instead of wrapping them as success responses
*/
const createQuizHandler = async (args) => {
const context = {
requestId: null,
timestamp: new Date().toISOString(),
};
try {
const result = await createQuizInstance.execute(args || {}, context);
return {
content: result.content.map(item => ({
type: item.type || 'text',
text: item.text || '',
})),
};
}
catch (error) {
// Re-throw the error so ModularMCPHandler can convert it to proper JSON-RPC error
throw error;
}
};
const listQuizzesHandler = async (args) => {
const context = {
requestId: null,
timestamp: new Date().toISOString(),
};
try {
const result = await listQuizzesInstance.execute(args || {}, context);
return {
content: result.content.map(item => ({
type: item.type || 'text',
text: item.text || '',
})),
};
}
catch (error) {
throw error;
}
};
const getQuizHandler = async (args) => {
const context = {
requestId: null,
timestamp: new Date().toISOString(),
};
try {
const result = await getQuizInstance.execute(args || {}, context);
return {
content: result.content.map(item => ({
type: item.type || 'text',
text: item.text || '',
})),
};
}
catch (error) {
throw error;
}
};
const deleteQuizHandler = async (args) => {
const context = {
requestId: null,
timestamp: new Date().toISOString(),
};
try {
const result = await deleteQuizInstance.execute(args || {}, context);
return {
content: result.content.map(item => ({
type: item.type || 'text',
text: item.text || '',
})),
};
}
catch (error) {
throw error;
}
};
/**
* Quiz tool handlers
*/
exports.quizHandlers = {
create_quiz: createQuizHandler,
list_quizzes: listQuizzesHandler,
get_quiz: getQuizHandler,
delete_quiz: deleteQuizHandler,
...analytics_results_1.analyticsHandlers,
};
/**
* All quiz tools combined
*/
exports.allQuizTools = exports.quizToolDefinitions;
exports.allQuizHandlers = exports.quizHandlers;