API & MCP

MCP Reference

Complete reference for the AffinityBots MCP Server tools and their parameters.

February 6, 2024
10 min read

This document provides a complete reference for all tools available through the AffinityBots MCP Server.

Authentication

All requests require a valid API key passed as a Bearer token:

Authorization: Bearer ab_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Create API keys in SettingsAPI Keys.


Agent Tools

affinitybots_list_agents

List all AI agents accessible to you.

Parameters:

NameTypeRequiredDefaultDescription
limitnumberNo20Maximum agents to return (max: 100)
offsetnumberNo0Number of agents to skip for pagination

Response:

{
  "agents": [
    {
      "id": "uuid",
      "name": "Sales Assistant",
      "description": "Handles lead qualification",
      "model": "openai:gpt-4o",
      "created_at": "2024-01-15T10:00:00Z",
      "updated_at": "2024-02-01T15:30:00Z"
    }
  ],
  "total": 1,
  "limit": 20,
  "offset": 0
}

affinitybots_get_agent

Get detailed information about a specific agent.

Parameters:

NameTypeRequiredDescription
agent_idstringYesThe unique ID of the agent

Response:

{
  "id": "uuid",
  "name": "Sales Assistant",
  "description": "Handles lead qualification",
  "model": "openai:gpt-4o",
  "system_prompt": "You are a helpful sales assistant...",
  "capabilities": {
    "mcp_servers": ["hubspot", "gmail"],
    "memory_enabled": true,
    "knowledge_base_enabled": true,
    "web_search_enabled": false,
    "image_generation_enabled": false
  },
  "created_at": "2024-01-15T10:00:00Z",
  "updated_at": "2024-02-01T15:30:00Z"
}

affinitybots_chat

Send a message to an agent and receive a response.

Parameters:

NameTypeRequiredDescription
agent_idstringYesThe unique ID of the agent to chat with
messagestringYesThe message to send
thread_idstringNoThread ID to continue an existing conversation

Response:

{
  "thread_id": "thread_uuid",
  "agent_id": "agent_uuid",
  "agent_name": "Sales Assistant",
  "response": "Based on our qualification framework, here are the key steps..."
}

[!TIP] Save the thread_id from the response to continue the conversation in future calls.


affinitybots_list_threads

List conversation threads for an agent or all agents.

Parameters:

NameTypeRequiredDefaultDescription
agent_idstringNo-Filter threads by agent. Omit for all agents.
limitnumberNo20Maximum threads to return (max: 100)

Response:

{
  "threads": [
    {
      "thread_id": "thread_uuid",
      "agent_id": "agent_uuid",
      "created_at": "2024-02-01T10:00:00Z",
      "updated_at": "2024-02-01T10:30:00Z"
    }
  ],
  "total": 1
}

affinitybots_get_thread

Get the full conversation history of a thread.

Parameters:

NameTypeRequiredDescription
thread_idstringYesThe unique ID of the thread

Response:

{
  "thread_id": "thread_uuid",
  "agent_id": "agent_uuid",
  "messages": [
    {
      "role": "user",
      "content": "What's the best way to qualify leads?"
    },
    {
      "role": "assistant",
      "content": "There are several effective frameworks for lead qualification..."
    }
  ],
  "created_at": "2024-02-01T10:00:00Z",
  "updated_at": "2024-02-01T10:30:00Z"
}

Workflow Tools

affinitybots_list_workflows

List all workflows accessible to you.

Parameters:

NameTypeRequiredDefaultDescription
limitnumberNo20Maximum workflows to return (max: 100)
offsetnumberNo0Number of workflows to skip
active_onlybooleanNofalseOnly return activated workflows

Response:

{
  "workflows": [
    {
      "id": "uuid",
      "name": "Content Approval",
      "description": "Reviews and approves marketing content",
      "type": "sequential",
      "is_active": true,
      "created_at": "2024-01-20T09:00:00Z",
      "updated_at": "2024-02-05T14:00:00Z"
    }
  ],
  "total": 1,
  "limit": 20,
  "offset": 0
}

Workflow Types:

  • sequential - Tasks run in a linear chain
  • orchestrator - Manager agent delegates to worker agents

affinitybots_get_workflow

Get detailed information about a workflow.

Parameters:

NameTypeRequiredDescription
workflow_idstringYesThe unique ID of the workflow

Response:

{
  "id": "uuid",
  "name": "Content Approval",
  "description": "Reviews and approves marketing content",
  "type": "sequential",
  "is_active": true,
  "tasks": [
    {
      "id": "task_uuid",
      "name": "Review Content",
      "description": "Initial content review",
      "assistant_id": "agent_uuid"
    },
    {
      "id": "task_uuid_2",
      "name": "Final Approval",
      "description": "Manager approval step",
      "assistant_id": "agent_uuid_2"
    }
  ],
  "triggers": [
    {
      "id": "trigger_uuid",
      "type": "manual",
      "name": "Manual Trigger"
    },
    {
      "id": "trigger_uuid_2",
      "type": "webhook",
      "name": "API Webhook"
    }
  ],
  "created_at": "2024-01-20T09:00:00Z",
  "updated_at": "2024-02-05T14:00:00Z"
}

affinitybots_execute_workflow

Execute a workflow with input data.

Parameters:

NameTypeRequiredDescription
workflow_idstringYesThe unique ID of the workflow
inputstringYesInput text/data for the workflow
trigger_idstringNoSpecific trigger to use (defaults to manual)

Response:

{
  "run_id": "run_uuid",
  "workflow_id": "workflow_uuid",
  "workflow_name": "Content Approval",
  "status": "running",
  "message": "Workflow execution started. Use affinitybots_get_run_status to check progress."
}

[!NOTE] Workflow execution is asynchronous. Use affinitybots_get_run_status to poll for completion.


affinitybots_get_run_status

Check the status and output of a workflow run.

Parameters:

NameTypeRequiredDescription
run_idstringYesThe unique ID of the workflow run

Response:

{
  "run_id": "run_uuid",
  "workflow_id": "workflow_uuid",
  "workflow_name": "Content Approval",
  "status": "completed",
  "input": {
    "message": "Review the Q4 marketing report"
  },
  "output": {
    "result": "Content approved with minor revisions...",
    "task_outputs": [...]
  },
  "error": null,
  "started_at": "2024-02-06T10:00:00Z",
  "completed_at": "2024-02-06T10:02:30Z"
}

Status Values:

  • pending - Queued, not started
  • running - Currently executing
  • completed - Finished successfully
  • failed - Finished with error

Error Responses

All errors follow this format:

{
  "error": "Error message description"
}

Common Errors

HTTP StatusErrorDescription
401Invalid API keyKey doesn't exist or is malformed
401API key has been revokedKey was deleted by owner
401API key has expiredKey passed expiration date
403Tool not allowed for scopeKey scope doesn't include this tool
404Agent not foundAgent doesn't exist or isn't yours
404Workflow not foundWorkflow doesn't exist or isn't yours
404Thread not foundThread doesn't exist or isn't yours
429Rate limit exceededToo many requests per minute
500Internal server errorServer-side error

Rate Limiting

Requests are rate-limited per API key:

PlanLimit
Free60/min
Starter60/min
Pro300/min
Enterprise1000/min

When rate limited, wait and retry with exponential backoff.


Best Practices

  1. Thread Reuse: Always save and reuse thread_id for ongoing conversations
  2. Pagination: Use limit and offset for large lists
  3. Scoped Keys: Create keys with only the scope you need
  4. Error Handling: Always handle error responses gracefully
  5. Async Workflows: Poll get_run_status instead of waiting