HomeDocsConnecting to AF MCP

Coding Agents Setup

Connect Claude Code, Cursor, and Codex to Agentic Fabriq via the local MCP broker.

Claude CodeCursorCodexMCP

Overview

Coding agents (Claude Code, Cursor, Codex) can access your Agentic Fabriq tool connections through a local MCP broker.

The broker runs as a child process spawned by the coding agent, proxying MCP requests to the Agentic Fabriq gateway.

No server to run — the broker starts automatically when the agent reads your MCP config.


Prerequisites

  • Agentic Fabriq account (sign up at dashboard.agenticfabriq.com)
  • Python 3.11+ installed
  • SDK installed:
    pip install agentic-fabriq-sdk
  • Authenticated:
    afctl auth login
    
    # For team workspaces:
    afctl auth login --org your-domain.com
  • At least one tool connected (e.g., Gmail, Slack) via the dashboard or CLI
  • Admin must enable the coding agent in the Admin Console > Coding Agents

Setup by Agent

Claude Code

Config file: ~/.claude/mcp.json

{
  "mcpServers": {
    "agentic-fabriq": {
      "command": "afctl",
      "args": ["broker"]
    }
  }
}

Restart Claude Code after saving the config file.

Claude Code sources your shell profile, so bare afctl works without a full path.

Cursor

Config file: ~/.cursor/mcp.json

For local Cursor, the same config as Claude Code works:

{
  "mcpServers": {
    "agentic-fabriq": {
      "command": "afctl",
      "args": ["broker"]
    }
  }
}

For Cursor Remote SSH (running in a VM or remote server), use the full path:

{
  "mcpServers": {
    "agentic-fabriq": {
      "command": "/home/ubuntu/.af-venv/bin/afctl",
      "args": ["broker"]
    }
  }
}

Note: Replace the path with wherever afctl is installed on the remote machine. Cursor Remote SSH doesn't source .bashrc, so the full path is required.

Codex

Same config format as Claude Code. Place it in the MCP config location that Codex reads.

{
  "mcpServers": {
    "agentic-fabriq": {
      "command": "afctl",
      "args": ["broker"]
    }
  }
}

How It Works

  1. Agent spawns afctl broker as a child process
  2. Broker detects which agent spawned it (by checking parent process name/cmdline)
  3. Broker authenticates with the gateway using your stored afctl auth login token
  4. A session is created on the gateway, tracked by your admin
  5. Broker proxies MCP tool calls (list_tools, call_tool) over WebSocket to the gateway
  6. Session heartbeats every 60 seconds; auto-expires ~3 minutes after broker exits
  7. If the token expires, the broker transparently re-establishes the session

Device Auth for Remote Machines

If running on a headless/remote machine (VM, server, CI), use the device code flow:

afctl auth login --remote

This prints a URL and a code. Open the URL in any browser, enter the code, and authorize.

The CLI polls until authorization completes — no browser needed on the remote machine.


Team Workspace Login

For organization accounts with dedicated realms:

afctl auth login --org your-domain.com

This routes authentication to your organization's dedicated Keycloak realm.


Verifying the Setup

# Check authentication status
afctl auth status

# Check who you're logged in as
afctl auth whoami

# View current token (for debugging)
afctl auth token

Troubleshooting

ErrorCause / Fix
No auth token foundRun afctl auth login
Token rejectedToken expired. Run afctl auth login again.
Agent not detectedBroker couldn't identify the parent process. This is usually fine — it falls back to a generic agent name. If needed, use afctl broker --agent claude-code to override.
Connection refusedGateway unreachable. Check your internet connection and that dashboard.agenticfabriq.com is accessible.
Tool not foundEnsure you've connected the tool in the dashboard and your admin has granted scopes to the coding agent app.

Need help?

Our team is here to help you get started.