@@ -8,12 +8,13 @@ import {
88 shutdownServices ,
99 ServiceContainer ,
1010 AssetService ,
11+ WalletService ,
1112 QueueService ,
1213 DkgService ,
1314} from "./services" ;
1415import { openAPIRoute } from "@dkg/plugin-swagger" ;
15-
1616import express from "express" ;
17+ import { registerMcpTools } from "./mcp/tools" ;
1718
1819/**
1920 * DKG Publisher Plugin
@@ -161,6 +162,10 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
161162 attemptCount : z . number ( ) ,
162163 } ) ,
163164 } ,
165+ finalizeRouteConfig : ( config ) => ( {
166+ ...config ,
167+ security : [ ] ,
168+ } ) ,
164169 } ,
165170 async ( req , res ) => {
166171 if ( ! serviceContainer ) {
@@ -199,6 +204,10 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
199204 params : z . object ( {
200205 id : z . string ( ) . transform ( Number ) ,
201206 } ) ,
207+ finalizeRouteConfig : ( config ) => ( {
208+ ...config ,
209+ security : [ ] ,
210+ } ) ,
202211 } ,
203212 async ( req , res ) => {
204213 if ( ! serviceContainer ) {
@@ -232,8 +241,8 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
232241
233242 try {
234243 const queueService = serviceContainer . get < QueueService > ( "queueService" ) ;
235- const assetService = serviceContainer . get < any > ( "assetService" ) ;
236- const walletService = serviceContainer . get < any > ( "walletService" ) ;
244+ const assetService = serviceContainer . get < AssetService > ( "assetService" ) ;
245+ const walletService = serviceContainer . get < WalletService > ( "walletService" ) ;
237246
238247 // Get Redis queue stats
239248 const queueStats = await queueService . getQueueStats ( ) ;
@@ -260,7 +269,7 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
260269 capacity : {
261270 totalWallets : walletStats . total ,
262271 availableWallets : walletStats . available ,
263- lockedWallets : walletStats . locked ,
272+ lockedWallets : walletStats . inUse ,
264273 availableSlots : availableSlots , // Slots available for new jobs
265274 } ,
266275 } ) ;
@@ -275,7 +284,7 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
275284 }
276285
277286 try {
278- const walletService = serviceContainer . get < any > ( "walletService" ) ;
287+ const walletService = serviceContainer . get < WalletService > ( "walletService" ) ;
279288 const stats = await walletService . getWalletStats ( ) ;
280289 res . json ( stats ) ;
281290 } catch ( error : any ) {
@@ -312,6 +321,10 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
312321 . optional ( ) ,
313322 } ) ,
314323 } ,
324+ finalizeRouteConfig : ( config ) => ( {
325+ ...config ,
326+ security : [ ] ,
327+ } ) ,
315328 } ,
316329 async ( req , res ) => {
317330 if ( ! serviceContainer ) {
@@ -357,6 +370,10 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
357370 error : z . string ( ) . optional ( ) ,
358371 } ) ,
359372 } ,
373+ finalizeRouteConfig : ( config ) => ( {
374+ ...config ,
375+ security : [ ] ,
376+ } ) ,
360377 } ,
361378 async ( req , res ) => {
362379 if ( ! serviceContainer ) {
@@ -383,51 +400,8 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
383400 ) ,
384401 ) ;
385402
386- // MCP tool for creating knowledge assets
387- mcp . registerTool (
388- "knowledge-asset-publish" ,
389- {
390- title : "Publish Knowledge Asset" ,
391- description : "Register a JSON-LD asset for publishing to the DKG" ,
392- inputSchema : {
393- content : z . object ( { } ) . passthrough ( ) ,
394- metadata : z
395- . object ( {
396- source : z . string ( ) . optional ( ) ,
397- sourceId : z . string ( ) . optional ( ) ,
398- } )
399- . optional ( ) ,
400- privacy : z . enum ( [ "private" , "public" ] ) . optional ( ) ,
401- } ,
402- } ,
403- async ( input ) => {
404- if ( ! serviceContainer ) {
405- throw new Error ( "DKG Publisher Plugin not configured" ) ;
406- }
407-
408- const assetService = serviceContainer . get < AssetService > ( "assetService" ) ;
409-
410- const assetInput = {
411- content : input . content ,
412- metadata : input . metadata ,
413- publishOptions : {
414- privacy : input . privacy || "private" ,
415- } ,
416- } ;
417-
418- const result = await assetService . registerAsset ( assetInput ) ;
419- // Asset registration emits 'asset-queued' event which triggers queue addition
420-
421- return {
422- content : [
423- {
424- type : "text" ,
425- text : `Asset registered for publishing: ${ result . id } (Status: ${ result . status } )` ,
426- } ,
427- ] ,
428- } ;
429- } ,
430- ) ;
403+ // Register all MCP tools for publisher plugin
404+ registerMcpTools ( mcp , serviceContainer ) ;
431405} ) ;
432406
433407// Cleanup function
0 commit comments