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

# Extend and customize tools

> Extend catalog tools or build custom

Create custom tools, or extend a catalog tool, to build exactly what your agent needs.

## Extend a catalog tool

Use `nango pull` to fetch tools from the catalog into your [Nango functions project](https://nango.dev/docs/guides/platform/functions/functions-guide.md#build-locally-with-the-cli).

For example, to fetch GitHub's `get-repository` tool:

```bash theme={null}
nango pull --catalog github get-repository
```

The CLI adds the tool's source to your project and imports it from `index.ts`. From there you can edit it by following the steps in [create a custom tool](#create-a-custom-tool).

Nango updates catalog tools automatically, which can change what they accept or return. For backend calls, use `nango pull --catalog` and deploy the copy as a custom tool. You can deploy it as-is. Your integration uses the version you deployed, and you decide when to update it.

## Create a custom tool

First, [set up a Nango functions project](https://nango.dev/docs/guides/platform/functions/functions-guide.md#build-locally-with-the-cli). This example defines a tool that creates a GitHub issue.

```typescript github/tools/create-issue.ts theme={null}
import { createTool, scopes } from 'nango';
import * as z from 'zod';

export default createTool({
    description: 'Creates a GitHub issue',
    input: z.object({
        owner: z.string(),
        repo: z.string(),
        title: z.string(),
        body: z.string().optional()
    }),
    output: z.object({ id: z.number(), url: z.string().url() }),
    meta: {
        instructions: 'Use when the user asks to create an issue. Confirm the repository and title first.',
        requiredScopes: scopes.any('repo', 'public_repo'),
        tags: { read_only_hint: 'true', destructive_hint: 'false', idempotent_hint: 'false' }
    },
    exec: async (nango, { input }) => {
        const { owner, repo, title, body } = input;
        const response = await nango.post({
            endpoint: `/repos/${owner}/${repo}/issues`,
            data: { title, body }
        });
        return { id: response.data.id, url: response.data.html_url };
    }
});
```

Import the tool from your project's root `index.ts`:

```typescript index.ts theme={null}
import './github/tools/create-issue';
```

* The tool name defaults to its filename without the extension. In this example, the name is `create-issue`.
* Read the tool's arguments from `input`. Nango validates them against your input schema before running the tool.
* Use `meta.requiredScopes` to describe the provider permissions the tool needs. Use `scopes.all(...)`, `scopes.any(...)`, or `scopes.none()`. The field is informational and not enforced by Nango.
* Use `meta.tags` to annotate the tool with labels such as its category or operation type (read, write, potentially destructive, etc.).
  * Nango catalog tools use `read_only_hint`, `destructive_hint`, and `idempotent_hint` to indicate whether a tool is read-only, can make destructive changes, or can be repeated with the same effect.

See the [`createTool` SDK reference](https://nango.dev/docs/reference/functions/functions-sdk#createtool) for all options.

To fail a tool call, throw `new nango.Error(...)` inside `exec`. Nango returns your error message to the caller. In an agent session, the agent receives the message, so explain what went wrong and what it can do next.

```typescript theme={null}
throw new nango.Error({
    code: 'repository_not_allowed',
    message: 'Issue creation is disabled for this repository. Ask the user to choose an approved repository.',
    repository: `${owner}/${repo}`
});
```

For details on error messages and response format, see [Errors in the Functions SDK](https://nango.dev/docs/reference/functions/functions-sdk.md#nango-error).

## Test and deploy

Create a test connection in the **Connections** tab, then dry run the tool with realistic input:

```bash theme={null}
nango dryrun create-issue '<CONNECTION-ID>' -e dev --input '{"owner":"NangoHQ","repo":"interactive-demo","title":"Bug report"}' --validate
nango deploy dev github/tools/create-issue.ts
```

A dry run calls real provider APIs and can create or change data. See [Testing](https://nango.dev/docs/guides/platform/functions/testing.md) and [CI/CD](https://nango.dev/docs/guides/platform/functions/ci-cd.md).

## Call a custom tool

Once deployed, [call a custom tool from your agent or backend](https://nango.dev/docs/guides/tools/overview.md#call-tools) the same way you call a catalog tool.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.