# MCP

The NLX MCP Interface exposes your AI app's capabilities as standard [Model Context Protocol](https://modelcontextprotocol.io/) tools. This allows external Agents, LLMs, and MCP-compliant clients to discover and execute actions defined within your NLX deployment.

### When to use this API

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><i class="fa-brain-circuit">:brain-circuit:</i></td><td><strong>Agent integration</strong></td><td>Allow autonomous agents (like AutoGen or LangChain agents) to use your NLX app as a toolkit</td></tr><tr><td><i class="fa-head-side-gear">:head-side-gear:</i></td><td><strong>Tool discovery</strong></td><td>Dynamically query what your AI app can do (e.g., "CheckInventory", "ResetPassword") and retrieve the schema for those actions</td></tr></tbody></table>

### Configuration

| Setting      | Value                                                                   |
| ------------ | ----------------------------------------------------------------------- |
| **Base URL** | `https://apps.nlx.ai/c/mcp/{deploymentKey}/{channelKey}-{languageCode}` |
| **Header**   | `nlx-api-key: YOUR_API_KEY`                                             |

{% hint style="info" %}
As with other endpoints, append the language code (e.g., `-en-US`) to the channel key.
{% endhint %}

#### 1. List available tools (`GET`)

Retrieve a list of all tools exposed by this deployment, including their names, descriptions, and JSON schemas for arguments.

**Endpoint:** `GET /tools`

```bash
curl -X GET "https://apps.nlx.ai/c/mcp/xxxx/xxxx-en-US/tools" \
  -H "nlx-api-key: YOUR_API_KEY"
```

**Response example:**

```json
{
  "tools": [
    {
      "name": "check_order_status",
      "description": "Retrieves the status of a customer order",
      "inputSchema": {
        "type": "object",
        "properties": {
          "orderId": { "type": "string" }
        },
        "required": ["orderId"]
      }
    }
  ]
}
```

#### 2. Execute a tool (`POST`)

Invoke a specific tool by name. You pass the arguments defined in the tool's schema.

**Endpoint:** `POST /tools/{toolName}`

**Standard execution (JSON)**

Useful for single, synchronous results.

```bash
curl -X POST "https://apps.nlx.ai/c/mcp/xxxx/xxxx-en-US/tools/check_order_status" \
  -H "nlx-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "arguments": {
      "orderId": "ORD-12345"
    }
  }'
```

**Response example:**

```json
{
  "content": [
    {
      "type": "text",
      "text": "Order ORD-12345 is currently in transit."
    }
  ],
  "isError": false
}
```

**Streaming execution (SSE)**

If a tool produces long-running output or you want real-time feedback, enable streaming.

```bash
curl -N -X POST "https://apps.nlx.ai/c/mcp/xxxx/xxxx-en-US/tools/generate_report" \
  -H "nlx-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "stream": true,
    "arguments": { "year": 2024 }
  }'
```

**Response example:** Returns `text/event-stream` chunks prefixed with `data:`.

```
data: {"content": [{"type": "text", "text": "Generating report..."}]}

data: {"content": [{"type": "text", "text": " Q1 Data analyzed."}]}
```
