How to Set Up the XreplyAI MCP Server in Claude Code

If you use Claude Code as your primary development environment, you already have an AI assistant that can read files, run commands, and reason about your codebase. What you may not have is a direct connection to your X/Twitter content pipeline. That is what the XreplyAI MCP server adds: 13 tools that let you generate posts in your voice, manage a draft queue, and publish to X without ever leaving your terminal.
Setup takes under five minutes. You need an XreplyAI account, Node.js 20 or later, and Claude Code installed. This guide walks through every step from getting your authentication token to running your first tool call, plus the manual configuration path if you prefer to edit JSON directly.
If you want background on what the MCP server can do before diving into setup, start with the XreplyAI MCP server overview. Otherwise, read on and you will be generating posts from your terminal in a few minutes.
What You Need Before Starting
There are three prerequisites before you run any commands. First, you need an active XreplyAI account. The MCP server authenticates against your account, uses your voice profile for post generation, and respects your plan's posting quotas. If you do not have an account yet, create one at xreplyai.com before continuing.
Second, you need Node.js 20 or later. The MCP server runs as an npx process, so Node.js is the only runtime dependency. Check your version with node --version. If you are on an older version, update via nodejs.org or your preferred version manager such as nvm, fnm, or volta.
Third, you need Claude Code installed and working. You should be able to run claude from your terminal and start a session. If Claude Code is not installed, follow the setup instructions at claude.ai/code. Once all three are in place, the actual MCP server setup is two commands.
Step 1: Get Your JWT Token from XreplyAI Settings
The MCP server authenticates with a JWT token tied to your XreplyAI account. To get your token, log in to XreplyAI and navigate to Settings. There is a dedicated section for MCP access where your token is displayed. Copy the full token string: it is a long base64-encoded value and you will paste it directly into the setup command.
One important detail: tokens expire every 30 days. Mark a calendar reminder or note it somewhere visible. When a token expires, any tool call will return a 401 error. Refreshing is straightforward: go back to Settings, generate a new token, and update your Claude Code MCP configuration with the new value. The steps for updating the token are the same as the initial setup. Just run the claude mcp add command again with the new token and it will overwrite the existing entry.
Keep your token private. It grants full access to your XreplyAI account including post generation, queue management, and publishing. Do not commit it to a repository or paste it into a shared document. The environment variable approach used in the next step keeps it out of config files that might end up in version control.
Step 2: Register the MCP Server with Claude Code
With your token ready, run this command in your terminal:
claude mcp add xreply -e XREPLY_TOKEN=your-token -- npx @xreplyai/mcp
Replace your-token with the actual JWT token you copied from Settings. This command does three things: it registers a new MCP server named xreply, sets XREPLY_TOKEN as an environment variable that the server process will read, and configures Claude Code to launch the server using npx @xreplyai/mcp on demand.
By default, this registers the server at the local (project) scope. To register it globally so it is available in every Claude Code session on your machine, add the --scope user flag:
claude mcp add --scope user xreply -e XREPLY_TOKEN=your-token -- npx @xreplyai/mcp
You do not need to install @xreplyai/mcp globally first. The npx command handles downloading and running the package automatically each time the server starts, so you always get the latest version without a separate update step.
Step 3: Verify the Server Is Registered
After running the claude mcp add command, confirm the registration worked:
claude mcp list
You should see xreply listed as a registered MCP server. If it does not appear, re-run the add command and check for any output errors. Common issues at this step include a typo in the server name or a malformed token that causes the command to reject the environment variable.
Once confirmed in the list, start a new Claude Code session. The MCP server loads at session start, not at registration time, so you need a fresh session for the tools to be available. Open a terminal, run claude, and you are ready to test.
At this point, 13 tools are available in your session: generation tools (xreply_posts_generate, xreply_posts_generate_batch), queue management tools (xreply_posts_create, xreply_posts_list, xreply_posts_edit, xreply_posts_delete, xreply_posts_publish), discovery (xreply_viral_library), preferences (xreply_preferences_get, xreply_preferences_set), rules (xreply_rules_list), and account status (xreply_voice_status, xreply_billing_status).
Alternative: Manual JSON Configuration
If you prefer to configure MCP servers by editing JSON directly, you can create a .mcp.json file in your project directory. This is the project-scoped configuration file that Claude Code reads automatically. Create or edit .mcp.json at the root of your project and add the following:
{"mcpServers": {"xreply": {"command": "npx", "args": ["@xreplyai/mcp"], "env": {"XREPLY_TOKEN": "your-token"}}}}
Replace your-token with your actual JWT token. Save the file, then start a new Claude Code session from that project directory. Run claude mcp list to confirm the server appears. Note that if you add .mcp.json to a shared repository, make sure to either use a placeholder token value and set the real token via environment variable, or add the file to .gitignore to avoid accidentally committing your credential.
The manual approach gives you the same result as the CLI command. The only practical difference is that you are editing the underlying config file directly. Either method works; use whichever fits your workflow.
Quick First Commands to Confirm Everything Works
Once you have a Claude Code session running with the MCP server loaded, run two tool calls to verify the connection is healthy. First, ask Claude to call xreply_voice_status. A successful response will show your voice profile status: whether training is complete, when it was last updated, and how many source tweets were used. A 401 error means your token is expired or incorrect. A connection error means the server did not start correctly.
Second, ask Claude to call xreply_billing_status. This returns your current plan tier and remaining quota for the billing period. It is a lightweight call that confirms both authentication and account data are accessible.
If both calls return data, setup is complete. You now have access to the full XreplyAI toolset from inside Claude Code. A good next step is to ask Claude to run xreply_posts_generate with a topic you care about and see a post generated in your voice. From there, you can explore batch generation, the viral library, and the full queue management workflow.
For a complete walkthrough of what each tool does and how to combine them into a content pipeline, see the XreplyAI MCP server overview.
Setting up the XreplyAI MCP server in Claude Code takes two commands and less than five minutes. Once it is running, you have 13 tools for X content directly in your terminal: generate posts in your voice, manage a draft queue, browse viral tweets for inspiration, and publish on schedule. No browser tabs, no context switching, no separate app.
If you do not have an XreplyAI account yet, start at xreplyai.com. Connect your X account, let the voice profile train on your past tweets, then come back here and run the setup. Your first batch-generated post is a single Claude Code prompt away.
FAQ
- How long does it take to set up the XreplyAI MCP server in Claude Code?
- Under five minutes in most cases. The setup is two commands: one to register the server with your token, one to verify it appears in the list. You then start a new Claude Code session and the tools are available. The only time-consuming part is if you need to update Node.js to version 20 or later first.
- Why do my XreplyAI tools return a 401 error?
- A 401 error means your JWT token is expired or incorrect. Tokens expire every 30 days. To fix it, log in to XreplyAI Settings, generate a new token, and re-run <code>claude mcp add xreply -e XREPLY_TOKEN=new-token -- npx @xreplyai/mcp</code> with the updated value. Start a new Claude Code session after updating.
- Do I need to install @xreplyai/mcp globally with npm?
- No. The setup command uses <code>npx @xreplyai/mcp</code>, which downloads and runs the package on demand without a global install. This also means you get the latest version automatically each time the server starts, with no separate update step required.
- How do I make the XreplyAI MCP server available in all my Claude Code projects?
- Use the <code>--scope user</code> flag when registering: <code>claude mcp add --scope user xreply -e XREPLY_TOKEN=your-token -- npx @xreplyai/mcp</code>. This stores the configuration at the user level rather than the project level, so the server is available in every Claude Code session on your machine.
- What happens if the MCP server does not appear in claude mcp list?
- Re-run the <code>claude mcp add</code> command and check for any output errors. Common causes are a typo in the server name, a malformed token, or a Node.js version below 20. Run <code>node --version</code> to confirm you are on Node 20 or later, then try the add command again.