run_read_query
Execute a SELECT query on a SingleStore database to retrieve data. This tool performs read-only operations, ensuring secure and efficient data access.
Instructions
Execute a read-only (SELECT) query on the database
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | SQL SELECT query to execute |
Input Schema (JSON Schema)
{
"properties": {
"query": {
"description": "SQL SELECT query to execute",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
}
Implementation Reference
- src/index.ts:1619-1652 (handler)The handler for 'run_read_query' tool. Validates input, ensures query is SELECT-only, executes on database, returns results as JSON text.case 'run_read_query': { if (!request.params.arguments || typeof request.params.arguments.query !== 'string') { throw new McpError( ErrorCode.InvalidParams, 'Query parameter must be a string' ); } const query = request.params.arguments.query.trim().toLowerCase(); if (!query.startsWith('select ')) { throw new McpError( ErrorCode.InvalidParams, 'Only SELECT queries are allowed for this tool' ); } try { const [rows] = await conn.query(request.params.arguments.query) as [mysql.RowDataPacket[], mysql.FieldPacket[]]; return { content: [ { type: 'text', text: JSON.stringify(rows, null, 2), }, ], }; } catch (error: unknown) { const err = error as Error; throw new McpError( ErrorCode.InternalError, `Query error: ${err.message}` ); } }
- src/index.ts:1224-1236 (schema)Input schema definition for run_read_query tool in MCP ListToolsRequestSchema response.name: 'run_read_query', description: 'Execute a read-only (SELECT) query on the database', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'SQL SELECT query to execute', }, }, required: ['query'], }, },
- src/index.ts:1224-1236 (registration)The run_read_query tool is registered here in the tools list returned by ListToolsRequestSchema handler.name: 'run_read_query', description: 'Execute a read-only (SELECT) query on the database', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'SQL SELECT query to execute', }, }, required: ['query'], }, },
- src/index.ts:184-196 (schema)Duplicate schema definition for SSE/HTTP API tool listing.name: 'run_read_query', description: 'Execute a read-only (SELECT) query on the database', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'SQL SELECT query to execute', }, }, required: ['query'], }, },