@commonlyai/mcp 0.3.20 → 0.3.22

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/tools.js +22 -3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commonlyai/mcp",
3
3
  "mcpName": "io.github.Team-Commonly/commonly",
4
- "version": "0.3.20",
4
+ "version": "0.3.22",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
package/src/tools.js CHANGED
@@ -184,11 +184,13 @@ export const buildTools = (config) => {
184
184
  threadRootId: STRING,
185
185
  continueAnyway: { type: 'boolean' },
186
186
  metadata: { type: 'object', additionalProperties: true },
187
+ messageType: { type: 'string', enum: ['text', 'card'] },
188
+ payload: { type: 'object', description: 'UI card only: {kind:"ui",v:1,lang:"openui@1",catalogId,catalogRev,catalogHash,source}. Use catalogId:"commonly.ui", catalogRev:1, catalogHash:"sha256:bb8b4de07f90c06ee48f254d86478b5bd347c738b3e86cf65e2f32e26534db57". Requires messageType card and content text fallback; unknown catalogue revisions return 400.', additionalProperties: true },
187
189
  }, ['podId', 'content']),
188
- call: wrap(async ({ podId, content, replyToMessageId, threadRootId, metadata, continueAnyway }) => request(config, {
190
+ call: wrap(async ({ podId, content, replyToMessageId, threadRootId, metadata, continueAnyway, messageType, payload }) => request(config, {
189
191
  method: 'POST',
190
192
  path: `/api/agents/runtime/pods/${encodeURIComponent(podId)}/messages`,
191
- body: { content, replyToMessageId, threadRootId, metadata, continueAnyway },
193
+ body: { content, replyToMessageId, threadRootId, metadata, continueAnyway, messageType, payload },
192
194
  })),
193
195
  },
194
196
  {
@@ -651,5 +653,22 @@ export const buildTools = (config) => {
651
653
  // as the machine's OWN GitHub identity rather than ours, and it supports
652
654
  // line-level review comments, which these tools never did.
653
655
  ];
654
- return tools;
656
+ // A model can call a tool without an argument its schema requires; MCP
657
+ // clients do not enforce `required`. Interpolated into a path, a missing
658
+ // podId becomes the literal "undefined" and the backend answers 500, which
659
+ // tells the caller nothing. Refuse the call here and name the argument.
660
+ return tools.map((tool) => {
661
+ const keys = tool.inputSchema?.required || [];
662
+ if (keys.length === 0) return tool;
663
+ return {
664
+ ...tool,
665
+ call: async (args = {}, ...rest) => {
666
+ const missing = keys.filter((key) => args?.[key] === undefined || args?.[key] === null || args?.[key] === '');
667
+ if (missing.length > 0) {
668
+ return err(new Error(`${tool.name}: missing required argument${missing.length > 1 ? 's' : ''} ${missing.join(', ')}`));
669
+ }
670
+ return tool.call(args, ...rest);
671
+ },
672
+ };
673
+ });
655
674
  };