@@ -17,6 +17,7 @@ import {
1717 handleTagsIntersectResource ,
1818 handleTagsExclusiveResource ,
1919 handleTagsDistributionResource ,
20+ handleSchemaResource ,
2021 RESOURCE_PATTERNS ,
2122} from './resources/index.js' ;
2223import {
@@ -31,8 +32,11 @@ import {
3132 type UpdateCardInput ,
3233 type TagCardInput ,
3334 type DeleteCardInput ,
35+ CreateCardInputMCPSchema ,
36+ UpdateCardInputMCPSchema ,
37+ TagCardInputMCPSchema ,
38+ DeleteCardInputMCPSchema ,
3439} from './types/tools.js' ;
35- import { z } from 'zod' ;
3640import {
3741 createFillInCardAuthoringPrompt ,
3842 createEloScoringGuidancePrompt ,
@@ -453,20 +457,44 @@ export class MCPServer {
453457 }
454458 ) ;
455459
460+ // Register schema://{dataShapeName} resource
461+ this . mcpServer . registerResource (
462+ RESOURCE_PATTERNS . SCHEMA_SPECIFIC ,
463+ new ResourceTemplate ( 'schema://{dataShapeName}' , { list : undefined } ) ,
464+ {
465+ title : 'DataShape Schema' ,
466+ description : 'Get JSON Schema for a specific DataShape to validate card data' ,
467+ mimeType : 'application/json' ,
468+ } ,
469+ async ( uri , { dataShapeName } ) => {
470+ this . logger . debug ( `MCP Server: Fetching schema for '${ dataShapeName } '` ) ;
471+ const result = await handleSchemaResource ( this . courseDB , dataShapeName as string ) ;
472+ if ( result . available ) {
473+ this . logger . info ( `MCP Server: Retrieved schema for '${ dataShapeName } '` ) ;
474+ } else {
475+ this . logger . warn ( `MCP Server: Schema not available for '${ dataShapeName } '` ) ;
476+ }
477+ return {
478+ contents : [
479+ {
480+ uri : uri . href ,
481+ text : JSON . stringify ( result , null , 2 ) ,
482+ mimeType : 'application/json' ,
483+ } ,
484+ ] ,
485+ } ;
486+ }
487+ ) ;
488+
456489 // Register create_card tool
457490 this . mcpServer . registerTool (
458491 TOOL_PATTERNS . CREATE_CARD ,
459492 {
460493 title : 'Create Card' ,
461494 description : 'Create a new course card with specified datashape and content' ,
462- inputSchema : {
463- datashape : z . string ( ) ,
464- data : z . any ( ) ,
465- tags : z . array ( z . string ( ) ) . optional ( ) ,
466- elo : z . number ( ) . optional ( ) ,
467- sourceRef : z . string ( ) . optional ( ) ,
468- } ,
495+ inputSchema : CreateCardInputMCPSchema as any ,
469496 } ,
497+ // @ts -ignore - MCP SDK type incompatibility with Zod v4
470498 async ( input ) => {
471499 const createInput = input as CreateCardInput ;
472500 this . logger . info ( `MCP Server: Creating card with datashape '${ createInput . datashape } '` ) ;
@@ -489,14 +517,9 @@ export class MCPServer {
489517 {
490518 title : 'Update Card' ,
491519 description : 'Update an existing course card (data, tags, ELO, sourceRef)' ,
492- inputSchema : {
493- cardId : z . string ( ) ,
494- data : z . any ( ) . optional ( ) ,
495- tags : z . array ( z . string ( ) ) . optional ( ) ,
496- elo : z . number ( ) . optional ( ) ,
497- sourceRef : z . string ( ) . optional ( ) ,
498- } ,
520+ inputSchema : UpdateCardInputMCPSchema as any ,
499521 } ,
522+ // @ts -ignore - MCP SDK type incompatibility with Zod v4
500523 async ( input ) => {
501524 const updateInput = input as UpdateCardInput ;
502525 this . logger . info ( `MCP Server: Updating card ${ updateInput . cardId } ` ) ;
@@ -519,13 +542,9 @@ export class MCPServer {
519542 {
520543 title : 'Tag Card' ,
521544 description : 'Add or remove tags from a course card with optional ELO update' ,
522- inputSchema : {
523- cardId : z . string ( ) ,
524- action : z . enum ( [ 'add' , 'remove' ] ) ,
525- tags : z . array ( z . string ( ) ) ,
526- updateELO : z . boolean ( ) . optional ( ) . default ( false ) ,
527- } ,
545+ inputSchema : TagCardInputMCPSchema as any ,
528546 } ,
547+ // @ts -ignore - MCP SDK type incompatibility with Zod v4
529548 async ( input ) => {
530549 const tagInput = input as TagCardInput ;
531550 this . logger . info ( `MCP Server: ${ tagInput . action === 'add' ? 'Adding' : 'Removing' } tags [${ tagInput . tags . join ( ', ' ) } ] ${ tagInput . action === 'add' ? 'to' : 'from' } card ${ tagInput . cardId } ` ) ;
@@ -548,12 +567,9 @@ export class MCPServer {
548567 {
549568 title : 'Delete Card' ,
550569 description : 'Safely delete a course card with confirmation requirement' ,
551- inputSchema : {
552- cardId : z . string ( ) ,
553- confirm : z . boolean ( ) . default ( false ) ,
554- reason : z . string ( ) . optional ( ) ,
555- } ,
570+ inputSchema : DeleteCardInputMCPSchema as any ,
556571 } ,
572+ // @ts -ignore - MCP SDK type incompatibility with Zod v4
557573 async ( input ) => {
558574 const deleteInput = input as DeleteCardInput ;
559575 this . logger . warn ( `MCP Server: Deleting card ${ deleteInput . cardId } ${ deleteInput . reason ? ` (reason: ${ deleteInput . reason } )` : '' } ` ) ;
0 commit comments