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

# Create Tool

> Creates a new tool in the environment.

## Endpoint

`POST https://gateway.orkeia.ai/tools`

**Authentication**\
Requires header `authorization:  <your_token>`.

## Request Body (JSON)

> The service expects a **wrapper** with the property `tool`. (The `environment` is handled on the server.)\
> **Note:** the field `type` **does not** exist in this interface. Use the fields defined in `Tool` (below).

```json theme={null}
{
  "tool": {
    "name": "My Tool",
    "description": "Tool description",
    "code": "export async function run(input){ return { ok: true }; }",
    "entryFunctionName": "run",
    "sectors": ["engineering", "legal"],
    "publisher": "Orkeia",
    "enabled": true,
    "environments": ["prod"],
    "mcp": {
      "url": "https://tools.orkeia.ai/my-tool",
      "transport": "sse"
    }
  }
}
```

## Example (cURL)

```bash theme={null}
curl -X POST "https://gateway.orkeia.ai/tools"   -H "authorization:  <your_token>"   -H "Content-Type: application/json"   -d '{
    "tool": {
      "name": "My Tool",
      "description": "Tool description",
      "code": "export async function run(input){ return { ok: true }; }",
      "entryFunctionName": "run",
      "sectors": ["engineering", "legal"],
      "publisher": "Orkeia",
      "enabled": true,
      "environments": ["prod"],
      "mcp": {
        "url": "https://tools.orkeia.ai/my-tool",
        "transport": "sse"
      }
    }
  }'
```

## Responses

### Response - Success

```json response theme={null}
{
  "status": "OK",
  "data": { "id": "TOOL_123456" }
}
```

### 500 — Server Error

```json theme={null}
{
  "status": "ERROR",
  "code": "server/error",
  "data": null
}
```

### 400 — Client Error

```json theme={null}
{
  "status": "ERROR",
  "code": "client/error",
  "data": null
}
```

## Reference Interface (`Tool`)

```ts theme={null}
export interface Tool {
  id?: string;
  name: string;
  description: string;
  code?: string;
  entryFunctionName?: string;
  sectors: string[];
  publisher: string;
  enabled: boolean;
  environments: string[];
  mcp?: {
    url: string;
    transport: 'sse' | 'streamable-http';
  };
}
```

## Fields

| Name              | Type                         | Required | Description                                                   | Example                                |
| ----------------- | ---------------------------- | -------- | ------------------------------------------------------------- | -------------------------------------- |
| id                | string                       | No       | Unique identifier (returned by the backend).                  | `TOOL_123456`                          |
| name              | string                       | Yes      | Name of the tool.                                             | `My Tool`                              |
| description       | string                       | Yes      | Short description of the functionality.                       | `Performs integration operations`      |
| code              | string                       | No       | Executable source code of the tool (when applicable).         | `export async function run(){...}`     |
| entryFunctionName | string                       | No       | Name of the exported function in `code` that will be invoked. | `run`                                  |
| sectors           | string\[]                    | Yes      | Authorized sectors to use the tool.                           | `["engineering","legal"]`              |
| publisher         | string                       | Yes      | Publisher/organization responsible.                           | `Orkeia`                               |
| enabled           | boolean                      | Yes      | Indicates if the tool is enabled.                             | `true`                                 |
| environments      | string\[]                    | Yes      | Environments in which the tool is available.                  | `["prod","staging"]`                   |
| mcp               | object                       | No       | Configuration for use via Model Context Protocol (MCP).       | `{ "url": "...", "transport": "sse" }` |
| mcp.url           | string                       | No       | URL of the MCP server.                                        | `https://tools.orkeia.ai/my-tool`      |
| mcp.transport     | `'sse' \| 'streamable-http'` | No       | Supported MCP transport type.                                 | `sse`                                  |
