# Agents and APIs

Your own code reaches Acquestor's tools two ways: call the [REST API](/reference/rest) directly, or hand the MCP server to a model provider's API and let the model call the tools. Both take a founding broker's API key as a bearer token.

The request shapes below follow each provider's documentation as of October 6, 2026. None has been tested against Acquestor's deployed server yet.

## Claude Code

```sh
claude mcp add --transport http acquestor https://mcp.acquestor.com/mcp
```

Claude Code opens a browser for you to sign in. To use an API key instead:

```sh
claude mcp add --transport http acquestor https://mcp.acquestor.com/mcp \
  --header "Authorization: Bearer $ACQUESTOR_API_KEY"
```

Add `--scope project` to share the server with a repository through its `.mcp.json`; keep the key in an environment variable, not in the file.

## Claude API (Messages API)

The MCP connector is in beta on the Claude API. Pass the server in `mcp_servers` and enable its tools with an `mcp_toolset` entry.

```sh
curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "anthropic-beta: mcp-client-2025-11-20" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-opus-5-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "What price can an SBA buyer finance for a business with $400K of SDE, no capex reserve, at the national median manager salary?"}],
    "mcp_servers": [{
      "type": "url",
      "url": "https://mcp.acquestor.com/mcp",
      "name": "acquestor",
      "authorization_token": "'"$ACQUESTOR_API_KEY"'"
    }],
    "tools": [{
      "type": "mcp_toolset",
      "mcp_server_name": "acquestor",
      "default_config": {"enabled": false},
      "configs": {"sba_price_ceiling": {"enabled": true}, "get_rates": {"enabled": true}, "get_market_salary": {"enabled": true}}
    }]
  }'
```

Enabling only the tools you need keeps the model's tool list short and your spend predictable.

## OpenAI Responses API

```sh
curl https://api.openai.com/v1/responses \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "'"$OPENAI_MODEL"'",
    "input": "Which lenders made SBA acquisition loans to HVAC businesses in Texas?",
    "tools": [{
      "type": "mcp",
      "server_label": "acquestor",
      "server_url": "https://mcp.acquestor.com/mcp",
      "headers": {"Authorization": "Bearer '"$ACQUESTOR_API_KEY"'"},
      "allowed_tools": ["find_sba_lenders"],
      "require_approval": "always"
    }]
  }'
```

Set `OPENAI_MODEL` to a model that supports remote MCP tools. `require_approval` defaults to asking before data is shared with the server; `"never"` or `{"never": {"read_only": true}}` relaxes it.

## xAI API

```sh
curl https://api.x.ai/v1/responses \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-4.7",
    "input": "Stress-test a $1.2M deal: SDE $350K, manager salary $90K, capex reserve $15K, a $1.08M loan at 10% over 10 years.",
    "tools": [{
      "type": "mcp",
      "server_label": "acquestor",
      "server_url": "https://mcp.acquestor.com/mcp",
      "headers": {"Authorization": "Bearer '"$ACQUESTOR_API_KEY"'"},
      "allowed_tools": ["stress_test_deal"]
    }]
  }'
```

## Your own MCP client

Any client that speaks Streamable HTTP works. With the TypeScript SDK:

```ts
import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";

const transport = new StreamableHTTPClientTransport(new URL("https://mcp.acquestor.com/mcp"), {
  requestInit: { headers: { Authorization: `Bearer ${process.env.ACQUESTOR_API_KEY}` } },
});
const client = new Client({ name: "my-agent", version: "1.0.0" });
await client.connect(transport);

const { tools } = await client.listTools();
const result = await client.callTool({
  name: "sba_price_ceiling",
  arguments: { sde: 156000, manager_salary: 80000, capex_reserve: 0 },
});
console.log(result.content[0].text);       // the card as text, with source lines
console.log(result.structuredContent);     // the full response envelope
```

The server answers clients on the 2026-07-28 protocol and clients that open with `initialize` on the 2025 versions.

## Keep the sources

Every result carries its source lines in the text and its `sources` in `structuredContent`. If your agent rewrites results for people, keep each number's source and date with it, and pass on gaps instead of filling them.
