Skip to content

Conversation

@gitplaneta
Copy link
Contributor

@gitplaneta gitplaneta commented Oct 17, 2025

Summary
Copilot Agent Mode rejects the Metals MCP tool generate-scalafix-rule due to an invalid JSON Schema:

Failed to validate tool mcp_hello-world-m_generate-scalafix-rule: Error: tool parameters array type must have items.

The tool’s inputSchema.properties.targets is "type": "array" but lacks an "items" schema, causing Copilot’s validation to fail and agent mode to break.

Steps to Reproduce

  1. sbt new scala/scala3.g8
  2. code .
  3. Start Metals MCP server and enable Copilot Agent Mode
  4. Observe Copilot error

Evidence

  • mcp.trace.json excerpt:
{
  "name": "generate-scalafix-rule",
  "description": "Generate a scalafix rule and run it on the current project.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "ruleImplementation": { "type": "string", "description": "The implementation of the scalafix rule to run, this should contain the actual scalafix rule implementation." },
      "description": { "type": "string", "description": "The description of the scalafix rule to run for later MCP invocations." },
      "targets": {
        "type": "array",
        "description": "The targets to run the rule on, if empty will run on the last focused target"
        // Missing "items": { ... }
      },
      "sampleCode": { "type": "string", "description": "Sample code that we are trying to match in the rule, if nothing was matched an error will be returned with the structure of this sample." },
      "fileToRunOn": { "type": "string", "description": "File to run it all, if empty will run on all files in given targets" }
    },
    "required": ["description", "ruleImplementation"]
  }
}

@tgodzik tgodzik marked this pull request as ready for review October 17, 2025 10:21
@gitplaneta gitplaneta changed the title Add missing type to array in MCP schema bugfix: Add missing type to array in MCP schema Oct 17, 2025
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@tgodzik tgodzik merged commit fd911a1 into scalameta:main Oct 17, 2025
26 of 27 checks passed
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