> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect to the MCP Server

> Connect any MCP client to the Ayrshare MCP Server — transport, endpoint, and authentication.

The Ayrshare [MCP Server](/docs/additional/mcp-action-server) lets an AI agent drive the Ayrshare API. This page covers how to connect to it and how authentication works.

## Endpoint and transport

The production MCP Server is available at:

`https://api.ayrshare.com/mcp`

It uses **Streamable HTTP** transport and is **stateless** — there is no session to maintain between calls.

<h2 id="supported-clients">
  Supported clients
</h2>

The Action MCP Server authenticates **only** with a static `Authorization: Bearer` request header. That one requirement decides everything below: a client that can set a custom HTTP header on a Streamable HTTP connection can authenticate, and a client that cannot, cannot. Find your client before you start setup.

| Client | Can it authenticate? | How, or why not |
| - | - | - |
| **Claude Code (CLI)** | **Yes** | `claude mcp add --transport http … --header "Authorization: Bearer YOUR_API_KEY"`. This is the recommended path — see [Option B: Any MCP client](#option-b-any-mcp-client) below. |
| **Claude Code plugin** | **Yes** | The bundled MCP configuration sends your key as the `Authorization` header. See [Claude Code Plugin](/docs/additional/mcp-claude-code-plugin). |
| **Claude Desktop — personal connector** | **No** | A personal custom connector cannot send a static `Authorization` header, and Ayrshare has not verified any third-party bridge that adds one. Use [Claude Code](#option-b-any-mcp-client) instead, or see the organization option below. |
| **claude.ai web — personal connector** | **No** | A personal connector cannot send a static `Authorization: Bearer` header, and Ayrshare publishes no OAuth metadata for it to use instead. See [Why personal connectors cannot authenticate](#why-personal-connectors-cannot-authenticate) below. |
| **Claude mobile — personal connector** | **No** | Same as claude.ai web: a personal connector has no way to present an Ayrshare API key. |
| **Claude Team or Enterprise — organization administrator** | **Beta, administrators only** | Anthropic's `static_headers` request-header option, available in beta to organization administrators in a limited set of organizations. See [Team and Enterprise organizations](#team-and-enterprise-organizations) below. |
| **Cursor** | **Yes** | Supported via a `headers` block on the remote server entry — `"Authorization": "Bearer YOUR_API_KEY"` — per [Cursor's MCP documentation](https://cursor.com/docs/context/mcp). |
| **VS Code** | **Yes** | Supported via the `headers` property on an `http` MCP server entry, per [VS Code's MCP configuration reference](https://code.visualstudio.com/docs/agents/reference/mcp-configuration). |
| **n8n** | **Yes** | Supported via a Bearer credential (or a generic header) on the MCP Client Tool node, per [n8n's MCP Client Tool documentation](https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolmcp/). See the [n8n guide](/docs/additional/mcp-n8n). |
| **Any client supporting custom HTTP headers** | **Yes** | Send `Authorization: Bearer YOUR_API_KEY` on every request. That is the server's only authentication requirement, so a client not listed above is still answerable by this rule. |

<h3 id="why-personal-connectors-cannot-authenticate">
  Why personal connectors cannot authenticate
</h3>

Ayrshare's Action MCP requires a static `Authorization: Bearer` header. Adding it as a personal custom connector on claude.ai, Claude Desktop, or Claude mobile does not work, because Ayrshare publishes no OAuth metadata and the request-header alternative is a beta limited to approved organizations.

On a personal connector, no setting on your side fixes this: there is no field for an `Authorization` header, and no API key, profile, or account setting that enables one. **Ayrshare does not publish OAuth metadata, so the connector's OAuth path has nothing to connect to.** Use a client from the table above instead: [Claude Code](#option-b-any-mcp-client), the [Claude Code plugin](/docs/additional/mcp-claude-code-plugin), or any client that lets you set a custom `Authorization` header. If you are an administrator of an organization in Anthropic's request-header beta, see [Team and Enterprise organizations](#team-and-enterprise-organizations) below.

<Warning>
  **If your connector looks healthy but every tool fails.** The connector adds cleanly, reports **healthy**, and lists the **full tool catalog** — and then **every** tool call returns Ayrshare **403 / code 102, "API Key not valid"**. That is this limitation, not a broken key — your client cannot send the static `Authorization: Bearer` header this server requires. `initialize` and `tools/list` are reachable before authentication (see [Authentication](#authentication) below), so nothing fails until the first tool call, when it becomes clear no credential was ever sent.

  **Client capability, or a genuinely bad key?** They return the identical error, so use the signature to tell them apart. A client-capability failure means the connector is healthy **and** every tool fails, while the same key works elsewhere. A bad key produces the same error but is reproducible outside the connector — it fails on a REST call too. For the error semantics themselves, see [Authentication errors](#authentication-errors) below.
</Warning>

<h3 id="team-and-enterprise-organizations">
  Team and Enterprise organizations
</h3>

Anthropic's `static_headers` mechanism lets a custom connector send a fixed credential as a request header instead of using OAuth. It is **available in beta to organization administrators in a limited set of organizations**, and it is **not** available to individual users adding a personal connector.

If your organization has access, the administrator must enter the header value as `Bearer ` followed by your Ayrshare API key, including the space — Claude sends the value exactly as entered and does not add the scheme for you. For current availability and setup, see [Anthropic's connector authentication documentation](https://claude.com/docs/connectors/building/authentication).

<Warning>
  **The key is shared by the whole organization.** Anthropic's request-header credential is entered once by an administrator and used by every member of the organization, so all of them act as the single Ayrshare account that key belongs to — with access to every [User Profile](/docs/multiple-users/manage-user-profiles) under it on a Business key, and no per-user attribution in your Ayrshare history or analytics. Treat it as a shared service credential, not as individual access.
</Warning>

<h2 id="authentication">
  Authentication
</h2>

Authentication is enforced by the same Ayrshare API chain that powers the REST API.

<ul class="custom-bullets">
  <li>**Required:** `Authorization: Bearer YOUR_API_KEY` — your account API key (Business plan key for profiles and sub-profiles).</li>
  <li>**Optional:** `Profile-Key: YOUR_PROFILE_KEY` — targets a sub-profile for every call on the connection.</li>
  <li>**Optional per call:** a `profileKey` tool argument — targets a sub-profile for a single tool call.</li>
</ul>

<h3 id="precedence-argument-wins-over-header">
  Precedence: argument wins over header
</h3>

When a tool call includes a `profileKey` argument **and** the connection has a `Profile-Key` header, the **per-call `profileKey` argument wins**. The header is used only when no valid argument is provided.

One exception: on `get_platform_history` and `get_social_network_analytics`, an X/Twitter `userId`/`userName` lookup must use the account API key only; supplying a `profileKey` argument or `Profile-Key` header there returns Error 400.

<Note>
  The `initialize` and `tools/list` MCP methods are reachable **before** authentication — they return metadata only and execute nothing. **Every tool call is authenticated.**
</Note>

<h3 id="authentication-errors">
  Authentication errors
</h3>

An unauthenticated or invalid key on a tool call returns an Ayrshare **error 403 / code 102** with message **"API Key not valid"**. Per the MCP spec, tool-execution errors are returned in-band: the tool result carries `isError: true` and this message, while the MCP transport itself responds **HTTP 200**. (The `403`/`102` are Ayrshare's application error, not the transport status.)

## Connect

### Option A: Claude Code plugin

If you use Claude Code, install the Ayrshare plugin. It bundles the MCP Server configuration, a setup command, agents, skills, and a confirmation hook. See the [Claude Code Plugin](/docs/additional/mcp-claude-code-plugin) page for the full install steps.

<h3 id="option-b-any-mcp-client">
  Option B: Any MCP client
</h3>

For any MCP client that supports Streamable HTTP **and lets you set a custom request header** — see [Supported clients](#supported-clients) above — register the server directly. In Claude Code:

```bash theme={"system"}
claude mcp add --transport http ayrshare https://api.ayrshare.com/mcp --header "Authorization: Bearer YOUR_API_KEY"
```

To target a sub-profile on every call, add the optional `Profile-Key` header:

```bash theme={"system"}
claude mcp add --transport http ayrshare https://api.ayrshare.com/mcp \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Profile-Key: YOUR_PROFILE_KEY"
```

<Warning>
  The MCP connection initializes at session start. **Restart your MCP client** after installing the server or changing your key so the new configuration takes effect.
</Warning>

<div id="x/twitter-byo-credentials" />

<h2 id="xtwitter-byo-credentials">
  X/Twitter BYO credentials
</h2>

Since March 31, 2026, X/Twitter operations through Ayrshare require your own OAuth 1.0a credentials. When a tool call targets X/Twitter, forward these two headers on the connection alongside your `Authorization` (and optional `Profile-Key`) headers:

| Header | Description |
| - | - |
| `X-Twitter-OAuth1-Api-Key` | Your OAuth 1.0a API Key (Consumer Key) |
| `X-Twitter-OAuth1-Api-Secret` | Your OAuth 1.0a API Key Secret (Consumer Secret) |

These are the same headers used by the REST API — one OAuth 1.0a key pair per Ayrshare account, sent on every X-targeting request (the same pair applies to all sub-profiles). Ayrshare does not use OAuth 2.0 here. See the [API Overview](/docs/apis/overview#xtwitter-byo-credentials) and the [X BYO Key Setup Guide](/docs/dashboard/connect-social-accounts/x-twitter-byo-keys) for setup, policy, and troubleshooting.

<Warning>
  Without these headers, an X/Twitter tool call returns error `419` (`x_credentials_required`).
</Warning>

### Connect with the BYO headers

To set up X/Twitter BYO credentials from the start, add the server with both OAuth 1.0a headers alongside your `Authorization` header (include `Profile-Key` too if you target a sub-profile on every call):

```bash theme={"system"}
claude mcp add --transport http ayrshare https://api.ayrshare.com/mcp \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "X-Twitter-OAuth1-Api-Key: YOUR_TWITTER_CONSUMER_KEY" \
  --header "X-Twitter-OAuth1-Api-Secret: YOUR_TWITTER_CONSUMER_SECRET"
```

### Add the BYO headers to an existing connection

Connection headers are fixed when the server is added, so if you already connected without the BYO headers, remove the server and re-add it with the full set (re-include any headers you were already using, such as `Profile-Key`):

```bash theme={"system"}
claude mcp remove ayrshare
claude mcp add --transport http ayrshare https://api.ayrshare.com/mcp \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "X-Twitter-OAuth1-Api-Key: YOUR_TWITTER_CONSUMER_KEY" \
  --header "X-Twitter-OAuth1-Api-Secret: YOUR_TWITTER_CONSUMER_SECRET"
```

Restart your MCP client after changing headers so the new configuration takes effect. Using the Claude Code plugin instead of a raw connection? See [Claude Code Plugin → X/Twitter BYO credentials](/docs/additional/mcp-claude-code-plugin#xtwitter-byo-credentials).

## Next steps

<CardGroup cols={2}>
  <Card title="Tool Catalog" icon="list" href="/docs/additional/mcp-action-tools" horizontal>
    The 27 tools grouped by domain, with scope and purpose.
  </Card>

  <Card title="Claude Code Plugin" icon="terminal" href="/docs/additional/mcp-claude-code-plugin" horizontal>
    Install the Ayrshare plugin for Claude Code.
  </Card>
</CardGroup>
