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

# Model Context Protocol Tools

> Create, drop, export, and call Model Context Protocol (MCP) tools that expose database operations to AI clients in Ocient.

export const Ocient = "Ocient®";

A Model Context Protocol (MCP) tool is a database object in the {Ocient} System that exposes a predefined operation to Model Context Protocol clients, such as AI agents. Each MCP tool has a name, a set of typed arguments, a description, and a definition that the system executes when a client calls the tool. The description helps a client decide when to call the tool.

The system supports two types of MCP tools:

* System Tools — Built-in tools that ship with the database. System tools belong to the `sys` schema, are always visible to every user, and cannot be dropped.
* User-Defined Tools — Tools that you create with the `CREATE MCP TOOL` SQL statement. User-defined tools follow the standard object privilege rules.

Each MCP tool belongs to a toolset, which is a label that groups related tools so that a client can list and select tools by toolset. You can view all MCP tools in the system in the [`sys.mcp_tools`](/system-catalog#model-context-protocol) system catalog table.

## CREATE MCP TOOL

Creates a user-defined MCP tool. When you specify the `OR REPLACE` clause and the tool already exists, the system replaces the existing tool definition.

**Privileges**

To create an MCP tool, you must have the `CREATE` privilege. The user who creates the tool inherits all privileges on the tool. For details, see the [Data Control Language (DCL) Statement Reference](/data-control-language-dcl-statement-reference).

**Syntax**

```sql SQL theme={null}
CREATE [ OR REPLACE ] MCP TOOL [ IF NOT EXISTS ] tool_name
    [ ( argument_name data_type [ NOT NULL ] [, ...] ) ]
    DESCRIPTION 'description'
    TOOLSET 'toolset'
    AS BEGIN TOOL
        tool_body
    END TOOL;
```

| **Parameter** | **Type** | **Description** |
| - | - | - |
| `tool_name` | Identifier | The name of the MCP tool. You can qualify the name with a database and schema. For details, see [Identifiers](/identifiers). |
| `argument_name` | Identifier | The name of an argument that the tool accepts. Reference an argument in the tool body with the `@argument_name` syntax. |
| `data_type` | String | The data type of the argument. Specify `NOT NULL` to require a value for the argument. |
| `description` | String | A description of what the tool does. A client uses this description to determine when to call the tool. |
| `toolset` | String | The name of the toolset where the tool belongs. The name can contain spaces. |
| `tool_body` | String | The SQL statement that the system executes when a client calls the tool. The body must include a `RETURN` clause with a `SELECT` statement and can reference arguments with the `@argument_name` syntax. |

**Example**

This example creates the `show_tables` MCP tool, which lists the user-defined tables in a schema. The tool belongs to the `System Information` toolset and accepts an optional `schema` argument.

```sql SQL theme={null}
CREATE MCP TOOL show_tables(schema VARCHAR)
    DESCRIPTION 'Lists the user-defined tables within a schema'
    TOOLSET 'System Information'
    AS BEGIN TOOL
        RETURN SELECT * FROM information_schema.tables
            WHERE table_schema NOT IN ('sys', 'information_schema')
            AND table_type = 'BASE TABLE'
            AND (@schema IS NULL OR table_schema = @schema);
    END TOOL;
```

## CALL MCP TOOL

Executes an MCP tool and returns its result set.

**Privileges**

To call an MCP tool, you must have the `EXECUTE` privilege on the tool. By default, every user can call system tools.

**Syntax**

```sql SQL theme={null}
CALL MCP TOOL tool_name [ ( argument_value [, ...] ) ];
```

| **Parameter** | **Type** | **Description** |
| - | - | - |
| `tool_name` | Identifier | The name of the MCP tool to call. |
| `argument_value` | Any | A value to pass to the corresponding tool argument. |

**Example**

This example calls the `show_tables` MCP tool for the `public` schema.

```sql SQL theme={null}
CALL MCP TOOL show_tables('public');
```

## DROP MCP TOOL

Drops a user-defined MCP tool. You cannot drop a system tool. When you specify the `IF EXISTS` clause and the tool does not exist, the system does not return an error.

**Privileges**

To drop an MCP tool, you must have the `DROP` privilege on the tool.

**Syntax**

```sql SQL theme={null}
DROP MCP TOOL [ IF EXISTS ] tool_name;
```

| **Parameter** | **Type** | **Description** |
| - | - | - |
| `tool_name` | Identifier | The name of the MCP tool to drop. |

**Example**

This example drops the `show_tables` MCP tool.

```sql SQL theme={null}
DROP MCP TOOL show_tables;
```

## EXPORT MCP TOOL

Returns the `CREATE MCP TOOL` SQL statement that recreates a user-defined MCP tool.

**Privileges**

To export an MCP tool, you must have the `VIEW` privilege on the tool.

**Syntax**

```sql SQL theme={null}
EXPORT MCP TOOL tool_name;
```

| **Parameter** | **Type** | **Description** |
| - | - | - |
| `tool_name` | Identifier | The name of the MCP tool to export. |

**Example**

This example exports the `show_tables` MCP tool.

```sql SQL theme={null}
EXPORT MCP TOOL show_tables;
```

### Related Links

[Ocient MCP Server](/ocient-mcp-server)

[Data Control Language (DCL) Statement Reference](/data-control-language-dcl-statement-reference)

[System Catalog](/system-catalog#model-context-protocol)

[Identifiers](/identifiers)
