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

# Platform API

> Reference for the Tydli Platform API

# Tydli Platform API Reference

The Tydli Platform API allows you to manage your deployments and OAuth clients programmatically.

## Base URL

All API requests should be made to:

```
https://your-project.supabase.co/functions/v1
```

## Authentication

Most endpoints require authentication. You can authenticate using:

* **Bearer Token**: `Authorization: Bearer <your-jwt-token>`

## OAuth 2.1 Server

Endpoints for managing OAuth clients and performing OAuth flows.

### Register Client

Register a new OAuth client for your deployment.

* **Endpoint**: `POST /mcp-oauth-server/register`
* **Content-Type**: `application/json`

**Request Body:**

```json theme={null}
{
  "client_name": "My Client",
  "redirect_uris": ["http://localhost:3000/callback"],
  "scope": "openid email"
}
```

**Response:**

```json theme={null}
{
  "client_id": "mcp_...",
  "client_secret": "secret_...",
  "client_name": "My Client",
  "redirect_uris": ["..."]
}
```

### Authorization Endpoint

The URL to redirect users to for authorization.

* **URL**: `GET /mcp-oauth-server/authorize`
* **Parameters**:
  * **INLINE\_CODE\_4**: Your client ID
  * **INLINE\_CODE\_5**: **INLINE\_CODE\_6**
  * **INLINE\_CODE\_7**: One of your registered redirect URIs
  * **INLINE\_CODE\_8**: PKCE code challenge
  * **INLINE\_CODE\_9**: **INLINE\_CODE\_10**
  * **INLINE\_CODE\_11**: Random string for CSRF protection

### Token Endpoint

Exchange an authorization code for an access token.

* **URL**: `POST /mcp-oauth-server/token`
* **Content-Type**: `application/json`

**Request Body:**

```json theme={null}
{
  "grant_type": "authorization_code",
  "code": "auth_code_from_callback",
  "redirect_uri": "http://localhost:3000/callback",
  "client_id": "your_client_id",
  "code_verifier": "pkce_code_verifier"
}
```

## MCP Router

Endpoints for interacting with your deployed MCP servers.

### Invoke Tool

Call a tool on your deployed MCP server.

* **Endpoint**: `POST /mcp-router/{deployment_slug}/messages`
* **Headers**:
  * **INLINE\_CODE\_15**: **INLINE\_CODE\_16**

**Request Body:**

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

### List Resources

List all resources defined for a deployment.

* **Endpoint**: `POST /mcp-router/{deployment_slug}/messages`

**Request Body:**

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

**Response:**

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "resources": [
      {
        "uri": "file://config.json",
        "name": "config",
        "title": "Configuration",
        "description": "Application configuration",
        "mimeType": "application/json"
      }
    ],
    "nextCursor": null
  }
}
```

### Read Resource

Read content of a specific resource by URI.

* **Endpoint**: `POST /mcp-router/{deployment_slug}/messages`

**Request Body:**

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "resources/read",
  "params": {
    "uri": "file://config.json"
  },
  "id": 1
}
```

**Response:**

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "contents": [
      {
        "uri": "file://config.json",
        "mimeType": "application/json",
        "text": "{\"key\": \"value\"}"
      }
    ]
  }
}
```

### List Prompts

List all prompts defined for a deployment.

* **Endpoint**: `POST /mcp-router/{deployment_slug}/messages`

**Request Body:**

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

**Response:**

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "prompts": [
      {
        "name": "summarize",
        "title": "Summarize Document",
        "description": "Summarize a document in a specific language",
        "arguments": [
          {"name": "content", "required": true},
          {"name": "language", "required": false}
        ]
      }
    ],
    "nextCursor": null
  }
}
```

### Get Prompt

Get a specific prompt and render its template with arguments.

* **Endpoint**: `POST /mcp-router/{deployment_slug}/messages`

**Request Body:**

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "prompts/get",
  "params": {
    "name": "summarize",
    "arguments": {
      "content": "This is the document text...",
      "language": "English"
    }
  },
  "id": 1
}
```

**Response:**

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "description": "Summarize a document in a specific language",
    "messages": [
      {
        "role": "user",
        "content": {
          "type": "text",
          "text": "Please summarize this in English:\n\nThis is the document text..."
        }
      }
    ]
  }
}
```

## Discovery

### Protected Resource Metadata

Discover OAuth configuration for a resource.

* **Endpoint**: `GET /mcp-router/{deployment_slug}/.well-known/oauth-protected-resource`

**Response:**

```json theme={null}
{
  "resource": "https://...",
  "authorization_servers": ["https://..."],
  "scopes_supported": ["openid", "email", "mcp.tools.execute"]
}
```
