Connecting to an LLM¶
This guide explains how to connect the MCP server to a large language model (LLM). Once connected, the LLM can discover and use EventSourcingDB operations through natural language prompts.
Transport Protocol¶
The MCP server uses Streamable HTTP as its transport protocol. Most MCP-compatible LLM clients support Streamable HTTP out of the box. The HTTP endpoint is available at the root path of the MCP server, so if the server is running on http://localhost:3000, the HTTP endpoint is http://localhost:3000/mcp.
Authentication¶
If you started the MCP server with the --api-token flag, clients must include a Bearer token in the Authorization header when connecting. The exact way to configure this depends on your LLM client, but the token value must match the one you passed to the MCP server.
If no --api-token was set, the MCP server accepts connections without authentication.
What the LLM Sees¶
When an LLM connects to the MCP server, it automatically receives a list of tools that correspond to EventSourcingDB operations. These tools cover reading and writing events, querying with EventQL, listing subjects and event types, registering schemas, and more. The LLM uses the tool descriptions to decide which operations to invoke based on your prompts.
For a complete list of available tools, see Available Tools.
Configuring Your LLM Client¶
The specific configuration steps depend on which LLM client you use. In general, you need to provide three pieces of information:
- The HTTP endpoint URL of the MCP server (e.g.
http://localhost:3000/mcp) - The transport type, which is Streamable HTTP
- The Bearer token, if authentication is enabled on the MCP server
Consult your LLM client's documentation for the exact configuration format. Most clients that support MCP allow you to specify these settings in a JSON configuration file or through their user interface.
Tips for Effective Use¶
Before you start prompting, it helps to register event schemas for your event types. When schemas are available, the LLM can understand the structure of your events and provide more accurate responses.
It is also a good idea to start with read operations before moving on to writes. Listing subjects, reading event types, and running simple EventQL queries lets you verify that the connection works and gives the LLM context about your data before you ask it to make changes.
For a detailed description of each tool the LLM can use, see Available Tools.