mysql_mcp_server icon indicating copy to clipboard operation
mysql_mcp_server copied to clipboard

Can this server support chunked select (aka cursor)?

Open zhrt123 opened this issue 10 months ago • 3 comments

I need to deal with an extensive database, but the memory is insufficient. So I wonder if the server could support pagination. Looking forward to your response.

zhrt123 avatar Mar 28 '25 07:03 zhrt123

There may be a pull request that addresses that feature.

https://github.com/designcomputer/mysql_mcp_server/pull/7

designcomputer avatar Mar 28 '25 12:03 designcomputer

Thank you for your response. After reviewing the code, I noticed that cursor queries are exclusively handled with fetchall() instead of fetch(). Would it be possible to add support for fetch() in this server?

zhrt123 avatar Mar 30 '25 06:03 zhrt123

@zhrt123

We're actively working on adding pagination support to mysql_mcp_server. This enhancement will allow much more efficient handling of large result sets. The implementation involves several key components:

Adding a cursor management system to maintain state between queries Creating new tools specifically for paginated queries Implementing proper resource cleanup to prevent memory leaks Enhancing documentation so AI agents can understand pagination concepts

Rather than fetching all results at once with fetchall(), we'll use fetchmany() to retrieve data in configurable batches. This will significantly reduce memory usage for large datasets. We need to thoroughly test this feature before release to ensure:

Cursor state is properly maintained across multiple requests Resources are correctly cleaned up when queries complete or errors occur The pagination workflow is intuitive for both human and AI users Performance is optimized for various batch sizes and dataset volumes

I'll keep you updated on our progress. We're aiming to have this feature tested and ready for deployment soon!

designcomputer avatar Mar 30 '25 10:03 designcomputer