<a id="flink-sql-create-tool"></a>

# CREATE TOOL Statement in Confluent Cloud for Apache Flink

Confluent Cloud for Apache Flink® enables creating tool resources that can be used by AI agents.
Tools can be either [user-defined functions](../../concepts/user-defined-functions.md#flink-sql-udfs) or external
tools accessed by using connection resources. For more information, see
[Call Tools in AI Workflows](../../../ai/streaming-agents/call-tools.md#streaming-agents-call-tools).

## Syntax

```sql
CREATE TOOL [IF NOT EXISTS] [[catalog.]database.]tool_name
[
  USING FUNCTION <function_identifier>
|
  USING CONNECTION <connection_identifier>
]
[COMMENT <comment_string>]
WITH (<option_list>)
```

## Description

Create a new tool resource that can be referenced by AI agents. Tools can be
either Flink user-defined functions or external MCP servers accessed by using
connections.

## Tool types

### Function tools

Tools that wrap Flink user-defined functions:

```sql
CREATE TOOL convert_to_celsius_tool
USING FUNCTION convert_to_celsius
WITH (
  'type' = 'function',
  'description' = 'This function can be used by model to convert degree to celsius'
);
```

### Connection tools

Tools that access external MCP servers or A2A servers by using connections:

```sql
CREATE TOOL mcp_server
USING CONNECTION mcp_connection
WITH (
  'type' = 'mcp',
  'allowed_tools' = 'tool1,tool2',
  'request_timeout' = '30'
);
```

## MCP tool options

- **type**: Tool type (‘function’ or ‘mcp’ or ‘a2a’) (Required)
- **allowed_tools**: Comma-separated list of allowed tools (MCP only, Required)
- **description**: Human-readable description (Optional)
- **request_timeout**: Request timeout for external tools (Optional, default: ‘30’)

## Examples

Create a function tool:

```sql
CREATE FUNCTION convert_to_celsius
USING JAR 'celsius.jar'
COMMENT 'function to convert degree to celsius';

CREATE TOOL convert_to_celsius_tool
USING FUNCTION convert_to_celsius
WITH (
  'type' = 'function',
  'description' = 'Convert temperature from Fahrenheit to Celsius'
);
```

Create an MCP tool:

```sql
CREATE CONNECTION mcp_connection
WITH (
  'type' = 'mcp_server',
  'api-key' = '<your-api-key>',
  'endpoint' = 'https://mcp.example.com',
);

CREATE TOOL mcp_server
USING CONNECTION mcp_connection
WITH (
  'type' = 'mcp',
  'allowed_tools' = 'weather_api,calculator',
  'request_timeout' = '60'
);
```

## Related content

- [ALTER TOOL Statement](alter-tool.md#flink-sql-alter-tool)
- [Call Tools in AI Workflows](../../../ai/streaming-agents/call-tools.md#streaming-agents-call-tools)
- [CREATE AGENT Statement](create-agent.md#flink-sql-create-agent)
- [CREATE FUNCTION Statement](create-function.md#flink-sql-create-function)
- [CREATE CONNECTION Statement](create-connection.md#flink-sql-create-connection)
- [DROP TOOL Statement](drop-tool.md#flink-sql-drop-tool)
- [SHOW TOOLS Statement](show.md#flink-sql-show-tools)

#### NOTE
This website includes content developed at the [Apache Software Foundation](https://www.apache.org/)
under the terms of the [Apache License v2](https://www.apache.org/licenses/LICENSE-2.0.html).
