Skip to main content
Glama

MySQL Query MCP Server

by devakone
README.md1.71 kB
# MySQL MCP Server Test Fixes This document describes the issues that were fixed in the test suite of the MySQL MCP Server project. ## Issues Fixed 1. **Exported the `isReadOnlyQuery` function in query.ts**: - The function was being imported in the tests but wasn't exported from the source file - Fixed by adding the `export` keyword to the function declaration 2. **Fixed the Mocking Approach**: - Previous test implementation was using `vi.mocked()` which was causing type errors - The mocks were not properly set up for the connection and query methods - We simplified the mock implementation with pure JavaScript functions instead of relying on jest/vitest mocking APIs 3. **Simplified Test State Management**: - Added global variables to track mock state (e.g., `releaseCalled`, `queryCount`) - Used these variables to verify that the expected operations were performed - Made tests more readable and less brittle 4. **Fixed the `info.ts` Module**: - The module was creating its own pools instead of importing from db/pools.js - Updated to import the pools from the correct location, making it consistent with other modules ## Improved Test Patterns The tests now use a more reliable approach: 1. **Manual Mocking**: Instead of relying on mock functions with `mockResolvedValueOnce`, etc., we use pure JavaScript functions with conditional logic. 2. **Clear State Management**: Each test resets the mock state before running, preventing test interdependence. 3. **Fixed Environmental Setup**: Tests now properly set up the environment and clean up after themselves. ## Running Tests Tests can be run with: ```bash npm test ``` All tests now pass successfully.

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/devakone/mysql-query-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server