import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';
import { type WSS } from '../wss';
const orderEnum = {
'asc': 1,
'desc': -1
};
export const register = (server: McpServer, wss: WSS) => {
server.registerTool(
'store_search',
{
description: 'Search store assets',
inputSchema: {
search: z.string(),
order: z.enum(['asc', 'desc']).optional(),
skip: z.number().optional(),
limit: z.number().optional()
}
},
({ search, order, skip, limit }) => {
return wss.call('store:playcanvas:list', {
search,
order: order ? orderEnum[order] : undefined,
skip,
limit
});
}
);
server.registerTool(
'store_get',
{
description: 'Get store asset',
inputSchema: {
id: z.string()
}
},
({ id }) => {
return wss.call('store:playcanvas:get', id);
}
);
server.registerTool(
'store_download',
{
description: 'Download store asset',
inputSchema: {
id: z.string(),
name: z.string(),
license: z.object({
author: z.string(),
authorUrl: z.string().url(),
license: z.string()
})
}
},
({ id, name, license }) => {
return wss.call('store:playcanvas:clone', id, name, license);
}
);
};