> ## 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.

# MCP सर्वर से कनेक्ट करें

> किसी भी MCP क्लाइंट को Ayrshare MCP सर्वर से कनेक्ट करें — transport, endpoint, और authentication।

Ayrshare [MCP सर्वर](/additional/mcp-action-server) एक AI agent को Ayrshare API चलाने देता है। यह पृष्ठ बताता है कि इससे कैसे कनेक्ट करें और authentication कैसे काम करता है।

## Endpoint और transport

Production MCP सर्वर यहाँ उपलब्ध है:

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

यह **Streamable HTTP** transport का उपयोग करता है और **stateless** है — calls के बीच बनाए रखने के लिए कोई session नहीं है।

## Authentication

Authentication उसी Ayrshare API chain द्वारा लागू किया जाता है जो REST API को शक्ति प्रदान करती है।

<ul class="custom-bullets">
  <li>**आवश्यक:** `Authorization: Bearer YOUR_API_KEY` — आपकी account API key (profiles और sub-profiles के लिए Business plan key)।</li>
  <li>**वैकल्पिक:** `Profile-Key: YOUR_PROFILE_KEY` — connection पर प्रत्येक call के लिए एक sub-profile को target करती है।</li>
  <li>**प्रति call वैकल्पिक:** एक `profileKey` tool argument — एकल tool call के लिए sub-profile को target करता है।</li>
</ul>

### प्राथमिकता: argument header पर जीतता है

जब एक tool call में `profileKey` argument शामिल हो **और** connection में `Profile-Key` header हो, तो **प्रति-call `profileKey` argument जीतता है**। Header का उपयोग केवल तब होता है जब कोई मान्य argument प्रदान नहीं किया गया हो।

एक अपवाद: `get_platform_history` और `get_social_network_analytics` पर, X/Twitter `userId`/`userName` lookup को केवल account API key का उपयोग करना चाहिए; वहाँ `profileKey` argument या `Profile-Key` header देने पर Error 400 लौटाया जाता है।

<Note>
  `initialize` और `tools/list` MCP methods authentication से **पहले** पहुँच योग्य हैं — वे केवल metadata लौटाते हैं और कुछ भी execute नहीं करते। **प्रत्येक tool call authenticated होती है।**
</Note>

### Authentication errors

किसी tool call पर unauthenticated या अमान्य key Ayrshare **error 403 / code 102** को संदेश **"API Key not valid"** के साथ लौटाती है। MCP spec के अनुसार, tool-execution errors in-band लौटाई जाती हैं: tool result `isError: true` और यह संदेश रखता है, जबकि MCP transport स्वयं **HTTP 200** से प्रतिक्रिया देता है। (`403`/`102` Ayrshare की application error हैं, transport status नहीं।)

## कनेक्ट करें

### विकल्प A: Claude Code plugin

यदि आप Claude Code का उपयोग करते हैं, तो Ayrshare plugin स्थापित करें। यह MCP सर्वर configuration, एक setup command, agents, skills, और एक confirmation hook को बंडल करता है। पूर्ण install steps के लिए [Claude Code Plugin](/additional/mcp-claude-code-plugin) पृष्ठ देखें।

### विकल्प B: कोई भी MCP client

किसी भी MCP client के लिए जो Streamable HTTP का समर्थन करता है, सर्वर को सीधे register करें। Claude Code में:

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

प्रत्येक call पर एक sub-profile को target करने के लिए, वैकल्पिक `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>
  MCP connection session शुरू होने पर initialize होता है। सर्वर स्थापित करने या अपनी key बदलने के बाद **अपने MCP client को restart करें** ताकि नया configuration प्रभावी हो।
</Warning>

## X/Twitter BYO credentials

31 मार्च 2026 से, Ayrshare के माध्यम से X/Twitter operations के लिए आपके स्वयं के OAuth 1.0a credentials आवश्यक हैं। जब कोई tool call X/Twitter को target करता है, तो अपने `Authorization` (और वैकल्पिक `Profile-Key`) headers के साथ connection पर ये दो headers forward करें:

| Header                        | विवरण                                            |
| ----------------------------- | ------------------------------------------------ |
| `X-Twitter-OAuth1-Api-Key`    | आपकी OAuth 1.0a API Key (Consumer Key)           |
| `X-Twitter-OAuth1-Api-Secret` | आपकी OAuth 1.0a API Key Secret (Consumer Secret) |

ये वही headers हैं जिनका उपयोग REST API करता है — प्रति Ayrshare account एक OAuth 1.0a key pair, प्रत्येक X-targeting request पर भेजा जाता है (वही जोड़ी सभी sub-profiles पर लागू होती है)। Ayrshare यहाँ OAuth 2.0 का उपयोग नहीं करता। सेटअप, नीति और troubleshooting के लिए [API Overview](/apis/overview#xtwitter-byo-credentials) और [X BYO Key Setup Guide](/dashboard/connect-social-accounts/x-twitter-byo-keys) देखें।

<Warning>
  इन headers के बिना, एक X/Twitter tool call error `419` (`x_credentials_required`) लौटाती है।
</Warning>

### BYO headers के साथ कनेक्ट करें

शुरू से X/Twitter BYO credentials सेट अप करने के लिए, अपने `Authorization` header के साथ दोनों OAuth 1.0a headers जोड़कर सर्वर जोड़ें (यदि आप प्रत्येक call पर sub-profile target करते हैं, तो `Profile-Key` भी शामिल करें):

```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"
```

### किसी मौजूदा connection में BYO headers जोड़ें

Connection headers सर्वर जोड़ते समय ही तय हो जाते हैं, इसलिए यदि आप पहले BYO headers के बिना कनेक्ट हो चुके हैं, तो सर्वर हटाएँ और उसे पूर्ण सेट के साथ फिर से जोड़ें (कोई भी headers जो आप पहले से उपयोग कर रहे थे, जैसे `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"
```

Headers बदलने के बाद अपने MCP client को restart करें ताकि नया configuration प्रभावी हो। raw connection के बजाय Claude Code plugin का उपयोग कर रहे हैं? देखें [Claude Code Plugin → X/Twitter BYO credentials](/additional/mcp-claude-code-plugin#xtwitter-byo-credentials)।

## अगले चरण

<CardGroup cols={2}>
  <Card title="Tool Catalog" icon="list" href="/additional/mcp-action-tools" horizontal>
    domain के अनुसार समूहित 27 tools, scope और उद्देश्य के साथ।
  </Card>

  <Card title="Claude Code Plugin" icon="terminal" href="/additional/mcp-claude-code-plugin" horizontal>
    Claude Code के लिए Ayrshare plugin स्थापित करें।
  </Card>
</CardGroup>
