survey-mcp-server
Version:
Survey management server handling survey creation, response collection, analysis, and reporting with database access for data management
146 lines (145 loc) • 3.55 kB
TypeScript
import { TextContent, ImageContent, EmbeddedResource } from "@modelcontextprotocol/sdk/types.js";
export type ToolResponse = Array<TextContent | ImageContent | EmbeddedResource>;
export interface ToolArguments {
[key: string]: any;
}
export interface Survey {
_id?: string;
surveyId: string;
title: string;
description?: string;
createdBy: string;
createdDate: Date;
status: 'draft' | 'active' | 'closed' | 'archived';
questions: SurveyQuestion[];
settings: SurveySettings;
targetAudience?: string[];
tags?: string[];
}
export interface SurveyQuestion {
questionId: string;
type: 'multiple_choice' | 'text' | 'rating' | 'yes_no' | 'date' | 'number';
question: string;
options?: string[];
required: boolean;
order: number;
validation?: {
minLength?: number;
maxLength?: number;
min?: number;
max?: number;
pattern?: string;
};
}
export interface SurveySettings {
allowAnonymous: boolean;
allowMultipleResponses: boolean;
showProgressBar: boolean;
randomizeQuestions: boolean;
collectEmail: boolean;
thankYouMessage?: string;
redirectUrl?: string;
}
export interface SurveyResponse {
_id?: string;
responseId: string;
surveyId: string;
respondentId?: string;
email?: string;
submittedDate: Date;
responses: ResponseAnswer[];
ipAddress?: string;
userAgent?: string;
completionTime?: number;
isComplete: boolean;
}
export interface ResponseAnswer {
questionId: string;
answer: string | string[] | number | boolean | Date;
skipped?: boolean;
}
export interface SurveyAnalytics {
surveyId: string;
totalResponses: number;
completionRate: number;
averageCompletionTime: number;
responsesByDate: {
date: string;
count: number;
}[];
questionAnalytics: QuestionAnalytics[];
demographics?: DemographicData;
}
export interface QuestionAnalytics {
questionId: string;
question: string;
type: string;
totalResponses: number;
skippedCount: number;
responseDistribution: {
value: string;
count: number;
percentage: number;
}[];
averageRating?: number;
textSummary?: string;
}
export interface DemographicData {
ageGroups?: {
range: string;
count: number;
}[];
locations?: {
location: string;
count: number;
}[];
sources?: {
source: string;
count: number;
}[];
}
export interface Participant {
_id?: string;
participantId: string;
email?: string;
name?: string;
phone?: string;
demographics?: {
age?: number;
gender?: string;
location?: string;
occupation?: string;
[key: string]: any;
};
surveyHistory: string[];
createdDate: Date;
lastActivity?: Date;
status: 'active' | 'inactive' | 'blocked';
tags?: string[];
}
export interface SurveyTemplate {
_id?: string;
templateId: string;
name: string;
description: string;
category: string;
questions: SurveyQuestion[];
defaultSettings: SurveySettings;
isPublic: boolean;
createdBy: string;
createdDate: Date;
usageCount: number;
tags?: string[];
}
export interface SearchFilters {
status?: string[];
createdBy?: string;
dateRange?: {
start: Date;
end: Date;
};
tags?: string[];
category?: string;
responseCountMin?: number;
responseCountMax?: number;
}