Skip to content

MCP Protocol Validation Error During Initialization #1

@ahmed98Osama

Description

@ahmed98Osama

Summary

The Java MCP SQL Server successfully connects to the database and all tools are functional, but Cursor IDE shows a protocol validation error during initialization with a red error indicator. The error occurs during the MCP handshake but the server recovers and continues to work normally.

Environment

  • OS: Windows 10 (Build 19045)
  • Java Version: openjdk version "21.0.4" 2024-07-16 LTS
  • MCP Server Version: 1.0.0
  • JAR Location: C:\java-mcp-sql-server-1.0.0.jar
  • Database: Oracle
  • Cursor IDE: 2.2.43

Configuration

{
  "java-mcp-sql-server": {
    "command": "java",
    "args": ["-jar", "C:\\java-mcp-sql-server-1.0.0.jar"],
    "env": {
      "JMCP_JDBC_URL": "jdbc:oracle:thin:@//your-server:1521/your-database",
      "JMCP_DB_USERNAME": "YOUR_USERNAME",
      "JMCP_DB_PASSWORD": "YOUR_PASSWORD",
      "JMCP_MODE": "stdio",
      "JMCP_QUERY_SELECT_ONLY": "false"
    }
  }
}

Error Details

Server Startup (Successful)

23:47:21.222 [main] INFO  com.dgdev91.mcpsql.SqlMcpServer - Starting SQL MCP Server...
23:47:21.481 [main] INFO  com.dgdev91.mcpsql.service.DatabaseService - Oracle driver loaded successfully
23:47:23.111 [main] INFO  com.dgdev91.mcpsql.service.DatabaseService - Successfully connected to database: ORACLE
23:47:23.242 [main] INFO  com.dgdev91.mcpsql.SqlMcpServer - Database connection successful. Type: ORACLE, Query SELECT only: false

Protocol Validation Error

Cursor IDE reports a Zod validation error during initialization:

{
  "code": "invalid_union",
  "unionErrors": [
    {
      "issues": [
        {
          "code": "invalid_union",
          "unionErrors": [
            {
              "issues": [
                {
                  "code": "invalid_type",
                  "expected": "string",
                  "received": "null",
                  "path": ["id"],
                  "message": "Expected string, received null"
                }
              ],
              "name": "ZodError"
            },
            {
              "issues": [
                {
                  "code": "invalid_type",
                  "expected": "number",
                  "received": "null",
                  "path": ["id"],
                  "message": "Expected number, received null"
                }
              ],
              "name": "ZodError"
            }
          ],
          "path": ["id"],
          "message": "Invalid input"
        },
        {
          "code": "invalid_type",
          "expected": "string",
          "received": "undefined",
          "path": ["method"],
          "message": "Required"
        },
        {
          "code": "unrecognized_keys",
          "keys": ["error"],
          "path": [],
          "message": "Unrecognized key(s) in object: 'error'"
        }
      ],
      "name": "ZodError"
    }
  ],
  "path": [],
  "message": "Invalid input"
}

Recovery (Successful)

After the error, the server recovers:

23:47:24.394 [info] Handling ListOfferings action, server stored: true
23:47:24.402 [info] listOfferings: Found 5 tools
23:47:24.402 [info] Found 5 tools, 0 prompts, and 0 resources

Expected Behavior

The MCP server should initialize without protocol validation errors. All messages sent during initialization should conform to the MCP protocol specification.

Actual Behavior

  • Server starts successfully ✅
  • Database connection established ✅
  • Tools are available and functional ✅
  • Protocol validation error during initialization ❌
  • Red error indicator in Cursor IDE ❌

Impact

  • Severity: Low (cosmetic issue)
  • Functionality: All tools work correctly after initialization
  • User Experience: Red error indicator is misleading and concerning

Steps to Reproduce

  1. Configure mcp.json with java-mcp-sql-server
  2. Restart Cursor IDE
  3. Check MCP server logs in Cursor
  4. Observe protocol validation error during initialization
  5. Verify tools are still functional (they are)

Additional Notes

  • The error appears to be related to a message sent during initialization that contains an "error" key with a null id
  • The server appears to send a non-standard message format that doesn't match MCP protocol expectations
  • This might be related to error handling or logging during the initialization phase
  • All 5 tools (list_schemas, list_tables, get_table_structure, query_table, execute_query) work correctly after initialization

Note: This issue was identified while using the server with Oracle database, but it may affect other database types as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions