Connect your data agent

Connect a data agent your team built, such as a Slack bot that many people talk to, to Vuon. Vuon checks, caps, and records every query it runs, along with the person who asked.

Slack sends questions to your bot. Your bot sends the key, session ID, and end user to two servers in your Vuon workspace: the Vuon server finds tables and metrics, draws charts, and transforms results; the BigQuery server checks, caps, and records each query before running it on your BigQuery project.

Connection diagram: Slack → your bot → the Vuon and BigQuery MCP servers → your BigQuery project.

Your bot uses one key for two MCP servers on your workspace. The Vuon server finds tables and metrics and draws charts. The BigQuery server runs every query. On each request, your code says which conversation it belongs to and who asked.

Before you start


Step 1: Create a key

  1. Go to Settings → Databases, open your BigQuery database, and find Outside agents.
  2. Click New client, name it after your bot, and leave the enforcement mode on Observe.
  3. Click Create and add a key, and copy the key. It is shown once.

Create one client per bot, not one per person. The key acts as the client's bot user, not as you, so it keeps working if you leave the workspace. See API keys for what it can reach.

Give your bot the key and your workspace URL as environment variables. Keep the key in your secret manager, never in code or a prompt.

.env

VUON_API_KEY=sk_live_...
VUON_URL=https://<workspace>.vuon.ai

Step 2: Connect your bot

For each conversation, open a client to both servers, run the conversation, and close the client. Send these headers on every request:

HeaderValue
AuthorizationBearer and your key.
X-Vuon-Session-IdThe conversation, such as the Slack thread's timestamp. Keeps its queries together, so a later step can build on an earlier result.
X-Vuon-End-UserWho asked, such as slack:U0123ABC. Query checks shows it on every query.

Set the headers in your code, never through the model. A model can't know who is asking.

Choose the example for your agent. LangChain's createAgent runs on LangGraph; the Claude Agent SDK manages its own agent loop. The LangGraph and Claude Agent SDK examples use your Anthropic credentials (ANTHROPIC_API_KEY), separately from the Vuon key. Install the packages for the example you use:

  • LangGraph / LangChain: npm install langchain @langchain/core @langchain/langgraph @langchain/anthropic @langchain/mcp-adapters@2.0.2
  • Claude Agent SDK: npm install @anthropic-ai/claude-agent-sdk@0.3.322

Connect for one conversation

// vuon.ts
import { createMCPClient } from '@ai-sdk/mcp';
import { generateText, isStepCount } from 'ai';

type VuonClient = Awaited<ReturnType<typeof createMCPClient>>;

export async function connectVuon(endUser: string, sessionId: string) {
  const headers = {
    Authorization: `Bearer ${process.env.VUON_API_KEY}`,
    'X-Vuon-Session-Id': sessionId,
    'X-Vuon-End-User': endUser,
  };
  const base = `${process.env.VUON_URL}/api/mcp`;
  const clients: VuonClient[] = [];
  const close = () => Promise.all(clients.map((client) => client.close()));
  try {
    for (const url of [base, `${base}/bigquery`]) {
      clients.push(
        await createMCPClient({ transport: { type: 'http', url, headers } }),
      );
    }
    const toolSets = await Promise.all(clients.map((client) => client.tools()));
    return { tools: Object.assign({}, ...toolSets), close };
  } catch (error) {
    await close();
    throw error;
  }
}

export async function answer(
  slackUserId: string,
  threadTs: string,
  question: string,
) {
  const vuon = await connectVuon(`slack:${slackUserId}`, threadTs);
  try {
    const { text } = await generateText({
      model, // your model
      tools: vuon.tools,
      stopWhen: isStepCount(10),
      prompt: question,
    });
    return text;
  } finally {
    await vuon.close();
  }
}

Every BigQuery tool also takes a projectId: the BigQuery project of your connection. If the model passes another one, the error names the right one.

Already have a custom LangGraph graph? Use the same adapter to discover tools, then give them to both your model's bindTools and your graph's tool-execution node; see the LangGraph quickstart. Keep the adapter open until the graph finishes, including tool execution and streaming.

The Claude Agent SDK example auto-approves only the two Vuon servers' MCP tools, disables built-in tools, and excludes other configured MCP servers. allowedTools alone is not a tool allowlist. Narrow the tools further on the Vuon client's page in Step 4. These headers stay fixed during a run; do not reuse a run for another person. For verified end users and runs longer than five minutes, see Identify who asked.

The LangGraph connection follows the LangChain MCP guide and header authentication reference, for @langchain/mcp-adapters 2.0.2 (MCPAdapter and listTools). On 1.x, see the migration guide. The Claude Agent SDK connection follows Anthropic's MCP guide and TypeScript reference.

The LangGraph and Claude Agent SDK examples were checked against the published API definitions for @langchain/mcp-adapters 2.0.2 and @anthropic-ai/claude-agent-sdk 0.3.322, not a live agent run. The AI SDK, Pi, OpenCode, and MCP SDK examples were checked against ai 7 with @ai-sdk/mcp 2.0.92, @earendil-works/pi-coding-agent 1.5.0, OpenCode 1.19, @modelcontextprotocol/client 2.4.0, and mcp 2.3.0. For older versions, the Pi and OpenCode CLIs, and streaming, see Recipes.

Step 3: Check that it works

Ask your bot something small, such as "How many rows are in our largest table?" Then check two things.

The key works. Call whoami on the Vuon server. It returns:

whoami

{
  "orgId": "org_...",
  "userId": "user_vuonbot_...",
  "authType": "apiKey",
  "scopes": ["mcp:read", "mcp:query", "mcp:metrics:read"],
  "unrestricted": false,
  "connections": [
    { "id": "…", "name": "Warehouse", "type": "bigquery", "isDefault": true }
  ],
  "unavailableTools": [
    { "name": "create_metric", "reason": "missing_scope", "scope": "mcp:metrics:write" }
  ]
}

The userId is the client's bot user: not you, and not the Slack user. connections are the database connections your bot can search, and unavailableTools lists the tools it can't use, each with the reason (details).

The query was recorded. Go to Settings → Query checks and filter by your client. Your query is there, with its end user, such as slack:U0123ABC. A dash instead of an end user means the header didn't reach Vuon.

If something fails, see Troubleshooting.

Step 4: Lock it down

Once your bot works, narrow what it can do. All of this is on the client's page.

  • Switch off tools your bot doesn't need. Under Tools, a tool that is off is hidden from your bot and refused if called. For a Slack bot, consider:

    • Charts, if your bot can't show a chart or a link to one.
    • Transform results, if your bot should answer only from queries Vuon checks. Transforms aren't recorded on Query checks.
    • execute_sql under Run queries. It does the same as execute_sql_readonly, so the model doesn't need both.

    See Tools for every tool.

  • Enforce the checks. After a few days in Observe, read what Query checks recorded, then move the client to Standard or Strict. See Enforcement modes.

  • Verify who asked. Your bot can put any name in X-Vuon-End-User, so Query checks shows it as unverified. To have it verified, sign a short-lived token; see Identify who asked.

  • Use one key per environment. To rotate a key, create a new one on the client's page, deploy it, then revoke the old one.


Next steps

Was this page helpful?