funifier-mcp 0.2.15 → 0.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp/bundle.js
CHANGED
|
@@ -77,7 +77,7 @@ Use the Read tool to read the file. When saving back, use funifier_save with fil
|
|
|
77
77
|
Full payload saved to:
|
|
78
78
|
${g}${y}`}]}}return{content:[{type:"text",text:`Found ${c.length} ${r} item(s) matching "${i}":`+`
|
|
79
79
|
|
|
80
|
-
`+l}]}}catch(o){return{content:[{type:"text",text:`Error getting ${r} ${i}: ${o.message}`}],isError:!0}}})}});var L4=x(cx=>{"use strict";Object.defineProperty(cx,"__esModule",{value:!0});cx.fetchCurrentById=VW;async function VW(e,t,r){let i;switch(t){case"trigger":i=await e.listTriggers();break;case"scheduler":i=await e.listSchedulers();break;case"aggregate":i=await e.listAggregates();break;case"websocket":i=await e.listWebsockets();break;case"widget":i=await e.listWidgets();break;case"custom-page":i=await e.listCustomPages();break;case"public-endpoint":i=await e.listPublicEndpoints();break;case"challenge-aggregate":i=await e.listChallengeAggregates();break;case"auth-module":i=await e.listAuthModules();break;case"ai-knowledge":i=await e.listAiKnowledge();break;case"action":i=await e.listActions();break;case"challenge":i=await e.listChallenges();break;case"point":i=await e.listPoints();break;case"level":i=await e.listLevels();break;case"leaderboard":i=await e.listLeaderboards();break;case"quiz":i=await e.listQuizzes();break;case"virtual-good-catalog":i=await e.listVirtualGoodCatalogs();break;case"virtual-good-item":i=await e.listVirtualGoodItems();break;default:throw new Error(`Unknown resource type: ${t}`)}return i.find(a=>a._id===r)??null}});var B4=x(ux=>{"use strict";Object.defineProperty(ux,"__esModule",{value:!0});ux.mergeResource=KW;function KW(e,t){return{...e,...t}}});var V4=x(Si=>{"use strict";var GW=Si&&Si.__createBinding||(Object.create?function(e,t,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){i===void 0&&(i=r),e[i]=t[r]}),HW=Si&&Si.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),JW=Si&&Si.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var i=[];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[i.length]=n);return i},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null)for(var i=e(t),n=0;n<i.length;n++)i[n]!=="default"&&GW(r,t,i[n]);return HW(r,t),r}}();Object.defineProperty(Si,"__esModule",{value:!0});Si.registerSaveTool=nY;var lx=sn(),dx=JW(require("fs")),WW=L4(),YW=B4(),XW=["trigger","scheduler","aggregate","websocket","widget","custom-page","public-endpoint","challenge-aggregate","auth-module","ai-knowledge","action","challenge","point","level","leaderboard","quiz","virtual-good-catalog","virtual-good-item"],QW=new Set(["trigger","scheduler","aggregate","websocket","public-endpoint","auth-module"]),eY={html:".html",css:".css",content:".content.md",aggregate:".pipeline.json"};function tY(e,t,r){let i=e.replace(/\.json$/,""),n=QW.has(t)?".script.groovy":".script.js",a={...eY,script:n},o={...r};for(let[s,c]of Object.entries(a)){let u=`${i}${c}`;dx.existsSync(u)&&(o[s]=dx.readFileSync(u,"utf-8"))}return o}async function rY(e,t,r){switch(t){case"trigger":return await e.saveTrigger(r);case"scheduler":return await e.saveScheduler(r);case"aggregate":return await e.saveAggregate(r);case"websocket":return await e.saveWebsocket(r,!r._id);case"widget":return await e.saveWidget(r);case"custom-page":return await e.saveCustomPage(r);case"public-endpoint":return await e.savePublicEndpoint(r);case"challenge-aggregate":return await e.saveChallengeAggregate(r);case"auth-module":return await e.saveAuthModule(r,!r._id);case"ai-knowledge":return await e.saveAiKnowledge(r);case"action":return await e.saveAction(r);case"challenge":return await e.saveChallenge(r);case"point":return await e.savePoint(r);case"level":return await e.saveLevel(r);case"leaderboard":return await e.saveLeaderboard(r);case"quiz":return await e.saveQuiz(r);case"virtual-good-catalog":return await e.saveVirtualGoodCatalog(r);case"virtual-good-item":return await e.saveVirtualGoodItem(r);default:throw new Error(`Unknown resource type: ${t}`)}}function nY(e,t){e.tool("funifier_save","Create or update a Funifier resource. On update (when `_id` is present in the payload), the current resource is fetched and any fields missing from the payload are preserved \u2014 you only need to send the fields you want to change. To clear a field, send it explicitly as `null`. Array and object fields are replaced wholesale when present in the payload.",{type:lx.z.enum(XW).describe("The resource type"),payload:lx.z.string().optional().describe("JSON string of the resource payload. On update, send only the fields you want to change (plus `_id`). Use `file` instead when the payload is too large to pass inline."),file:lx.z.string().optional().describe("Path to a JSON file containing the resource payload. Use this when the payload is too large to pass inline (e.g. a file previously written by funifier_get).")},async({type:r,payload:i,file:n})=>{try{let a=t.requireClient();if(!i&&!n)return{content:[{type:"text",text:"Either `payload` or `file` must be provided."}],isError:!0};let o=n?dx.readFileSync(n,"utf-8"):i,s=JSON.parse(o),c=Array.isArray(s)?s[0]:s,u=n?tY(n,r,c):c,l=u;if(!n&&u._id){let b=await(0,WW.fetchCurrentById)(a,r,u._id);if(!b)return{content:[{type:"text",text:`Cannot update ${r} ${u._id}: resource not found`}],isError:!0};l=(0,YW.mergeResource)(b,u)}let g=(await rY(a,r,l))?._id??l._id??"unknown";return{content:[{type:"text",text:`${r} saved successfully. _id: ${g}`}]}}catch(a){return{content:[{type:"text",text:`Error saving ${r}: ${a.message}`}],isError:!0}}})}});var G4=x(px=>{"use strict";Object.defineProperty(px,"__esModule",{value:!0});px.registerDeleteTool=aY;var K4=sn(),iY=["trigger","scheduler","aggregate","websocket","widget","custom-page","public-endpoint","challenge-aggregate","auth-module","ai-knowledge","action","challenge","point","level","leaderboard","quiz"];function aY(e,t){e.tool("funifier_delete","Delete a Funifier resource by type and ID",{type:K4.z.enum(iY).describe("The resource type"),id:K4.z.string().describe("The resource ID to delete")},async({type:r,id:i})=>{try{let n=t.requireClient();switch(r){case"trigger":await n.deleteTrigger(i);break;case"scheduler":await n.deleteScheduler(i);break;case"aggregate":await n.deleteAggregate(i);break;case"websocket":await n.deleteWebsocket(i);break;case"widget":await n.deleteWidget(i);break;case"custom-page":await n.deleteCustomPage(i);break;case"public-endpoint":await n.deletePublicEndpoint(i);break;case"challenge-aggregate":await n.deleteChallengeAggregate(i);break;case"auth-module":await n.deleteAuthModule(i);break;case"ai-knowledge":await n.deleteAiKnowledge(i);break;case"action":await n.deleteAction(i);break;case"challenge":await n.deleteChallenge(i);break;case"point":await n.deletePoint(i);break;case"level":await n.deleteLevel(i);break;case"leaderboard":await n.deleteLeaderboard(i);break;case"quiz":await n.deleteQuiz(i);break;default:return{content:[{type:"text",text:`Unknown resource type: ${r}`}],isError:!0}}return{content:[{type:"text",text:`Successfully deleted ${r} with id ${i}`}]}}catch(n){return{content:[{type:"text",text:`Error deleting ${r} ${i}: ${n.message}`}],isError:!0}}})}});var H4=x(mx=>{"use strict";Object.defineProperty(mx,"__esModule",{value:!0});mx.registerExecuteTool=oY;var fx=sn();function oY(e,t){e.tool("funifier_execute","Execute a Funifier resource (scheduler, aggregate, or public-endpoint)",{type:fx.z.enum(["scheduler","aggregate","public-endpoint"]).describe("The resource type to execute"),id:fx.z.string().describe("The resource ID to execute"),params:fx.z.string().optional().describe("Optional JSON string of execution parameters")},async({type:r,id:i,params:n})=>{try{let a=t.requireClient(),o;switch(r){case"scheduler":o=await a.executeScheduler(i);break;case"aggregate":{let s=n?JSON.parse(n):{};o=await a.executeAggregate(i,s);break}case"public-endpoint":{if(!n)return{content:[{type:"text",text:"public-endpoint execution requires params with apiKey, method, and payload"}],isError:!0};let s=JSON.parse(n),{apiKey:c,method:u,payload:l}=s;if(!c||!u)return{content:[{type:"text",text:"public-endpoint params must include apiKey and method"}],isError:!0};o=await a.executePublicEndpoint(c,i,l||{},u);break}default:return{content:[{type:"text",text:`Execute is not supported for type: ${r}. Supported types: scheduler, aggregate, public-endpoint`}],isError:!0}}return{content:[{type:"text",text:JSON.stringify(o,null,2)}]}}catch(a){return{content:[{type:"text",text:`Error executing ${r} ${i}: ${a.message}`}],isError:!0}}})}});var W4=x(hx=>{"use strict";Object.defineProperty(hx,"__esModule",{value:!0});hx.registerLogsTool=sY;var J4=sn();function sY(e,t){e.tool("funifier_logs","Get execution logs for a Funifier resource (trigger or scheduler)",{type:J4.z.enum(["trigger","scheduler"]).describe("The resource type to get logs for"),id:J4.z.string().describe("The resource ID")},async({type:r,id:i})=>{try{let n=t.requireClient(),a;switch(r){case"trigger":a=await n.getTriggerLogs(i);break;case"scheduler":a=await n.getSchedulerLogs(i);break;default:return{content:[{type:"text",text:`Logs are not supported for type: ${r}. Supported types: trigger, scheduler`}],isError:!0}}return{content:[{type:"text",text:JSON.stringify(a,null,2)}]}}catch(n){return{content:[{type:"text",text:`Error getting logs for ${r} ${i}: ${n.message}`}],isError:!0}}})}});var X4=x(gx=>{"use strict";Object.defineProperty(gx,"__esModule",{value:!0});gx.registerDatabaseTool=cY;var Qi=sn(),Y4=ix();function cY(e,t){e.tool("funifier_database","Query or aggregate any Funifier database collection. Use action='query' for simple queries with filters, or action='aggregate' for MongoDB aggregate pipelines. Use action='collections' to list all available collections.",{action:Qi.z.enum(["query","aggregate","collections","insert","update","delete","bulk"]).describe("'query' for filtered reads, 'aggregate' for pipelines, 'collections' to list all, 'insert' to create a document (POST), 'update' to update a document (PUT, requires _id in data), 'delete' to remove documents (requires query filter), 'bulk' to insert/update multiple documents"),collection:Qi.z.string().optional().describe("The collection name (e.g., 'player', 'action_log', 'videos__c'). Required for query and aggregate."),query:Qi.z.string().optional().describe(`For action='query': JSON string of MongoDB query filter (e.g., '{"userId":"john"}'). Defaults to {} (all documents).`),pipeline:Qi.z.string().optional().describe("For action='aggregate': JSON string of MongoDB aggregate pipeline array"),sort:Qi.z.string().optional().describe(`For action='query': JSON string of sort object (e.g., '{"time":-1}').`),limit:Qi.z.number().optional().describe("For action='query': Maximum number of documents to return. Default: 10."),offset:Qi.z.number().optional().describe("For action='query': Number of documents to skip for pagination. Default: 0."),data:Qi.z.string().optional().describe("For insert/update/bulk: JSON string of document(s). For insert: single object. For update: object with _id field. For bulk: array of objects.")},async({action:r,collection:i,query:n,pipeline:a,sort:o,limit:s,offset:c,data:u})=>{try{let l=t.requireClient();if(r==="collections"){let p=await l.getCollections();return{content:[{type:"text",text:`Found ${p.length} collections:
|
|
80
|
+
`+l}]}}catch(o){return{content:[{type:"text",text:`Error getting ${r} ${i}: ${o.message}`}],isError:!0}}})}});var L4=x(cx=>{"use strict";Object.defineProperty(cx,"__esModule",{value:!0});cx.fetchCurrentById=VW;async function VW(e,t,r){let i;switch(t){case"trigger":i=await e.listTriggers();break;case"scheduler":i=await e.listSchedulers();break;case"aggregate":i=await e.listAggregates();break;case"websocket":i=await e.listWebsockets();break;case"widget":i=await e.listWidgets();break;case"custom-page":i=await e.listCustomPages();break;case"public-endpoint":i=await e.listPublicEndpoints();break;case"challenge-aggregate":i=await e.listChallengeAggregates();break;case"auth-module":i=await e.listAuthModules();break;case"ai-knowledge":i=await e.listAiKnowledge();break;case"action":i=await e.listActions();break;case"challenge":i=await e.listChallenges();break;case"point":i=await e.listPoints();break;case"level":i=await e.listLevels();break;case"leaderboard":i=await e.listLeaderboards();break;case"quiz":i=await e.listQuizzes();break;case"virtual-good-catalog":i=await e.listVirtualGoodCatalogs();break;case"virtual-good-item":i=await e.listVirtualGoodItems();break;default:throw new Error(`Unknown resource type: ${t}`)}return i.find(a=>a._id===r)??null}});var B4=x(ux=>{"use strict";Object.defineProperty(ux,"__esModule",{value:!0});ux.mergeResource=KW;function KW(e,t){return{...e,...t}}});var V4=x(Si=>{"use strict";var GW=Si&&Si.__createBinding||(Object.create?function(e,t,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){i===void 0&&(i=r),e[i]=t[r]}),HW=Si&&Si.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),JW=Si&&Si.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var i=[];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[i.length]=n);return i},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null)for(var i=e(t),n=0;n<i.length;n++)i[n]!=="default"&&GW(r,t,i[n]);return HW(r,t),r}}();Object.defineProperty(Si,"__esModule",{value:!0});Si.registerSaveTool=nY;var lx=sn(),dx=JW(require("fs")),WW=L4(),YW=B4(),XW=["trigger","scheduler","aggregate","websocket","widget","custom-page","public-endpoint","challenge-aggregate","auth-module","ai-knowledge","action","challenge","point","level","leaderboard","quiz","virtual-good-catalog","virtual-good-item"],QW=new Set(["trigger","scheduler","aggregate","websocket","public-endpoint","auth-module"]),eY={html:".html",css:".css",content:".content.md",aggregate:".pipeline.json"};function tY(e,t,r){let i=e.replace(/\.json$/,""),n=QW.has(t)?".script.groovy":".script.js",a={...eY,script:n},o={...r};for(let[s,c]of Object.entries(a)){let u=`${i}${c}`;dx.existsSync(u)&&(o[s]=dx.readFileSync(u,"utf-8"))}return o}async function rY(e,t,r){switch(t){case"trigger":return await e.saveTrigger(r);case"scheduler":return await e.saveScheduler(r);case"aggregate":return await e.saveAggregate(r);case"websocket":return await e.saveWebsocket(r,!r._id);case"widget":return await e.saveWidget(r);case"custom-page":return await e.saveCustomPage(r);case"public-endpoint":return await e.savePublicEndpoint(r);case"challenge-aggregate":return await e.saveChallengeAggregate(r);case"auth-module":return await e.saveAuthModule(r,!r._id);case"ai-knowledge":return await e.saveAiKnowledge(r);case"action":return await e.saveAction(r);case"challenge":return await e.saveChallenge(r);case"point":return await e.savePoint(r);case"level":return await e.saveLevel(r);case"leaderboard":return await e.saveLeaderboard(r);case"quiz":return await e.saveQuiz(r);case"virtual-good-catalog":return await e.saveVirtualGoodCatalog(r);case"virtual-good-item":return await e.saveVirtualGoodItem(r);default:throw new Error(`Unknown resource type: ${t}`)}}function nY(e,t){e.tool("funifier_save","Create or update a Funifier resource. On update (when `_id` is present in the payload), the current resource is fetched and any fields missing from the payload are preserved \u2014 you only need to send the fields you want to change. To clear a field, send it explicitly as `null`. Array and object fields are replaced wholesale when present in the payload.",{type:lx.z.enum(XW).describe("The resource type"),payload:lx.z.string().optional().describe("JSON string of the resource payload. On update, send only the fields you want to change (plus `_id`). Use `file` instead when the payload is too large to pass inline."),file:lx.z.string().optional().describe("Path to a JSON file containing the resource payload. Use this when the payload is too large to pass inline (e.g. a file previously written by funifier_get).")},async({type:r,payload:i,file:n})=>{try{let a=t.requireClient();if(!i&&!n)return{content:[{type:"text",text:"Either `payload` or `file` must be provided."}],isError:!0};let o=n?dx.readFileSync(n,"utf-8"):i,s=JSON.parse(o),c=Array.isArray(s)?s[0]:s,u=n?tY(n,r,c):c,l=u;if(u._id){let b=await(0,WW.fetchCurrentById)(a,r,u._id);if(!b)return{content:[{type:"text",text:`Cannot update ${r} ${u._id}: resource not found`}],isError:!0};l=(0,YW.mergeResource)(b,u)}let g=(await rY(a,r,l))?._id??l._id??"unknown";return{content:[{type:"text",text:`${r} saved successfully. _id: ${g}`}]}}catch(a){return{content:[{type:"text",text:`Error saving ${r}: ${a.message}`}],isError:!0}}})}});var G4=x(px=>{"use strict";Object.defineProperty(px,"__esModule",{value:!0});px.registerDeleteTool=aY;var K4=sn(),iY=["trigger","scheduler","aggregate","websocket","widget","custom-page","public-endpoint","challenge-aggregate","auth-module","ai-knowledge","action","challenge","point","level","leaderboard","quiz"];function aY(e,t){e.tool("funifier_delete","Delete a Funifier resource by type and ID",{type:K4.z.enum(iY).describe("The resource type"),id:K4.z.string().describe("The resource ID to delete")},async({type:r,id:i})=>{try{let n=t.requireClient();switch(r){case"trigger":await n.deleteTrigger(i);break;case"scheduler":await n.deleteScheduler(i);break;case"aggregate":await n.deleteAggregate(i);break;case"websocket":await n.deleteWebsocket(i);break;case"widget":await n.deleteWidget(i);break;case"custom-page":await n.deleteCustomPage(i);break;case"public-endpoint":await n.deletePublicEndpoint(i);break;case"challenge-aggregate":await n.deleteChallengeAggregate(i);break;case"auth-module":await n.deleteAuthModule(i);break;case"ai-knowledge":await n.deleteAiKnowledge(i);break;case"action":await n.deleteAction(i);break;case"challenge":await n.deleteChallenge(i);break;case"point":await n.deletePoint(i);break;case"level":await n.deleteLevel(i);break;case"leaderboard":await n.deleteLeaderboard(i);break;case"quiz":await n.deleteQuiz(i);break;default:return{content:[{type:"text",text:`Unknown resource type: ${r}`}],isError:!0}}return{content:[{type:"text",text:`Successfully deleted ${r} with id ${i}`}]}}catch(n){return{content:[{type:"text",text:`Error deleting ${r} ${i}: ${n.message}`}],isError:!0}}})}});var H4=x(mx=>{"use strict";Object.defineProperty(mx,"__esModule",{value:!0});mx.registerExecuteTool=oY;var fx=sn();function oY(e,t){e.tool("funifier_execute","Execute a Funifier resource (scheduler, aggregate, or public-endpoint)",{type:fx.z.enum(["scheduler","aggregate","public-endpoint"]).describe("The resource type to execute"),id:fx.z.string().describe("The resource ID to execute"),params:fx.z.string().optional().describe("Optional JSON string of execution parameters")},async({type:r,id:i,params:n})=>{try{let a=t.requireClient(),o;switch(r){case"scheduler":o=await a.executeScheduler(i);break;case"aggregate":{let s=n?JSON.parse(n):{};o=await a.executeAggregate(i,s);break}case"public-endpoint":{if(!n)return{content:[{type:"text",text:"public-endpoint execution requires params with apiKey, method, and payload"}],isError:!0};let s=JSON.parse(n),{apiKey:c,method:u,payload:l}=s;if(!c||!u)return{content:[{type:"text",text:"public-endpoint params must include apiKey and method"}],isError:!0};o=await a.executePublicEndpoint(c,i,l||{},u);break}default:return{content:[{type:"text",text:`Execute is not supported for type: ${r}. Supported types: scheduler, aggregate, public-endpoint`}],isError:!0}}return{content:[{type:"text",text:JSON.stringify(o,null,2)}]}}catch(a){return{content:[{type:"text",text:`Error executing ${r} ${i}: ${a.message}`}],isError:!0}}})}});var W4=x(hx=>{"use strict";Object.defineProperty(hx,"__esModule",{value:!0});hx.registerLogsTool=sY;var J4=sn();function sY(e,t){e.tool("funifier_logs","Get execution logs for a Funifier resource (trigger or scheduler)",{type:J4.z.enum(["trigger","scheduler"]).describe("The resource type to get logs for"),id:J4.z.string().describe("The resource ID")},async({type:r,id:i})=>{try{let n=t.requireClient(),a;switch(r){case"trigger":a=await n.getTriggerLogs(i);break;case"scheduler":a=await n.getSchedulerLogs(i);break;default:return{content:[{type:"text",text:`Logs are not supported for type: ${r}. Supported types: trigger, scheduler`}],isError:!0}}return{content:[{type:"text",text:JSON.stringify(a,null,2)}]}}catch(n){return{content:[{type:"text",text:`Error getting logs for ${r} ${i}: ${n.message}`}],isError:!0}}})}});var X4=x(gx=>{"use strict";Object.defineProperty(gx,"__esModule",{value:!0});gx.registerDatabaseTool=cY;var Qi=sn(),Y4=ix();function cY(e,t){e.tool("funifier_database","Query or aggregate any Funifier database collection. Use action='query' for simple queries with filters, or action='aggregate' for MongoDB aggregate pipelines. Use action='collections' to list all available collections.",{action:Qi.z.enum(["query","aggregate","collections","insert","update","delete","bulk"]).describe("'query' for filtered reads, 'aggregate' for pipelines, 'collections' to list all, 'insert' to create a document (POST), 'update' to update a document (PUT, requires _id in data), 'delete' to remove documents (requires query filter), 'bulk' to insert/update multiple documents"),collection:Qi.z.string().optional().describe("The collection name (e.g., 'player', 'action_log', 'videos__c'). Required for query and aggregate."),query:Qi.z.string().optional().describe(`For action='query': JSON string of MongoDB query filter (e.g., '{"userId":"john"}'). Defaults to {} (all documents).`),pipeline:Qi.z.string().optional().describe("For action='aggregate': JSON string of MongoDB aggregate pipeline array"),sort:Qi.z.string().optional().describe(`For action='query': JSON string of sort object (e.g., '{"time":-1}').`),limit:Qi.z.number().optional().describe("For action='query': Maximum number of documents to return. Default: 10."),offset:Qi.z.number().optional().describe("For action='query': Number of documents to skip for pagination. Default: 0."),data:Qi.z.string().optional().describe("For insert/update/bulk: JSON string of document(s). For insert: single object. For update: object with _id field. For bulk: array of objects.")},async({action:r,collection:i,query:n,pipeline:a,sort:o,limit:s,offset:c,data:u})=>{try{let l=t.requireClient();if(r==="collections"){let p=await l.getCollections();return{content:[{type:"text",text:`Found ${p.length} collections:
|
|
81
81
|
|
|
82
82
|
${p.join(`
|
|
83
83
|
`)}`}]}}if(!i)return{content:[{type:"text",text:"Error: 'collection' is required for query and aggregate actions."}],isError:!0};if(r==="query"){let p=n?JSON.parse(n):{},g=o?JSON.parse(o):void 0,b=await l.queryCollection(i,p,{sort:g,limit:s??10,skip:c??0}),m=`Found ${b.length} document(s) in '${i}':`;return(0,Y4.applyCharGuard)(b,m)}if(r==="aggregate"){if(!a)return{content:[{type:"text",text:"Error: 'pipeline' is required for aggregate action."}],isError:!0};let p=JSON.parse(a),g=await l.aggregateCollection(i,p),b=Array.isArray(g)?g:[g],m=`Aggregate result (${b.length} document(s)) from '${i}':`;return(0,Y4.applyCharGuard)(b,m)}if(r==="insert"){if(!u)return{content:[{type:"text",text:"Error: 'data' is required for insert action."}],isError:!0};let p=JSON.parse(u),g=await l.insertDocument(i,p);return{content:[{type:"text",text:`Inserted document into '${i}':
|
|
@@ -143,7 +143,7 @@ Found existing funifier.json \u2014 serverUrl: ${l.serverUrl}`),await n({message
|
|
|
143
143
|
\u2705 Setup complete.`),r.some(a=>a.key==="claude-code")&&console.log(" Claude Code: type /funifier-help to start."),r.some(a=>a.key==="antigravity")){let a=process.env.USERPROFILE||process.env.HOME||"~",o=Hr.join(a,".gemini","antigravity","mcp_config.json");console.log(` Antigravity: merge .antigravity/mcp_config.json into ${o}`),console.log(" Or: Antigravity \u2192 Manage MCP Servers \u2192 View raw config \u2192 add the funifier block")}if(r.some(a=>a.key==="kimi")){let a=process.env.USERPROFILE||process.env.HOME||"~",o=Hr.join(a,".kimi","mcp.json");console.log(` Kimi: merge .kimi/mcp.json into ${o}`),console.log(" Or: run `kimi mcp add --transport stdio funifier -- node <path-to-bundle.js>`")}i||console.log(" \u26A0 Fill in funifier.json.example and rename to funifier.json before using the MCP.")}});var sj=x(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});Jc.tokenize=Zp;Jc.buildIndex=MQ;Jc.scoreFiles=NQ;var RQ=new Set(["the","and","for","are","but","not","you","all","can","her","was","one","our","had","has","have","that","this","with","they","from","will","been","its","than","then","when","who","what","how","into","more","also","use","used","using","which","about","each","some","such","any"]),AQ=new Set(["de","da","do","em","no","na","um","uma","que","com","por","para","dos","das","nos","nas","ser","ter","seu","sua","seus","suas","isso","este","esta","esse","essa","como","mais","mas","ele","ela","eles","elas","nao","sem","pode","pois","caso","cada","onde","quando","todo","toda","todos"]);function Zp(e){return e.toLowerCase().split(/[\s\W_]+/).filter(t=>t.length>=3&&!RQ.has(t)&&!AQ.has(t))}function MQ(e){let t={files:{},idf:{}},r={},i=e.size;for(let[n,a]of e){let o=Zp(a),s={};for(let u of o)s[u]=(s[u]??0)+1;let c=[];for(let u of a.split(`
|
|
144
144
|
`))/^#{1,2}\s/.test(u)&&c.push(...Zp(u.replace(/^#+\s*/,"")));t.files[n]={tokens:s,headings:c,totalTokens:o.length};for(let u of Object.keys(s))r[u]=(r[u]??0)+1}for(let[n,a]of Object.entries(r))t.idf[n]=Math.log((i+1)/(a+1));return t}function NQ(e,t,r={}){let{skillDocs:i=[],minScore:n=-1/0,top:a}=r,o=Zp(e),s=[];for(let[c,u]of Object.entries(t.files)){let l=0;for(let p of o){let g=(u.tokens[p]??0)/Math.max(u.totalTokens,1),b=t.idf[p]??0;l+=g*b,u.headings.includes(p)&&(l+=.3)}i.includes(c)&&(l+=.2),l>n&&s.push({file:c,score:l})}return s.sort((c,u)=>u.score-c.score),a!==void 0?s.slice(0,a):s}});var lj=x(Ii=>{"use strict";var ZQ=Ii&&Ii.__createBinding||(Object.create?function(e,t,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){i===void 0&&(i=r),e[i]=t[r]}),FQ=Ii&&Ii.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),uj=Ii&&Ii.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var i=[];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[i.length]=n);return i},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null)for(var i=e(t),n=0;n<i.length;n++)i[n]!=="default"&&ZQ(r,t,i[n]);return FQ(r,t),r}}();Object.defineProperty(Ii,"__esModule",{value:!0});Ii.default=LQ;var Fp=uj(require("fs")),cj=uj(require("path")),zQ=sj(),qQ=yx();function UQ(e){let t=e.slice(3),r=t.find(n=>!n.startsWith("--"))??"",i=n=>{let a=t.find(s=>s.startsWith(`--${n}=`))?.split("=").slice(1).join("=");if(a!==void 0)return a;let o=t.indexOf(`--${n}`);return o>=0?t[o+1]:void 0};return{query:r,top:i("top")?parseInt(i("top"),10):3,skillId:i("skill"),minScore:i("min-score")?parseFloat(i("min-score")):.5}}function LQ(){let{query:e,top:t,skillId:r,minScore:i}=UQ(process.argv);e||(console.error('Usage: funifier-mcp search "<query>" [--top N] [--skill <id>] [--min-score N]'),process.exit(1));let n=(0,qQ.resolvePackageRoot)(),a=cj.join(n,"datasource-funifier-docs",".search-index.json"),o=cj.join(n,"datasource-funifier-docs",".skills-map.json");Fp.existsSync(a)||(console.error("ERROR: .search-index.json not found. Run `npm run build:skills` first."),process.exit(1));let s=JSON.parse(Fp.readFileSync(a,"utf-8")),c=[];r&&Fp.existsSync(o)&&(c=JSON.parse(Fp.readFileSync(o,"utf-8"))[r]??[]);let u=(0,zQ.scoreFiles)(e,s,{skillDocs:c,minScore:i,top:t}),l="\u2500".repeat(53);console.log(`
|
|
145
145
|
SEARCH: "${e}"`),console.log(l),u.length===0?console.log("No results above score threshold."):u.forEach((p,g)=>{let b=`datasource-funifier-docs/${p.file}`;console.log(`${g+1}. ${b.padEnd(60)} [score: ${p.score.toFixed(2)}]`)}),console.log(l),console.log(`Read files with score > ${i}. Skip others.
|
|
146
|
-
`)}});var dj=x((Nce,BQ)=>{BQ.exports={name:"funifier-mcp",version:"0.2.
|
|
146
|
+
`)}});var dj=x((Nce,BQ)=>{BQ.exports={name:"funifier-mcp",version:"0.2.16",description:"Funifier AI toolkit \u2014 MCP server, API client, and Claude Code skills for the Funifier gamification platform",main:"dist/index.js",types:"dist/index.d.ts",bin:{"funifier-mcp":"dist/mcp/index.js"},files:["dist","skills","doc","datasource-funifier-docs","AGENTS.md",".github/copilot-instructions.md",".cursor/rules/funifier.mdc","README.md","LICENSE"],repository:{type:"git",url:"git+https://github.com/funifierinc/funifier-mcp.git"},bugs:{url:"https://github.com/funifierinc/funifier-mcp/issues"},homepage:"https://github.com/funifierinc/funifier-mcp#readme",author:"Funifier",publishConfig:{access:"public"},scripts:{build:"tsc",bundle:"npm run build && esbuild dist/mcp/index.js --bundle --outfile=dist/mcp/bundle.js --format=cjs --platform=node --minify",dev:"tsc --watch",prepublishOnly:"npm run build:skills && npm run bundle",test:"vitest run","test:watch":"vitest watch","build:skills":"tsx scripts/build-skills.ts","build:skills:force":"tsx scripts/build-skills.ts --force","search:docs":"tsx scripts/search-docs.ts"},keywords:["funifier","gamification","mcp","model-context-protocol","claude","ai","api-client"],license:"MIT",dependencies:{"@inquirer/prompts":"^7.10.1","@modelcontextprotocol/sdk":"^1.0.0",axios:"^1.6.0",zod:"^3.25.76"},devDependencies:{"@types/node":"^25.5.0",esbuild:"^0.20.0",tsx:"^4.21.0",typescript:"^5.3.0",vitest:"^1.0.0"},engines:{node:">=18"}}});Object.defineProperty(exports,"__esModule",{value:!0});var VQ=Xh(),KQ=Mw(),GQ=N4(),HQ=Q4(),JQ=tE(),WQ=rE();async function YQ(){let e=process.argv[2];if(e==="init"){let{default:a}=oj();await a();return}if(e==="search"){let{default:a}=lj();a();return}if(e==="--version"||e==="-v"){let a=dj();console.log(a.version);return}if(e==="--help"||e==="-h"){console.log("Usage: funifier-mcp Start the MCP server (stdio)"),console.log(" funifier-mcp init Interactive setup for AI platforms"),console.log(' funifier-mcp search "<query>" Search Funifier documentation'),console.log(" funifier-mcp --version Print version");return}let t=new GQ.ApiHolder,r=t.tryAutoConnect(),i=new VQ.McpServer({name:"funifier-mcp-server",version:"0.1.0"});(0,HQ.registerTools)(i,t),(0,JQ.registerResources)(i),(0,WQ.registerPrompts)(i);let n=new KQ.StdioServerTransport;await i.connect(n),r||console.error("Funifier MCP server started without auto-config. Use funifier_connect tool to connect.")}YQ().catch(e=>{console.error("Fatal error starting Funifier MCP server:",e),process.exit(1)});
|
|
147
147
|
/*! Bundled license information:
|
|
148
148
|
|
|
149
149
|
mime-db/index.js:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/save.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AA2F1C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/save.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AA2F1C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,QAuDvE"}
|
package/dist/mcp/tools/save.js
CHANGED
|
@@ -139,9 +139,8 @@ function registerSaveTool(server, apiHolder) {
|
|
|
139
139
|
// funifier_get saves an array; unwrap if needed
|
|
140
140
|
const unwrapped = Array.isArray(parsed) ? parsed[0] : parsed;
|
|
141
141
|
const data = file ? mergeCompanions(file, type, unwrapped) : unwrapped;
|
|
142
|
-
// When loading from file, the payload is already complete — skip merge to avoid overwriting edits.
|
|
143
142
|
let toSave = data;
|
|
144
|
-
if (
|
|
143
|
+
if (data._id) {
|
|
145
144
|
const current = await (0, _fetch_current_1.fetchCurrentById)(api, type, data._id);
|
|
146
145
|
if (!current) {
|
|
147
146
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save.js","sourceRoot":"","sources":["../../../src/mcp/tools/save.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,
|
|
1
|
+
{"version":3,"file":"save.js","sourceRoot":"","sources":["../../../src/mcp/tools/save.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,4CAuDC;AAtJD,6BAAwB;AACxB,uCAAyB;AAIzB,qDAAkE;AAClE,qCAAyC;AAEzC,MAAM,cAAc,GAAG;IACrB,SAAS;IACT,WAAW;IACX,WAAW;IACX,WAAW;IACX,QAAQ;IACR,aAAa;IACb,iBAAiB;IACjB,qBAAqB;IACrB,aAAa;IACb,cAAc;IACd,QAAQ;IACR,WAAW;IACX,OAAO;IACP,OAAO;IACP,aAAa;IACb,MAAM;IACN,sBAAsB;IACtB,mBAAmB;CACX,CAAC;AAEX,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC,CAAC;AAEnH,MAAM,gBAAgB,GAA2B;IAC/C,IAAI,EAAE,OAAO;IACb,GAAG,EAAE,MAAM;IACX,OAAO,EAAE,aAAa;IACtB,SAAS,EAAE,gBAAgB;CAC5B,CAAC;AAEF,SAAS,eAAe,CAAC,QAAgB,EAAE,IAAY,EAAE,GAAQ;IAC/D,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC7C,MAAM,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