MCP Server
The Aimdoc MCP server uses the same credentials as the External API.
This page covers the authenticated org MCP server at /mcp. To let visiting AI agents talk to your published agent over a public MCP URL (no Aimdoc credentials), see Agent Gateway.
Aimdoc exposes a remote Model Context Protocol (MCP) server so AI assistants like Claude can read your Aimdoc data — conversations, contacts, visitor profiles, accounts, and activity timelines — and configure agents and services directly in chat.
Use it to ask questions like "How did this week go?", "Show me recent leads from Acme Corp", or "What did this visitor do before they booked a demo?" With a user-authorized connection, you can also create and update agents and services, then publish draft changes after review.
Overview
Server URL:
https://api.aimdoc.ai/mcp
The server uses Streamable HTTP transport. Read tools are backed by the same data layer as the External API. Agent and service configuration tools edit a draft and only reach customers after you publish.
When connected, your assistant can:
- Summarize activity with aggregate counts
- Search and read conversation transcripts
- Look up captured contacts and leads
- Explore visitor profiles and enrichment data
- Browse accounts (companies), ICP fit, CRM match, and usage
- Review visitor journeys and on-site activity
- List, create, and update agents, including form fields, websites, objectives, and skills
- Add Q&A pairs to the organization knowledge base
- Publish draft agent changes after you approve them
- List, create, and update services, including tools, access, automations, event triggers, and pricing
- Publish a service draft after you approve the diff
- Inspect your connected MCP servers and call their read-only tools
Connect with Claude
The recommended way to connect is through an MCP client that supports OAuth 2.1, such as Claude or Claude Code.
- In your MCP client, add a remote MCP server with URL
https://api.aimdoc.ai/mcp - The client discovers Aimdoc's OAuth endpoints automatically and starts the authorization flow
- Sign in to your Aimdoc dashboard if prompted
- Review the consent screen and approve access for your organization
- The client receives an access token and can call MCP tools on your behalf
During consent, you grant access to conversations, contacts, visitor profiles, accounts, agent configuration, and services for your organization.
OAuth access tokens expire after 1 hour. MCP clients that support refresh tokens will rotate them automatically. You can revoke access at any time from your Aimdoc dashboard.
If you are testing locally, the MCP server is also available at http://localhost:8000/mcp when running the Aimdoc backend in development.
Connect with an API key
For custom MCP clients or programmatic access, authenticate with an API key instead of OAuth.
Server URL:
https://api.aimdoc.ai/mcp
Authorization header:
Authorization: Bearer ak_your_api_key_here
Create an API key the same way as the REST API:
- Go to Integrations
- Open API Keys
- Click Create new key
- Copy and store the key securely
You can only view your API key at the time of creation. Save it securely — you won't be able to view it again.
API keys share the same rate limits and read access as OAuth tokens. Tools that create, update, or publish agents or services, or add knowledge-base Q&A pairs, are not available to API-key credentials — use a user-authorized OAuth connection for those.
Available tools
Start with get_usage_summary for aggregate questions, then drill into specific records. Use list_accounts when you need company-level context, then pass account_id into the search tools.
get_organization_info
Confirm which Aimdoc organization the connection is authenticated as. Returns the organization id, name, and created_at. For the companies engaging with you, use list_accounts instead.
No parameters.
get_usage_summary
Get aggregate activity counts for a date range: total conversations, conversations with visitor interaction, contacts created, and journey event counts by type (meetings booked, escalations, buyer intent, and more).
| Parameter | Description |
|---|---|
start_date | Start of range (YYYY-MM-DD). Defaults to 30 days ago. |
end_date | End of range (YYYY-MM-DD). Defaults to today. |
This tool is available on MCP only — there is no matching REST endpoint.
search_conversations
Search chat sessions between your AI sales agent and website visitors. Results are newest first and paginated.
| Parameter | Description |
|---|---|
start_date, end_date | Date range (YYYY-MM-DD). Default: last 30 days. |
agent_id | Filter by agent. |
contact_id | Filter by contact. |
visitor_id | Filter by visitor. |
account_id | Filter to conversations from that account's contacts and visitors. Get IDs from list_accounts. |
initiated_by | Filter by who started the conversation: visitor, ai, human (a rep), or sdk (seeded by your site, for example aimdoc.sendMessage). Use visitor for genuine visitor-started chats. |
page, per_page | Pagination (max 100 per page). |
REST equivalent: GET /api/v1/conversations
get_conversation
Get one conversation with its full message transcript in chronological order. Use conversation IDs from search_conversations.
| Parameter | Description |
|---|---|
conversation_id | Required. The conversation to fetch. |
REST equivalent: GET /api/v1/messages?conversation_id=... (MCP bundles conversation metadata and messages together).
search_contacts
Search contacts who shared their details — name, email, company — with your agent.
| Parameter | Description |
|---|---|
search | Match name, email, or company. |
start_date, end_date | Filter by contact creation date (YYYY-MM-DD). Default: last 30 days. |
agent_id | Filter by agent. |
account_id | Filter to contacts linked to that account. Get IDs from list_accounts. |
page, per_page | Pagination (max 100 per page). |
REST equivalent: GET /api/v1/contacts
list_visitor_profiles
List visitor profiles with identity and company enrichment, whether or not the visitor became a contact.
| Parameter | Description |
|---|---|
search | Match person, company, or contact fields. |
contact_id | Filter by associated contact. |
account_id | Filter to visitors linked to that account. Get IDs from list_accounts. |
first_seen_after, first_seen_before | Filter by first seen date (YYYY-MM-DD). |
last_seen_after, last_seen_before | Filter by last seen date (YYYY-MM-DD). |
page, per_page | Pagination (max 100 per page). |
REST equivalent: GET /api/v1/visitor-profiles
get_visitor_profile
Get the full profile for one visitor: person identity, company enrichment, referrer context, associated contact, and latest conversation.
| Parameter | Description |
|---|---|
visitor_id | Required. Use IDs from list_visitor_profiles, search_conversations, or get_visitor_journey. |
REST equivalent: GET /api/v1/visitor-profiles/{visitor_id}
get_visitor_journey
Get a visitor's activity timeline: journey events (session started, contact created, meeting booked, escalation, buyer intent, identification) and browser activity (page views, clicks).
| Parameter | Description |
|---|---|
visitor_id | Provide exactly one of visitor_id or conversation_id. |
conversation_id | Provide exactly one of visitor_id or conversation_id. |
start_date, end_date | Date range (YYYY-MM-DD). Default: last 30 days. |
Returns the most recent 50 of each event kind. Check each section's pagination.total to see if more events exist.
REST equivalent: GET /api/v1/visitor-journey-events and GET /api/v1/browser-events (MCP merges both into one response).
list_accounts
List accounts — companies engaging with your website or product, derived from contact work emails, visitor enrichment, or SDK identify. Each row includes contact and visitor counts, last activity, the cached CRM match, and the ICP fit score (1–100).
| Parameter | Description |
|---|---|
search | Match name, domain, or external ID. |
sort_by | One of last_activity_at (default), name, domain, external_id, created_at, first_confirmed_at, fit_score, lead_count, visitor_count. |
sort_order | asc or desc (default). |
page, per_page | Pagination (max 100 per page). |
REST equivalent: GET /api/v1/accounts
get_account
Get one account's full profile: company facts, CRM match with account owner, ICP fit score with research findings, linked contacts and visitor profiles (first 50 of each), and the 10 most recent conversations. For complete people lists, filter search_contacts or list_visitor_profiles by account_id.
| Parameter | Description |
|---|---|
account_id | Required. Use IDs from list_accounts. |
REST equivalent: GET /api/v1/accounts/{account_id}
get_account_activity
Get an account's engagement: daily usage, most active people, or top website pages.
| Parameter | Description |
|---|---|
account_id | Required. Use IDs from list_accounts. |
view | daily (default): per-day series plus a 30-day DAU/MAU/stickiness summary. people: most active people. pages: top website pages. |
days | For daily only. Series length (1–366). Default 91. |
start_date, end_date | For people and pages (YYYY-MM-DD). Default: last 30 days. |
REST equivalents: GET /api/v1/accounts/{account_id}/activity/daily, /activity/people, and /activity/pages.
Agent configuration tools
These tools inspect and edit agent drafts. Mutating tools require a
user-authorized OAuth connection (not an API key). Nothing reaches visitors
until you call publish_agent with confirm=true after reviewing pending
changes.
list_agents
List the organization's agents with published and draft timestamps. Use this
to find an agent_id before configuring or publishing.
No parameters.
get_agent
Get one agent's full draft configuration: name, persona, goal, conversation starters, data-capture fields, training websites, objectives, and unpublished changes.
| Parameter | Description |
|---|---|
agent_id | Required. Get IDs from list_agents. |
create_agent
Create a new agent. Research the company first and write a substantive
persona and goal. agent_type is website (default) or product
(in-app). starters is up to 3 suggested opening questions.
| Parameter | Description |
|---|---|
name | Required. |
persona | Required. Who the agent is and its ideal customer. |
goal | Required. What the agent should achieve in conversations. |
agent_type | website or product. Default website. |
description | Optional. |
starters | Optional list of up to 3 strings. |
app_goal | Optional. The prompt the agent follows in App Mode. |
app_url | Optional. The main application URL; the widget switches into App Mode on it. |
app_allowlist_urls | Optional list of additional URLs treated as the application. |
idempotency_key | Optional. Reuse the same key to make retries safe. |
update_agent
Update core draft settings. Only the parameters you pass change. persona
and goal replace the current text entirely — read them with get_agent
first.
| Parameter | Description |
|---|---|
agent_id | Required. |
name, description, persona, goal, agent_type, starters | Optional fields to change. |
app_goal, app_url, app_allowlist_urls | Optional App Mode fields. app_allowlist_urls replaces the whole list; an empty value clears it. |
update_agent_fields
Add, update, or remove data-capture form fields on the draft.
| Parameter | Description |
|---|---|
agent_id | Required. |
add | Fields to add: {label, type, name?, required?, options?, description?}. |
update | Fields to change: {name, ...} with only the properties to update. |
remove | Field names to remove. |
add_agent_website
Add a website to the agent's knowledge base and start crawling it. Attach happens on the draft — publish for trained knowledge to reach visitors.
| Parameter | Description |
|---|---|
agent_id | Required. |
url | Site root (for example https://example.com). |
add_qa_pairs
Add question-and-answer pairs to the organization knowledge base. Dynamic Q&A is global — every agent can retrieve the pairs immediately via knowledge search. There is no draft or publish_agent step.
Requires a user-authorized OAuth connection (not an API key).
| Parameter | Description |
|---|---|
qa_pairs | Required. Array of {question, answer} objects. Max 100 per call. |
create_agent_objective / update_agent_objective
Create or update a journey objective on the draft. key is a
stable slug; level is account or person; optional stage, gating,
completion_sources, and customer_facing match the Objectives tab.
customer_facing true exposes the name (never the description) in the
checklist your product reads through the Services SDK. Changes go live with
publish_agent.
list_agent_skills / create_agent_skill
List or create skills on the draft. Skills combine activation rules, instructions, and granted tools. Workflow tracks and skills are mutually exclusive; tracks take precedence when enabled.
get_agent_workflow
Read the agent's legacy visitor workflow (tracks tree), typically to migrate it to skills. Workflow mode switches remain dashboard-only.
| Parameter | Description |
|---|---|
agent_id | Required. |
publish_agent
Publish draft changes so they go live for visitors.
| Parameter | Description |
|---|---|
agent_id | Required. |
confirm | Default false returns pending changes without publishing. Set true only after the user has approved those changes. |
Service authoring tools
These tools inspect and edit services. Mutating tools require a user-authorized OAuth connection (not an API key). Nothing is customer-visible until you publish a draft and the catalog listing is configured.
Call list_service_authoring_options before constructing tool bindings or
access policy so you use real MCP server ids and valid enum values.
Read
list_services/get_service/list_service_versions— catalog, draft vs published, live listing, and version historylist_service_authoring_options— valid native tools, connected MCP servers, surfaces, acquisition modes, and capabilitiespreview_service_access— the catalog and allowed actions for a contact, account, or anonymous visitorget_service_run— status and result for one runlist_service_access_requests— pending and decided access requestslist_service_automations/list_service_event_subscriptions— standing work and event triggersget_service_price— the current price package (draft or active), the margin preview, anything blocking activation, and whether Stripe is ready
Write
create_service/update_service/update_service_draft/configure_service_tools— identity, draft instructions, inputs, the optionaltarget_credits/max_creditsrun budget, and tools. Prefer a stableidempotency_keyon create.discard_service_draft/restore_service_version— throw away unpublished edits, or copy a published version back into the draftconfigure_service_offering— live listing, surfaces, and acquisition. Takes effect immediately; it is not part of a version.set_service_access_rule/grant_service_plan_access/revoke_service_plan_access/decide_service_access_request— who may discover, run, and automate. A plan grant can carry a counted allowance (limitplus aperiodofnoneorbilling_period).configure_service_price/activate_service_price— write the draft price package (one-time or subscription, included runs, reset period) and review its margin preview, then make it live in your connected Stripe account. Activation archives the previous price; existing orders keep their terms.test_service_as_contact— run the draft or published version as a real contact. Tests are saved-only and never delivered to the customer.publish_service— always call withconfirm=falsefirst, review the executable diff with the user, then call again withconfirm=true- Automation and event-trigger tools (
create_service_automation,pause_service_automation,run_service_automation,create_service_event_subscription, and the matching update / resume / cancel / delete tools) — standing work for one customer, or "whenever this event fires, run this service"
See Services and Events for the product behavior these tools configure.
Connected MCP server tools
Two tools let your assistant look at the MCP servers you connected under Integrations without handing it their credentials:
inspect_mcp_connection— list connected servers and the tool schemas Aimdoc discovered on them. Omitmcp_server_idto list every connection. Credentials and OAuth secrets are never returned.call_mcp_tool— call one tool on a connected server. Aimdoc supplies the stored credential server-side. Only tools that advertise themselves as read-only are callable this way; an optionalreasonis recorded for audit.
Authentication
The MCP server is an OAuth 2.1 resource server. It accepts two types of bearer tokens:
| Token type | Prefix | How to obtain |
|---|---|---|
| OAuth access token | oat_ | Authorize through an MCP client (recommended for Claude) |
| API key | ak_ | Create in Integrations → API Keys |
Both token types grant the api scope and access the same organization data
for read tools. Only OAuth (or another user-backed credential) can call agent
and service configuration writes, including publish_agent and
publish_service.
Discovery endpoints
MCP clients use these well-known URLs to discover authentication:
GET https://api.aimdoc.ai/.well-known/oauth-protected-resource/mcp— protected resource metadataGET https://api.aimdoc.ai/.well-known/oauth-authorization-server— authorization server metadata
Unauthenticated requests to /mcp return 401 with a WWW-Authenticate challenge pointing clients to these discovery documents.
Rate limits
MCP tool calls share the same rate limits as the External API:
- 1,000 requests per hour
- 10,000 requests per day
Limits are tracked per credential (API key or OAuth token family). When a limit is exceeded, the tool returns an error with a retry hint rather than an HTTP 429 response.
Related docs
- Services for authoring and delivering capabilities
- Events to emit product events and trigger services
- Agent Gateway for the public conversation MCP at
/mcp/public/{agent_id} - API & Webhooks Overview for REST API authentication and endpoints
- Objectives for journey goals agents track
- Skills for reusable agent behavior
- Webhooks Guide for real-time event delivery
- API Reference (Redoc) for full REST schemas and examples