Skip to main content

Usage

The #[mcp] macro enables you to expose any HelixQL query as an MCP (Model Context Protocol) endpoint, making it directly accessible to AI agents and LLM applications.
You MUST only return a single object/value from the query otherwise you will get a compile error. (See E401)
Make sure to set mcp = true under the instance you are using in the helix.toml file.

How it works

When you add the #[mcp] attribute to a query:
  1. HelixDB automatically registers the query as an MCP tool
  2. The query parameters become the tool’s input schema
  3. The query’s return type becomes the tool’s output schema
  4. AI agents can call this tool directly through the MCP server
The MCP macro automatically converts your HelixQL query into a callable MCP tool that can be used by LLM providers like OpenAI, Anthropic, and Gemini.

Using MCP Queries with LLM Providers

Once you’ve defined your MCP queries, you can use them with any LLM provider that supports MCP:

Best Practices

Choose query names that clearly describe what the tool does. AI agents rely on function names to understand capabilities.
Use clear parameter types and avoid overly complex signatures. AI agents work best with straightforward interfaces.

MCP Server Setup

Learn how to set up and configure the HelixDB MCP server

MCP Guide

Complete guide for using MCP with HelixDB

Query Basics

Learn the fundamentals of writing HelixQL queries

LLM Providers

Using HelixDB with different LLM providers