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

# MCP Protocol API

> The MCP protocol endpoints accept standard MCP JSON-RPC requests.

### Required Headers

```http theme={null}
Content-Type: application/json
Accept: application/json, text/event-stream
```

<Note>
  **Important**: The `Accept` header with `text/event-stream` is **REQUIRED**. Without it, you will receive a 406 Not Acceptable error.
</Note>

## With Token URL (Self-sufficient)

```http theme={null}
POST /mcp/:serverId/:accessToken
GET /mcp/:serverId/:accessToken
```

**Required Headers:**

* `Content-Type: application/json`
* `Accept: application/json, text/event-stream`

**Optional Headers:**

* `x-alloy-user-token`: JWT token for user isolation
* `x-alloy-userid`: Override user ID when needed
* `x-credential-id`: Use specific credential for operations
* `x-redirect-uri`: OAuth redirect URI for credential creation

## With API Authentication

Requires standard API authentication headers.

```http theme={null}
POST /mcp/:serverId
GET /mcp/:serverId
```

**Required Headers:**

* `Content-Type: application/json`
* `Accept: application/json, text/event-stream`
* `Authorization`: Bearer YOUR\_API\_KEY
* `x-alloy-userid`: Your user ID

**Optional Headers:**

* `x-alloy-user-token`: JWT token for user isolation
* `x-credential-id`: Use specific credential for operations
* `x-redirect-uri`: OAuth redirect URI for credential creation
* `x-mcp-server-id`: Alternative way to specify server ID

## Complete Examples

### Example with Token URL

```bash theme={null}
curl -X POST https://mcp.runalloy.com/mcp/your-server-id/your-access-token \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/list",
    "id": 1
  }'
```

### Example with API Authentication

```bash expandable theme={null}
curl -X POST https://mcp.runalloy.com/mcp/your-server-id \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-alloy-userid: YOUR_USER_ID" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "execute_action_alloy",
      "arguments": {
        "connectorId": "slack",
        "actionId": "chat_postMessage",
        "parameters": {
          "channel": "#general",
          "text": "Hello from MCP!"
        }
      }
    },
    "id": 1
  }'
```

## Request Format

All MCP requests follow the JSON-RPC 2.0 specification:

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "tool_name",
    "arguments": {
      // Tool-specific arguments
    }
  },
  "id": 1
}
```

## Response Format

Successful responses:

```json theme={null}
{
  "jsonrpc": "2.0",
  "result": {
    // Tool-specific result
  },
  "id": 1
}
```

Error responses:

```json theme={null}
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32000,
    "message": "Error description"
  },
  "id": 1
}
```

## Available Methods

### tools/list

Lists all available tools for the server.

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "tools/list",
  "id": 1
}
```

### tools/call

Executes a specific tool.

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "execute_action_alloy",
    "arguments": {
      "connectorId": "slack",
      "actionId": "chat_postMessage",
      "parameters": {
        "channel": "#general",
        "text": "Hello!"
      }
    }
  },
  "id": 1
}
```

### resources/list

Lists available resources.

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "resources/list",
  "id": 1
}
```

### resources/read

Reads a specific resource.

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "resources/read",
  "params": {
    "uri": "resource://workflows/my-workflow"
  },
  "id": 1
}
```

### prompts/list

Lists available prompts.

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "prompts/list",
  "id": 1
}
```

### prompts/get

Gets a specific prompt.

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "prompts/get",
  "params": {
    "name": "workflow_builder"
  },
  "id": 1
}
```
