Connect an AI agent (MCP)

Give AI agents access to your Labric data through the Model Context Protocol.
View as Markdown

Labric hosts a Model Context Protocol server that exposes the Labric API as tools any MCP-compatible agent can call — Claude, Cursor, or your own agent framework.

Endpoint

The server speaks streamable HTTP:

https://mcp.labric.co/mcp

Authentication

Authenticate with a Labric API key, exactly as you would against the REST API:

Authorization: Bearer lbk_your_api_key

The MCP server holds no data of its own — every tool call forwards your key to the Labric API, which enforces scopes and row-level security. A read-scoped key can only call read tools.

Connecting

Claude Code

claude mcp add --transport http labric https://mcp.labric.co/mcp \
--header "Authorization: Bearer lbk_your_api_key"

Python (Anthropic SDK)

The simplest way to give a Python agent access to Labric is the Anthropic API’s MCP connector — declare the server in the request and Claude discovers and calls the tools itself, with no client-side MCP plumbing:

import anthropic
client = anthropic.Anthropic()
response = client.beta.messages.create(
model="claude-sonnet-5",
max_tokens=4096,
betas=["mcp-client-2025-11-20"],
mcp_servers=[
{
"type": "url",
"name": "labric",
"url": "https://mcp.labric.co/mcp",
"authorization_token": "lbk_your_api_key",
}
],
tools=[{"type": "mcp_toolset", "mcp_server_name": "labric"}],
messages=[
{"role": "user", "content": "Tell me something interesting about my data."}
],
)
print(response.content[-1].text)

On long multi-tool tasks the API pauses the tool loop periodically (response.stop_reason == "pause_turn"); resume by appending the response content as an assistant message and calling again.

Python (any MCP client)

To call tools directly from a script — your own agent framework, or no LLM at all — use any MCP client library over streamable HTTP, for example FastMCP:

import asyncio
from fastmcp import Client
from fastmcp.client.transports import StreamableHttpTransport
transport = StreamableHttpTransport(
"https://mcp.labric.co/mcp",
headers={"Authorization": "Bearer lbk_your_api_key"},
)
async def main():
async with Client(transport) as labric:
print([tool.name for tool in await labric.list_tools()])
result = await labric.call_tool(
"execute_sql", {"query": "SELECT * FROM samples LIMIT 5"}
)
print(result)
asyncio.run(main())

If your agent framework only speaks stdio, FastMCP can also proxy the remote server: build the same transport, then create_proxy(transport, name="labric").run(transport="stdio").

Other MCP clients

Any client that supports streamable HTTP transport with custom headers works. A typical JSON configuration:

{
"mcpServers": {
"labric": {
"url": "https://mcp.labric.co/mcp",
"headers": {
"Authorization": "Bearer lbk_your_api_key"
}
}
}
}

Available tools

The tools mirror the API Reference one-to-one — each is generated from the same API schema, with the same name and description. Browse the reference for the full list; any agent can also discover them at runtime by listing the server’s tools.