RelayAPI

MCP Server

Give any AI assistant full access to the RelayAPI through the Model Context Protocol.

Connect any AI assistant to RelayAPI using the Model Context Protocol. Create posts, manage accounts, check analytics, and more — all through natural language.

What You Can Do

Ask your AI assistant things like:

  • "Post 'Hello world!' to Twitter"
  • "List my connected social accounts"
  • "Cross-post this announcement to Twitter and LinkedIn"
  • "Show my analytics for the past week"
  • "Upload this image and post it to Instagram"
  • "Schedule a LinkedIn post for tomorrow at 9am"

Quick Reference

Package@relayapi/mcp
ProtocolModel Context Protocol (MCP)
AuthRELAY_API_KEY environment variable
Transportstdio (default), HTTP
Toolssearch_docs, execute
SourceGitHub

How It Works

The MCP server exposes two tools that give the AI full access to the RelayAPI SDK:

Search Documentation

The AI calls search_docs to find the right SDK methods and parameters for your request.

Execute Code

The AI calls execute with TypeScript code that uses a pre-authenticated SDK client to perform the action.

Return Results

The code runs in a sandboxed environment and returns the results to the AI, which formats them for you.

Unlike MCP servers that expose one tool per API action, RelayAPI gives the AI access to the entire SDK surface through code execution. This means the AI can compose complex multi-step workflows, handle conditionals, and use new API features as soon as they ship — without waiting for MCP tool updates.

Setup

You need a RelayAPI API key. Get one from relayapi.dev under Settings > API Keys. Keys start with rlay_live_ (production) or rlay_test_ (testing).

Open Claude Desktop settings and go to Developer > Edit Config. Add the RelayAPI MCP server to claude_desktop_config.json:

claude_desktop_config.json
{
  "mcpServers": {
    "relayapi_mcp_api": {
      "command": "npx",
      "args": ["-y", "relay-mcp"],
      "env": {
        "RELAY_API_KEY": "rlay_live_your_key_here"
      }
    }
  }
}

Restart Claude Desktop after saving.

Run this command in your terminal:

claude mcp add relay_mcp_api --env RELAY_API_KEY="rlay_live_your_key_here" -- npx -y relay-mcp

The MCP server is available immediately in your next Claude Code session.

Add a new MCP server in Cursor Settings > Tools & MCP > New MCP Server with this configuration:

{
  "mcpServers": {
    "relayapi_mcp_api": {
      "command": "npx",
      "args": ["-y", "relay-mcp"],
      "env": {
        "RELAY_API_KEY": "rlay_live_your_key_here"
      }
    }
  }
}

Open the Command Palette and run MCP: Open User Configuration. Add the server:

{
  "mcpServers": {
    "relayapi_mcp_api": {
      "command": "npx",
      "args": ["-y", "relay-mcp"],
      "env": {
        "RELAY_API_KEY": "rlay_live_your_key_here"
      }
    }
  }
}

Tool Reference

search_docs

Search SDK documentation to find methods, parameters, and usage examples. Use this to discover the right approach before writing code.

ParameterTypeRequiredValuesDescription
querystringYesThe search query
languagestringYeshttp, python, go, typescript, javascript, terraform, ruby, java, kotlinTarget SDK language
detailstringNodefault, verboseAmount of detail to return

execute

Execute TypeScript code against a pre-authenticated SDK client in a sandbox. Your code must define an async run function that receives the client:

async function run(client) {
  const result = await client.posts.list();
  console.log(result.data);
}
ParameterTypeRequiredDescription
codestringYesTypeScript code defining an async run(client) function
intentstringNoDescription of the intended purpose

Execution constraints: Individual API requests have a 30-second timeout. Total code execution has a limit of approximately 5 minutes. The sandbox has no filesystem or web access except through the SDK client. Variables do not persist between separate execute calls.

Example Conversations

Simple Post

You: Post "Just shipped our new API!" to Twitter

AI: I'll create that post for you.

The AI searches the docs for the posts.create method, then executes:

async function run(client) {
  const post = await client.posts.create({
    content: 'Just shipped our new API!',
    targets: ['acc_twitter_123'],
    schedule: 'now',
  });
  console.log(post);
}

AI: Done! Your post has been published to Twitter.

List Accounts

You: Show me my connected social accounts

The AI executes:

async function run(client) {
  const accounts = await client.accounts.list();
  console.log(accounts.data);
}

AI: You have 3 connected accounts:

  • Twitter — @yourcompany
  • LinkedIn — Your Company Page
  • Instagram — @yourcompany

Cross-Post to Multiple Platforms

You: Post "Big announcement coming tomorrow!" to all my accounts

The AI lists accounts first, then creates a post targeting each one:

async function run(client) {
  const accounts = await client.accounts.list();
  const accountIds = accounts.data.map((a) => a.id);

  const post = await client.posts.create({
    content: 'Big announcement coming tomorrow!',
    targets: accountIds,
    schedule: 'now',
  });
  console.log(post);
}

AI: Published to Twitter, LinkedIn, and Instagram.

CLI Options

When running the MCP server directly, these flags are available:

FlagTypeDefaultDescription
--transportstdio | httpstdioConnection transport
--portnumber3000Port for HTTP transport
--socketstringUnix socket path for HTTP transport
--code-execution-modestainless-sandbox | localstainless-sandboxWhere to run code execution
--docs-search-modestainless-api | localstainless-apiWhere to search documentation
--toolsstringTools to enable: code, docs
--no-toolsstringTools to disable: code, docs
--debugbooleanfalseEnable debug logging
--log-formatjson | prettyautoLog output format

Remote Deployment

Run the MCP server as an HTTP service for remote or shared access:

npx -y relay-mcp@latest --transport=http --port=3000

Clients authenticate via headers:

  • Authorization: Bearer rlay_live_your_key_here
  • x-relay-api-key: rlay_live_your_key_here

Configure a remote client:

{
  "mcpServers": {
    "relayapi_mcp_api": {
      "url": "http://localhost:3000",
      "headers": {
        "Authorization": "Bearer rlay_live_your_key_here"
      }
    }
  }
}

Troubleshooting

API key not found

Make sure the RELAY_API_KEY environment variable is set in your MCP client configuration. The key must start with rlay_live_ or rlay_test_.

Tool execution timeout

Individual API requests have a 30-second timeout. If a request times out, try a smaller query or add filters. Total code execution has a limit of approximately 5 minutes — simplify complex workflows or break them into smaller steps.

Command not found: npx

The MCP server requires Node.js 18 or later. Install it from nodejs.org and make sure npx is in your PATH.

Stale package version

If you're not seeing the latest features, clear the npx cache:

npx -y relay-mcp@latest

The @latest tag ensures you always get the most recent version.

Found something wrong? Help us improve this page.

On this page

Submit an Issue
Requires a GitHub account.View repo