LabKey’s MCP (Model Context Protocol) Server provides a standardized way for AI agents and external tools to securely interact with LabKey Server. The MCP Server defines how systems expose data, metadata, and actions in a structured, machine-readable form, making it possible for intelligent clients to discover datasets, run queries, and author reports.
MCP Server Set Up
Set up an MCP-driven development environment for working with LabKey Server.
Enable the MCP Server
- Go to Gear > Site > Admin Console.
- Click Experimental Features.
- Place a checkmark next to Enable MCP Server. (You do not need to press a confirmation button--simply adding the checkmark is sufficient to enable the server.)
Configure Your Desktop App or IDE
Note that browser agents can't typically connect to MCP servers. Users need a desktop client application such as Claude Code CLI, Gemini CLI, OpenAI Codex, or an IDE such as IntelliJ and VS Code with appropriate extensions added, to interact with LabKey’s MCP. Some vendors restrict the use of MCPs via their desktop apps. For example, some require "developer mode" to configure MCPs and limit certain subscription levels to read-only interactions.
To configure your application to connect to the MCP server: create a file named
.mcp.json in your project directory with the following contents:
{
"mcpServers": {
"labkey": {
"type": "http",
"url": "https://MY_SERVER/mcp",
"headers": {
"apikey": "MY_API_KEY"
}
}
}
}
- Replace MY_SERVER with your server URL.
- Replace MY_API_KEY with your LabKey API key.
Note that the MCP Server does not restrict users with write access from modifying or deleting data on the server. For example, it may suggest client API calls that change data on the server. Consider providing API keys with read-only access to users who do not require write access. (To do this, generate the API key from an account with Reader access only.)