Labsco
MCP SERVER

qmcp Server

by gabiteodoru

Query a q/kdb+ server from an assistant, with the ability to interrupt a runaway query the way you would press Ctrl+C.

Relational SQL Databases
Summary
Query interruption is the reason this exists, and Windows outside WSL loses it.

An assistant writing q will eventually produce an infinite loop, and without SIGINT there is no way out except killing the session. That capability depends on the server being able to reach the q process, which is why the author pushes Windows users into WSL for both. The Qython translation tools are open-source proof of concept covering about 5% of the language — treat their output as a draft, not a result.

What it is

A q/kdb+ bridge built for development and debugging rather than production access. One persistent connection, sequential execution, and a timeout model that switches long queries to async so the conversation stays responsive. It can also send SIGINT to the q process to cancel a query the model should not have run.

What you get
  • `connect_to_q` with flexible fallback — a full connection string, a port number, a hostname, or nothing at all, filled in from `Q_DEFAULT_HOST`
  • `query_q` executes with the async switch: fast queries return immediately, slow ones move to async and can be auto-interrupted
  • `get_current_task_status` and `get_current_task_result` follow an async query; `interrupt_current_query` sends SIGINT to cancel one
  • `set_timeout_switch_to_async`, `set_timeout_interrupt_q`, `set_timeout_connection` and `get_timeout_settings` tune all of that at runtime
  • Two experimental alpha tools: `translate_qython_to_q` converts Python-like syntax to q, and `translate_q_to_qython` goes the other way using q's own parser — verify their output before use
Requirements

Python 3.8+, a running q/kdb+ server, and either uv or pip. The lightest path is `claude mcp add qmcp "uv run qmcp/server.py"`; a full install is `pip install qmcp` then `claude mcp add qmcp qmcp`. `Q_DEFAULT_HOST` accepts host, host:port, or host:port:user:passwd. On Windows, run both the server and the q session inside WSL — outside it, SIGINT-based interruption is disabled, and it is also disabled when the server and q session sit on opposite sides of the WSL/Windows divide.

Setup effort

One command — qmcp