Skip to content

MCP client - inputSchema containing anyOf #1491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
edeandrea opened this issue May 14, 2025 · 8 comments
Open

MCP client - inputSchema containing anyOf #1491

edeandrea opened this issue May 14, 2025 · 8 comments

Comments

@edeandrea
Copy link
Collaborator

I'm trying to build an MCP client to https://github.com/GongRzhe/Office-Word-MCP-Server. At startup, when ToolSpecificationHelper.toolSpecificationListFromMcpResponse runs, one of the entries in the array looks like the following.

You'll notice in the inputSchema.properties there are some properties that don't have a type key directly. Instead they have "anyOf": ["type":]...

Quarkus langchain4j seems to blow up with this, specifically in ToolSpecificationHelper.jsonNodeToJsonSchemaElement. It doesn't know what to do with anyOf.

{
  "name": "add_paragraph",
  "description": "\nAdd paragraph text to document\n\nParameters:\n- text: Paragraph text content\n- bold: Whether to bold\n- italic: Whether to italicize\n- underline: Whether to underline\n- font_size: Font size (points)\n- font_name: Font name\n- color: Text color (format: #FF0000)\n- alignment: Alignment (left, center, right, justify)\n",
  "inputSchema": {
    "properties": {
      "text": {
        "title": "Text",
        "type": "string"
      },
      "bold": {
        "default": false,
        "title": "Bold",
        "type": "boolean"
      },
      "italic": {
        "default": false,
        "title": "Italic",
        "type": "boolean"
      },
      "underline": {
        "default": false,
        "title": "Underline",
        "type": "boolean"
      },
      "font_size": {
        "anyOf": [
          {
            "type": "integer"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "title": "Font Size"
      },
      "font_name": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "title": "Font Name"
      },
      "color": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "title": "Color"
      },
      "alignment": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "title": "Alignment"
      }
    },
    "required": [
      "text"
    ],
    "title": "add_paragraphArguments",
    "type": "object"
  }
}
@edeandrea
Copy link
Collaborator Author

I'm not sure if this is an issue here in Quarkus Langchain4j, or if its an issue with the MCP server, as I don't see the anyOf key anywhere when looking at the MCP spec for tools/list

@geoand
Copy link
Collaborator

geoand commented May 14, 2025

cc @jmartisk @mkouba

@jmartisk
Copy link
Collaborator

What version are you using? I fixed that recently via langchain4j/langchain4j#2963

@jmartisk
Copy link
Collaborator

Yeah the MCP spec doesn't say anything about this, so I'm also a bit confused and I'm not sure if it's considered valid, but multiple MCP servers seem to be doing this, including @modelcontextprotocol/server-github which is kinda official

@edeandrea
Copy link
Collaborator Author

edeandrea commented May 15, 2025 via email

@jmartisk
Copy link
Collaborator

0.27 CR2 is probably still too old, but I assume @geoand is going to release 1.0.0.CR1 which will contain langchain4j-bom 1.0.0, which contains langchain4j-mcp 1.0.0.Beta5, which fixes this (hopefully I didn't get too tangled in the versions)

@geoand
Copy link
Collaborator

geoand commented May 15, 2025

That is correct. I'll do that tomorrow morning most likely

@edeandrea
Copy link
Collaborator Author

Then I will wait....

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

No branches or pull requests

3 participants