Skip to content
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

MCP - Handling Complex Schemas + System Prompt #5429

Open
lnvestor opened this issue Jan 23, 2025 · 3 comments
Open

MCP - Handling Complex Schemas + System Prompt #5429

lnvestor opened this issue Jan 23, 2025 · 3 comments

Comments

@lnvestor
Copy link

lnvestor commented Jan 23, 2025

Claude/Anthropic Model Unable to Handle Complex JSON Schema with anyOf/oneOf

Description

I've set up LibreChat with a custom MCP server containing 20 tools with complex schemas. While the tools are correctly displayed and accessible, I'm encountering issues when Claude (Anthropic's model) attempts to create connections using schemas that contain anyOf/oneOf conditions.https://github.com/danny-avila/LibreChat/issues/new/choose

Environment

  • LibreChat (Docker deployment)
  • Custom MCP server
  • Anthropic's latest model with Tools support

Configuration

docker-compose.override.yml

services:
  api:
    environment:
      - MONGO_URI=${MONGO_URI}
    volumes:
      - ./librechat.yaml:/app/librechat.yaml
      - /Users/drisstalainte/Documents/Cline/MCP:/app/mcp
  mongodb:
    image: arm64v8/mongo:latest
    command: ""
    entrypoint: ""

MCP server yaml config

myMCP:
  type: stdio
  command: "node"
  args:
    - "/app/mcp/MyMCP-server/build/index.js"
  env:
    NODE_ENV: production
    MyMCP_BEARER_TOKEN: "f596**********9dcf7f44c0"

Error

When attempting to create a connection, the following error occurs:

2025-01-24 00:05:26 LibreChat | 2025-01-23 23:05:26 error: create_connection MCP server tool call failed MCP error -32603: MCP error -32603: MCP error -32602: Missing required parameters: type, name

Investigation

The issue appears to be related to how complex JSON schemas with anyOf/oneOf conditions are handled. Looking at Cline's implementation (specifically this code), they handle this by:

  1. Using custom prompts
  2. Using JSON.stringify to send the input schema

Potential Solution

Implementing similar handling of complex schemas as Cline does might resolve this issue.

Additional Context


Would you like me to post the schema as a comment to maintain better readability of the main issue?

@lnvestor
Copy link
Author

export const httpConnectionSchema = { type: 'object', properties: { type: { type: 'string', const: 'http', description: 'Connection type', }, name: { type: 'string', description: 'Connection name', }, offline: { type: 'boolean', description: 'Whether the connection is offline', }, sandbox: { type: 'boolean', description: 'Whether to use sandbox environment', }, http: { type: 'object', properties: { formType: { type: 'string', enum: ['http', 'graph_ql'], description: 'Form type for HTTP connections', }, mediaType: { type: 'string', enum: ['json'], description: 'Media type', }, baseURI: { type: 'string', description: 'Base URI for the endpoint', }, unencrypted: { type: 'object', properties: { field: { type: 'string', description: 'Unencrypted field value', }, }, }, encrypted: { type: 'string', description: 'Encrypted data', }, auth: { type: 'object', properties: { type: { type: 'string', enum: ['basic', 'cookie', 'digest', 'token'], description: 'Authentication type', }, basic: { type: 'object', properties: { username: { type: 'string', description: 'Basic/Digest auth username', }, password: { type: 'string', description: 'Basic/Digest auth password', }, }, required: ['username', 'password'], }, cookie: { type: 'object', properties: { uri: { type: 'string', description: 'Cookie auth URI', }, method: { type: 'string', description: 'HTTP method for cookie auth', enum: ['GET', 'POST'], }, }, required: ['uri', 'method'], }, token: { type: 'object', properties: { token: { type: 'string', description: 'Authentication token', }, location: { type: 'string', enum: ['body', 'header', 'url'], description: 'Token location (body, header, or url)', }, headerName: { type: 'string', description: 'Header name when using header location', }, scheme: { type: 'string', enum: ['Bearer', 'custom', 'mac', 'None', ' '], description: 'Authentication scheme (Bearer, custom, mac, None, or space for no scheme)', }, paramName: { type: 'string', description: 'Parameter name for token', }, }, required: ['token', 'location', 'headerName', 'scheme', 'paramName'], allOf: [ { if: { properties: { location: { const: 'header' } } }, then: { properties: { scheme: { enum: ['Bearer', 'custom', 'mac', 'None'], }, }, } }, { if: { properties: { location: { const: 'body' } } }, then: { properties: { scheme: { const: ' ', }, }, } } ], }, }, required: ['type'], allOf: [ { if: { properties: { type: { const: 'basic' } } }, then: { required: ['basic'] } }, { if: { properties: { type: { const: 'cookie' } } }, then: { required: ['cookie'] } }, { if: { properties: { type: { const: 'digest' } } }, then: { required: ['basic'] } }, { if: { properties: { type: { const: 'token' } } }, then: { required: ['token'] } } ], }, ping: { type: 'object', properties: { relativeURI: { type: 'string', description: 'Relative URI for ping endpoint', }, method: { type: 'string', description: 'HTTP method for ping', }, }, }, }, required: ['formType', 'mediaType', 'baseURI', 'auth'], }, microServices: { type: 'object', properties: { disableNetSuiteWebServices: { type: 'boolean', default: false, }, disableRdbms: { type: 'boolean', default: false, }, disableDataWarehouse: { type: 'boolean', default: false, }, }, required: ['disableNetSuiteWebServices', 'disableRdbms', 'disableDataWarehouse'], }, queues: { type: 'array', items: { type: 'object', properties: { name: { type: 'string', description: 'Queue name', }, size: { type: 'number', description: 'Queue size', }, }, required: ['name', 'size'], }, }, }, required: ['type', 'name', 'http', 'microServices'], };

@dvejsada
Copy link

Is it possible this may be caused by using "type" as property name, when "type" is a reserved keyword in JSON Schema used to define the data type of a property?

@lnvestor
Copy link
Author

@dvejsada i have no idea i mean in cline it works fine but running same prompt in librechat it throwing this error

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

2 participants