import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js'; import { CourseDBInterface, ContentNavigationStrategyData } from '@vue-skuilder/db'; import { SkLogger, CourseConfig } from '@vue-skuilder/common'; import { z } from 'zod'; interface MCPServerOptions { enableSourceLinking?: boolean; maxCardsPerQuery?: number; allowedDataShapes?: string[]; eloCalibrationMode?: 'strict' | 'adaptive' | 'manual'; logger?: SkLogger; } declare class MCPServer { private courseDB; private readonly options; private mcpServer; private transport?; private logger; constructor(courseDB: CourseDBInterface, options?: MCPServerOptions); private setupCapabilities; start(transport: Transport): Promise; stop(): Promise; get server(): McpServer; get courseDatabase(): CourseDBInterface; } interface CourseResource { config: CourseConfig; eloStats: { min: number; max: number; mean: number; distribution: number[]; }; } interface CardResource { id: string; shape: string; tags: string[]; elo: number; } declare const CreateCardInputMCPSchema: { datashape: z.ZodString; data: z.ZodAny; tags: z.ZodOptional>; elo: z.ZodOptional; sourceRef: z.ZodOptional; }; declare const CreateCardInputSchema: z.ZodObject<{ datashape: z.ZodString; data: z.ZodAny; tags: z.ZodOptional>; elo: z.ZodOptional; sourceRef: z.ZodOptional; }, "strip", z.ZodTypeAny, { datashape: string; elo?: number | undefined; tags?: string[] | undefined; data?: any; sourceRef?: string | undefined; }, { datashape: string; elo?: number | undefined; tags?: string[] | undefined; data?: any; sourceRef?: string | undefined; }>; type CreateCardInput = z.infer; interface CreateCardOutput { cardId: string; initialElo: number; created: boolean; } declare const UpdateCardInputMCPSchema: { cardId: z.ZodString; data: z.ZodOptional; tags: z.ZodOptional>; elo: z.ZodOptional; sourceRef: z.ZodOptional; }; declare const UpdateCardInputSchema: z.ZodObject<{ cardId: z.ZodString; data: z.ZodOptional; tags: z.ZodOptional>; elo: z.ZodOptional; sourceRef: z.ZodOptional; }, "strip", z.ZodTypeAny, { cardId: string; elo?: number | undefined; tags?: string[] | undefined; data?: any; sourceRef?: string | undefined; }, { cardId: string; elo?: number | undefined; tags?: string[] | undefined; data?: any; sourceRef?: string | undefined; }>; type UpdateCardInput = z.infer; interface UpdateCardOutput { cardId: string; updated: boolean; changes: { data?: boolean; tags?: boolean; elo?: boolean; sourceRef?: boolean; }; } declare const TagCardInputMCPSchema: { cardId: z.ZodString; action: z.ZodEnum<["add", "remove"]>; tags: z.ZodArray; updateELO: z.ZodDefault>; }; declare const TagCardInputSchema: z.ZodObject<{ cardId: z.ZodString; action: z.ZodEnum<["add", "remove"]>; tags: z.ZodArray; updateELO: z.ZodDefault>; }, "strip", z.ZodTypeAny, { cardId: string; tags: string[]; action: "add" | "remove"; updateELO: boolean; }, { cardId: string; tags: string[]; action: "add" | "remove"; updateELO?: boolean | undefined; }>; type TagCardInput = z.infer; interface TagCardOutput { cardId: string; action: string; tagsProcessed: string[]; success: boolean; currentTags: string[]; } declare const DeleteCardInputMCPSchema: { cardId: z.ZodString; confirm: z.ZodDefault; reason: z.ZodOptional; }; declare const DeleteCardInputSchema: z.ZodObject<{ cardId: z.ZodString; confirm: z.ZodDefault; reason: z.ZodOptional; }, "strip", z.ZodTypeAny, { cardId: string; confirm: boolean; reason?: string | undefined; }, { cardId: string; confirm?: boolean | undefined; reason?: string | undefined; }>; type DeleteCardInput = z.infer; interface DeleteCardOutput { cardId: string; deleted: boolean; message: string; } declare const LearnableWeightSchema: z.ZodObject<{ /** The current best estimate of optimal weight (multiplier) */ weight: z.ZodNumber; /** Confidence in this weight (0-1). Higher = narrower exploration spread. */ confidence: z.ZodNumber; /** Number of outcome observations that contributed to this weight */ sampleSize: z.ZodNumber; }, "strip", z.ZodTypeAny, { weight: number; confidence: number; sampleSize: number; }, { weight: number; confidence: number; sampleSize: number; }>; type LearnableWeightInput = z.infer; /** * MCP-compatible plain object schema for the create_strategy tool. * Used by the MCP SDK for tool registration. */ declare const CreateStrategyInputMCPSchema: { name: z.ZodString; description: z.ZodString; implementingClass: z.ZodString; serializedData: z.ZodOptional; learnable: z.ZodOptional>; staticWeight: z.ZodOptional; }; /** * Zod schema for runtime validation of create_strategy input. */ declare const CreateStrategyInputSchema: z.ZodObject<{ name: z.ZodString; description: z.ZodString; implementingClass: z.ZodString; serializedData: z.ZodOptional; learnable: z.ZodOptional>; staticWeight: z.ZodOptional; }, "strip", z.ZodTypeAny, { name: string; description: string; implementingClass: string; serializedData?: string | undefined; learnable?: { weight: number; confidence: number; sampleSize: number; } | undefined; staticWeight?: boolean | undefined; }, { name: string; description: string; implementingClass: string; serializedData?: string | undefined; learnable?: { weight: number; confidence: number; sampleSize: number; } | undefined; staticWeight?: boolean | undefined; }>; type CreateStrategyInput = z.infer; interface CreateStrategyOutput { success: boolean; strategyId: string; message: string; } interface SourceReference { type: 'git' | 'file' | 'url'; source: string; reference: string; milestone?: string; timestamp: string; } interface ELOContext { current: number; confidence: number; distribution: { min: number; max: number; mean: number; median: number; quartiles: [number, number, number]; }; } interface ContentWithELO { content: any; estimatedElo: number; eloConfidence: number; referenceCards?: string[]; } declare function handleCourseConfigResource(courseDB: CourseDBInterface): Promise; declare const CourseConfigUriSchema: z.ZodString; type CourseConfigUri = z.infer; interface CardResourceData { cardId: string; datashape: string; data: any; tags: string[]; elo?: number; created?: string; modified?: string; } interface CardsCollection { cards: CardResourceData[]; total: number; page?: number; limit?: number; filter?: string; } /** * Handle cards://all resource - List all cards in the course */ declare function handleCardsAllResource(courseDB: CourseDBInterface, limit?: number, offset?: number): Promise; /** * Handle cards://tag/[tagName] resource - Filter cards by tag */ declare function handleCardsTagResource(courseDB: CourseDBInterface, tagName: string, limit?: number, offset?: number): Promise; /** * Handle cards://shape/[shapeName] resource - Filter cards by DataShape */ declare function handleCardsShapeResource(courseDB: CourseDBInterface, shapeName: string, limit?: number, offset?: number): Promise; /** * Handle cards://elo/[min]-[max] resource - Filter cards by ELO range */ declare function handleCardsEloResource(courseDB: CourseDBInterface, eloRange: string, limit?: number, offset?: number): Promise; interface ShapeResource { name: string; description?: string; schema: any; category?: string; examples?: any[]; } interface ShapesCollection { shapes: ShapeResource[]; total: number; availableShapes: string[]; } /** * Handle shapes://all resource - List all available DataShapes for this course */ declare function handleShapesAllResource(courseDB: CourseDBInterface): Promise; /** * Handle shapes://[shapeName] resource - Get specific DataShape definition for this course */ declare function handleShapeSpecificResource(courseDB: CourseDBInterface, shapeName: string): Promise; interface TagResource { name: string; description?: string; cardCount: number; cardIds: string[]; created?: string; author?: string; metadata?: any; } interface TagsCollection { tags: TagResource[]; total: number; stats?: { totalTags: number; totalTaggedCards: number; averageTagsPerCard: number; mostUsedTags: { name: string; count: number; }[]; }; } interface TagDistribution { tagName: string; frequency: number; percentage: number; cardIds: string[]; } /** * Handle tags://all resource - List all available tags */ declare function handleTagsAllResource(courseDB: CourseDBInterface): Promise; /** * Handle tags://stats resource - Tag usage statistics */ declare function handleTagsStatsResource(courseDB: CourseDBInterface): Promise; /** * Handle tags://[tagName] resource - Specific tag details + card count */ declare function handleTagSpecificResource(courseDB: CourseDBInterface, tagName: string): Promise; /** * Handle tags://union/[tag1]+[tag2] resource - Cards with ANY of these tags */ declare function handleTagsUnionResource(courseDB: CourseDBInterface, tagsParam: string): Promise<{ cardIds: string[]; tags: string[]; operation: 'union'; }>; /** * Handle tags://intersect/[tag1]+[tag2] resource - Cards with ALL these tags */ declare function handleTagsIntersectResource(courseDB: CourseDBInterface, tagsParam: string): Promise<{ cardIds: string[]; tags: string[]; operation: 'intersect'; }>; /** * Handle tags://exclusive/[tag1]-[tag2] resource - Cards with tag1 but NOT tag2 */ declare function handleTagsExclusiveResource(courseDB: CourseDBInterface, tagsParam: string): Promise<{ cardIds: string[]; includeTag: string; excludeTag: string; operation: 'exclusive'; }>; /** * Handle tags://distribution resource - Tag frequency distribution */ declare function handleTagsDistributionResource(courseDB: CourseDBInterface): Promise<{ distribution: TagDistribution[]; totalTags: number; totalCards: number; }>; /** * Schema resource response structure */ interface SchemaResource { dataShapeName: string; jsonSchema: object; schemaString: string; available: boolean; lastUpdated?: string; } /** * Handle schema resource request for a specific DataShape * Returns the JSON Schema for the DataShape if available */ declare function handleSchemaResource(_courseDB: CourseDBInterface, dataShapeName: string): Promise; interface StrategySummary { _id: string; name: string; description: string; implementingClass: string; role: 'generator' | 'filter' | 'unknown'; hasLearnableWeight: boolean; staticWeight: boolean; } interface StrategiesAllResponse { strategies: StrategySummary[]; total: number; } interface StrategyDetailResponse { strategy: ContentNavigationStrategyData; role: 'generator' | 'filter' | 'unknown'; parsedConfig?: object; } interface StrategiesByRoleResponse { role: 'generator' | 'filter'; strategies: StrategySummary[]; total: number; } interface NavigatorRoleInfo { implementingClass: string; role: 'generator' | 'filter'; description: string; } interface AvailableRolesResponse { roles: NavigatorRoleInfo[]; total: number; } interface StrategySchemaField { name: string; type: string; required: boolean; description: string; default?: unknown; } interface StrategySchemaResponse { implementingClass: string; role: 'generator' | 'filter'; description: string; schema?: object; example?: object; fields?: StrategySchemaField[]; available: boolean; } /** * Handle strategies://all resource - List all navigation strategies */ declare function handleStrategiesAllResource(courseDB: CourseDBInterface): Promise; /** * Handle strategies://{strategyId} resource - Get specific strategy details */ declare function handleStrategySpecificResource(courseDB: CourseDBInterface, strategyId: string): Promise; /** * Handle strategies://role/{roleType} resource - Filter strategies by role */ declare function handleStrategiesByRoleResource(courseDB: CourseDBInterface, roleType: 'generator' | 'filter'): Promise; /** * Handle strategies://roles resource - List available strategy types */ declare function handleAvailableRolesResource(): Promise; /** * Handle strategies://schema/{implementingClass} resource - Get config schema for a strategy type */ declare function handleStrategySchemaResource(implementingClass: string): Promise; declare const RESOURCE_PATTERNS: { readonly COURSE_CONFIG: "course://config"; readonly CARDS_ALL: "cards://all"; readonly CARDS_TAG: "cards://tag/{tagName}"; readonly CARDS_SHAPE: "cards://shape/{shapeName}"; readonly CARDS_ELO: "cards://elo/{eloRange}"; readonly SHAPES_ALL: "shapes://all"; readonly SHAPES_SPECIFIC: "shapes://{shapeName}"; readonly TAGS_ALL: "tags://all"; readonly TAGS_STATS: "tags://stats"; readonly TAGS_SPECIFIC: "tags://{tagName}"; readonly TAGS_UNION: "tags://union/{tags}"; readonly TAGS_INTERSECT: "tags://intersect/{tags}"; readonly TAGS_EXCLUSIVE: "tags://exclusive/{tags}"; readonly TAGS_DISTRIBUTION: "tags://distribution"; readonly SCHEMA_SPECIFIC: "schema://{dataShapeName}"; readonly STRATEGIES_ALL: "strategies://all"; readonly STRATEGIES_SPECIFIC: "strategies://{strategyId}"; readonly STRATEGIES_ROLE: "strategies://role/{roleType}"; readonly STRATEGIES_ROLES: "strategies://roles"; readonly STRATEGIES_SCHEMA: "strategies://schema/{implementingClass}"; }; declare function handleCreateCard(courseDB: CourseDBInterface, input: CreateCardInput): Promise; declare function handleUpdateCard(courseDB: CourseDBInterface, input: UpdateCardInput): Promise; declare function handleTagCard(courseDB: CourseDBInterface, input: TagCardInput): Promise; declare function handleDeleteCard(courseDB: CourseDBInterface, input: DeleteCardInput): Promise; /** * Handle the create_strategy tool. * * Creates a new navigation strategy with the specified configuration. * Validates that the implementing class is a valid NavigatorRoles key. * Auto-generates unique IDs with collision handling. */ declare function handleCreateStrategy(courseDB: CourseDBInterface, input: CreateStrategyInput): Promise; declare const TOOL_PATTERNS: { readonly CREATE_CARD: "create_card"; readonly UPDATE_CARD: "update_card"; readonly TAG_CARD: "tag_card"; readonly DELETE_CARD: "delete_card"; readonly CREATE_STRATEGY: "create_strategy"; }; export { type AvailableRolesResponse, type CardResource, type CardResourceData, type CardsCollection, type ContentWithELO, type CourseConfigUri, CourseConfigUriSchema, type CourseResource, type CreateCardInput, CreateCardInputMCPSchema, CreateCardInputSchema, type CreateCardOutput, type CreateStrategyInput, CreateStrategyInputMCPSchema, CreateStrategyInputSchema, type CreateStrategyOutput, type DeleteCardInput, DeleteCardInputMCPSchema, DeleteCardInputSchema, type DeleteCardOutput, type ELOContext, type LearnableWeightInput, LearnableWeightSchema, MCPServer, type MCPServerOptions, type NavigatorRoleInfo, RESOURCE_PATTERNS, type SchemaResource, type ShapeResource, type ShapesCollection, type SourceReference, type StrategiesAllResponse, type StrategiesByRoleResponse, type StrategyDetailResponse, type StrategySchemaField, type StrategySchemaResponse, type StrategySummary, TOOL_PATTERNS, type TagCardInput, TagCardInputMCPSchema, TagCardInputSchema, type TagCardOutput, type TagDistribution, type TagResource, type TagsCollection, type UpdateCardInput, UpdateCardInputMCPSchema, UpdateCardInputSchema, type UpdateCardOutput, handleAvailableRolesResource, handleCardsAllResource, handleCardsEloResource, handleCardsShapeResource, handleCardsTagResource, handleCourseConfigResource, handleCreateCard, handleCreateStrategy, handleDeleteCard, handleSchemaResource, handleShapeSpecificResource, handleShapesAllResource, handleStrategiesAllResource, handleStrategiesByRoleResource, handleStrategySchemaResource, handleStrategySpecificResource, handleTagCard, handleTagSpecificResource, handleTagsAllResource, handleTagsDistributionResource, handleTagsExclusiveResource, handleTagsIntersectResource, handleTagsStatsResource, handleTagsUnionResource, handleUpdateCard };