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

Feature Request: Graceful handling of character encoding errors in SQLite MCP server #124

Closed
7shi opened this issue Nov 29, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@7shi
Copy link

7shi commented Nov 29, 2024

Is your feature request related to a problem? Please describe.

When using Japanese text with SQLite database in the Claude Desktop Application, the MCP server crashes if character encoding is not properly configured. Specifically:

  • Attempting to INSERT Japanese text causes the MCP server to crash
  • Even for successful manual inserts ('apple', 'りんご') via direct SQLite operations, querying through the application shows corrupt characters:
    {'id': 1, 'word': 'apple', 'meaning_ja': '���'}
    

Describe the solution you'd like

The MCP server should handle character encoding errors gracefully without crashing. When encountering encoding issues, it should:

  1. Continue running instead of crashing
  2. Possibly return an error message indicating the encoding problem
  3. Allow users to fix the encoding settings without needing to restart the server

Describe alternatives you've considered

Currently, the issue can be worked around by setting the PYTHONIOENCODING environment variable in the MCP server configuration:

{
  "mcpServers": {
    "sqlite": {
      "command": "uvx",
      "args": [
        "mcp-server-sqlite",
        "--db-path",
        "C:\\Users\\USER\\test.db"
      ],
      "env": {
        "PYTHONIOENCODING": "utf-8" 
      }
    }
  }
}

(Solution referenced from modelcontextprotocol/servers#65)

Additional context

Environment:

  • Client Application: Claude Desktop Application
  • Operating System: Windows 11
  • Database: SQLite 3
  • Database Encoding: UTF-8
  • Content: Japanese text (UTF-8 encoded)

Technical Details:

SQLite itself is encoding-agnostic and treats data as byte strings. The character encoding interpretation happens at the interface level - in this case, Python's SQLite driver in the MCP server. Without proper encoding settings, Python may default to an incorrect encoding when reading from or writing to the database.

@7shi 7shi added the enhancement New feature or request label Nov 29, 2024
@naveenatmit
Copy link

I had the same issue as well when trying to have a db with tamil text, luckily found this issue to find a workaround to include encoding information in the config after several attempts. please consider fixing this.

@jspahrsummers
Copy link
Member

jspahrsummers commented Dec 3, 2024

Thanks for flagging! We'd be happy to review a pull request fixing this issue if anyone wants to give it a try. 🙏

@jerome3o-anthropic
Copy link
Contributor

Fixed in #378, thank you @interrobot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants