# Frameworks

URL: https://briq.cloud/docs/setup/frameworks

> Connect an agent you build with an SDK to briq's MCP server, with an API key.

An agent you build with an SDK connects like any MCP client, with an API key instead of a
browser sign-in:

1. Create a key on the dashboard's **Agents** page, with the budget the agent may spend.
2. Keep it in `BRIQ_API_KEY`.
3. Point your framework at `https://api.briq.cloud/mcp` (Streamable HTTP), with the key as an
   `Authorization: Bearer` header.

Each snippet below does step 3; replace `<your model>` with yours.

Using a coding agent or a chat app instead? See [Clients](https://briq.cloud/docs/setup/clients).

## Claude Agent SDK

`npm i @anthropic-ai/claude-agent-sdk` (or `pip install claude-agent-sdk`)

```ts
import { query } from '@anthropic-ai/claude-agent-sdk';

for await (const m of query({
  prompt: 'Start a Postgres on briq',
  options: {
    mcpServers: {
      briq: {
        type: 'http',
        url: 'https://api.briq.cloud/mcp',
        headers: { Authorization: `Bearer ${process.env.BRIQ_API_KEY}` },
      },
    },
    allowedTools: ['mcp__briq__*'],
  },
})) if (m.type === 'result' && m.subtype === 'success') console.log(m.result);
```

`allowedTools` is what lets the agent call briq's tools without asking. A server that fails to
authenticate does not throw: it shows as `failed` or `needs-auth` in the init message.

## OpenAI Agents SDK

`pip install openai-agents` (or `npm i @openai/agents`)

```python
import os
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

async with MCPServerStreamableHttp(
    name="briq",
    params={
        "url": "https://api.briq.cloud/mcp",
        "headers": {"Authorization": f"Bearer {os.environ['BRIQ_API_KEY']}"},
    },
    cache_tools_list=True,
) as briq:
    agent = Agent(name="Ops", instructions="Use briq for services.", mcp_servers=[briq])
    print((await Runner.run(agent, "Start a Postgres on briq")).final_output)
```

In JavaScript, `new MCPServerStreamableHttp({ name: 'briq', url, requestInit: { headers } })`,
then `await briq.connect()` before running the agent.

## Vercel AI SDK

`npm i ai @ai-sdk/mcp`

```ts
import { createMCPClient } from '@ai-sdk/mcp';
import { ToolLoopAgent } from 'ai';

const briq = await createMCPClient({
  transport: {
    type: 'http',
    url: 'https://api.briq.cloud/mcp',
    headers: { Authorization: `Bearer ${process.env.BRIQ_API_KEY}` },
  },
});
try {
  const agent = new ToolLoopAgent({ model: '<your model>', tools: await briq.tools() });
  console.log((await agent.generate({ prompt: 'Start a Postgres on briq' })).text);
} finally {
  await briq.close();
}
```

## LangChain and LangGraph

`pip install "langchain[mcp]"` (or `npm i langchain @langchain/mcp-adapters`)

```python
import os
from fastmcp.client import Client
from langchain.agents import create_agent
from langchain.mcp import MCPAdapter

async with MCPAdapter(Client("https://api.briq.cloud/mcp", auth=os.environ["BRIQ_API_KEY"])) as briq:
    agent = create_agent("<your model>", await briq.list_tools())
    await agent.ainvoke({"messages": [{"role": "user", "content": "Start a Postgres on briq"}]})
```

`auth=` sends the key as a Bearer token. In JavaScript:
`new MCPAdapter({ servers: { briq: { url, headers } } })`, then `await adapter.listTools()`. The
older `MultiServerMCPClient` from `langchain-mcp-adapters` still works with
`"transport": "http"` and `"headers"`.

## Mastra

`npm i @mastra/mcp @mastra/core`

```ts
import { Agent } from '@mastra/core/agent';
import { MCPClient } from '@mastra/mcp';

const mcp = new MCPClient({
  servers: {
    briq: {
      url: new URL('https://api.briq.cloud/mcp'),
      requestInit: { headers: { Authorization: `Bearer ${process.env.BRIQ_API_KEY}` } },
    },
  },
});

export const agent = new Agent({
  id: 'ops',
  name: 'Ops',
  instructions: 'Use briq for services.',
  model: '<your model>',
  tools: await mcp.listTools(),
});
```

## Pydantic AI

`pip install "pydantic-ai-slim[mcp]"`

```python
import os
from pydantic_ai import Agent
from pydantic_ai.mcp import MCPToolset

briq = MCPToolset(
    "https://api.briq.cloud/mcp",
    headers={"Authorization": f"Bearer {os.environ['BRIQ_API_KEY']}"},
)
agent = Agent("<your model>", toolsets=[briq])

async def main():
    async with agent:
        print((await agent.run("Start a Postgres on briq")).output)
```

## Google ADK

`pip install google-adk`

```python
import os
from google.adk.agents import LlmAgent
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams

root_agent = LlmAgent(
    model="<your model>",
    name="ops",
    instruction="Use briq for services.",
    tools=[McpToolset(connection_params=StreamableHTTPConnectionParams(
        url="https://api.briq.cloud/mcp",
        headers={"Authorization": f"Bearer {os.environ['BRIQ_API_KEY']}"},
    ))],
)
```

## CrewAI

`pip install crewai mcp`

```python
import os
from crewai import Agent
from crewai.mcp import MCPServerHTTP

agent = Agent(
    role="Ops",
    goal="Run the services the crew needs",
    backstory="Runs databases and apps on briq.",
    mcps=[MCPServerHTTP(
        url="https://api.briq.cloud/mcp",
        headers={"Authorization": f"Bearer {os.environ['BRIQ_API_KEY']}"},
        streamable=True,
    )],
)
```

## Anything else

Any MCP client library works the same way: Streamable HTTP to the URL above, with the key in an
`Authorization: Bearer` header. Without MCP, every tool is also a [REST](https://briq.cloud/docs/api/overview) call.
