Skip to content

Conversation

@ashir6892
Copy link
Contributor

@ashir6892 ashir6892 commented Jan 10, 2026

Summary

Fixes an issue where skill_mcp fails with Invalid arguments JSON error when OpenCode's tool invocation system passes arguments as pre-parsed objects instead of JSON strings.

Problem

OpenCode's plugin tool system can pass arguments as already-parsed JavaScript objects rather than raw JSON strings. When this happens, the parseArguments function receives an object instead of a string, causing:

Invalid arguments JSON: JSON Parse error: Unexpected identifier "object"

Expected a valid JSON object, e.g.: '{"key": "value"}'
Received: [object Object]

This breaks skill_mcp usage with Playwright and other MCP tools.

Solution

Added a type check in parseArguments to handle both cases:

  • String arguments: Original behavior, parsed via JSON.parse()
  • Object arguments: Already parsed by OpenCode, returned directly

Changes

  • src/tools/skill-mcp/tools.ts: Added object type check in parseArguments
  • src/tools/skill-mcp/types.ts: Updated SkillMcpArgs.arguments type to accept both string and object

Testing

Tested with Playwright MCP browser automation - browser_navigate, browser_evaluate, and other tools now work correctly when arguments are passed as objects by OpenCode.

Some LLM tool frameworks pre-parse JSON string arguments into objects
before passing them to the tool. This causes parseArguments to fail
with 'Invalid arguments JSON' error when it receives [object Object].

This fix adds a type check to handle both:
- String arguments (original behavior, parsed via JSON.parse)
- Object arguments (already parsed by framework, returned directly)

Fixes issue where skill_mcp fails with Playwright and other MCP tools
when arguments are passed as JSON objects by the LLM framework.
@github-actions
Copy link
Contributor

github-actions bot commented Jan 10, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@ashir6892
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Jan 10, 2026
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Confidence score: 3/5

  • Runtime and type expectations diverge in src/tools/skill-mcp/types.ts, so widened object inputs will still be rejected and users can’t successfully call the tool with objects.
  • Impact is direct: the API now advertises support for objects but the schema remains string-only, creating a regression for callers who trust the types.
  • Pay close attention to src/tools/skill-mcp/types.ts - align the runtime schema with the widened type before merging.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/tools/skill-mcp/types.ts">

<violation number="1" location="src/tools/skill-mcp/types.ts:6">
P1: Type widened to allow object arguments but runtime tool schema still only accepts strings, so object inputs will be rejected before execution.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

resource_name?: string
prompt_name?: string
arguments?: string
arguments?: string | Record<string, unknown>
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Type widened to allow object arguments but runtime tool schema still only accepts strings, so object inputs will be rejected before execution.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/tools/skill-mcp/types.ts, line 6:

<comment>Type widened to allow object arguments but runtime tool schema still only accepts strings, so object inputs will be rejected before execution.</comment>

<file context>
@@ -3,6 +3,6 @@ export interface SkillMcpArgs {
   resource_name?: string
   prompt_name?: string
-  arguments?: string
+  arguments?: string | Record<string, unknown>
   grep?: string
 }
</file context>
Fix with Cubic

renekris added a commit to renekris/oh-my-glm that referenced this pull request Jan 10, 2026
renekris pushed a commit to renekris/oh-my-glm that referenced this pull request Jan 11, 2026
@code-yeongyu code-yeongyu merged commit 0809de8 into code-yeongyu:dev Jan 11, 2026
3 of 4 checks passed
kdcokenny pushed a commit that referenced this pull request Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants