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

# Creating a Tool

> A tool is a callable JavaScript function exposed over MCP. Write it yourself or let the AI Tool Builder generate it for you.

## What is a tool?

A **tool** is the fundamental unit of work in MCPCore. It has:

* A **name** — how the AI client identifies and calls it (e.g. `fetch_repo_stats`)
* A **description** — plain-language explanation of what the tool does; the AI uses this to decide when to call it
* **Parameters** — the typed inputs the AI passes at call time
* **Code** — the JavaScript that runs when the tool is invoked

When the AI connects to your server, it receives the full list of tools with their schemas. It then decides autonomously which tools to call, in what order, and with what parameters.

***

## Create a tool

<Steps>
  <Step title="Open the Tools section">
    On the server detail page, click the **Tools** tab, then click **New Tool**.
  </Step>

  <Step title="Name your tool">
    Choose a clear, descriptive name in **lowercase snake\_case**:

    | Good                 | Avoid              |
    | -------------------- | ------------------ |
    | `fetch_user_orders`  | `FetchUserOrders`  |
    | `send_slack_message` | `sendSlackMessage` |
    | `query_inventory_db` | `tool1`            |

    The name appears in the MCP schema and in your analytics dashboard. It cannot contain spaces or special characters.
  </Step>

  <Step title="Write a description">
    The description is critically important — it's what the AI reads to decide when to call your tool. Be specific.

    **Good description:**

    > Fetches the number of stars, forks, and primary language for a GitHub repository. Use when the user asks about repository statistics or open-source project metrics.

    **Weak description:**

    > Gets GitHub data.
  </Step>

  <Step title="Add parameters">
    Define the inputs your code will receive via `params.*`. See [Parameters](/tools/parameters) for the full schema reference.
  </Step>

  <Step title="Write the code">
    Write JavaScript in the [code editor](/tools/editor). The sandbox gives you access to `sdk`, `params`, `env`, and `console`. See [Sandbox](/tools/sandbox) for the complete API.

    Or use the **AI Tool Builder** to generate the code automatically — see below.
  </Step>

  <Step title="Save">
    Click **Save**. The tool is live immediately on your server's endpoint.
  </Step>
</Steps>

***

## AI Tool Builder

The **AI Tool Builder** lets you create tools by describing what you want in plain language. Instead of writing code manually, you describe the tool's purpose and MCPCore's AI generates the complete tool — including the name, parameters, and code.

### How it works

1. Open the tool editor and locate the **AI Assistant** panel on the right side
2. Type a description of what your tool should do (up to 2000 characters)
3. Click **Generate**
4. The AI produces:
   * A properly formatted `snake_case` tool name
   * Typed parameters with descriptions
   * Complete, working JavaScript code using `sdk.http()`, `sdk.db()`, or `sdk.lodash`
5. Review the generated code, make any adjustments, and save

### Example prompts

Try these to get started:

* `Fetch user profile from a PostgreSQL database using an email parameter`
* `Call a REST API endpoint and transform the JSON response`
* `Connect to MySQL, query a table with filters, and return paginated results`

### Generation limits

AI generation is available on supported plans. Each user can generate up to **20 tools per day**.

<Note>
  The AI Tool Builder uses Claude Sonnet 4 to generate code. Always review the generated code before saving — especially when the tool writes data or interacts with sensitive systems.
</Note>

***

## A minimal tool

```javascript theme={null}
// params.repo is a string like "anthropics/anthropic-sdk-python"
const res = await sdk.http({
  method: "GET",
  url: `https://api.github.com/repos/${params.repo}`,
  headers: {
    Authorization: `Bearer ${env.GITHUB_TOKEN}`,
  },
});

const data = JSON.parse(res.body());

return {
  stars:    data.stargazers_count,
  forks:    data.forks_count,
  language: data.language,
};
```

`sdk.http()` makes an HTTP request. `env.GITHUB_TOKEN` is a secret stored in the dashboard. `params.repo` is the value the AI passed at call time. The object you `return` is what the AI receives as the tool result.

***

## Tool limits

| Limit                | Value      |
| -------------------- | ---------- |
| Code size            | 100 KB     |
| Execution timeout    | 10 seconds |
| Memory per execution | 64 MB      |
| Parameters per tool  | 50         |

***

## Next steps

<CardGroup cols={2}>
  <Card icon="code" href="/tools/editor" title="Code Editor">
    Explore the VS Code-style editor with AI completions and integrated terminal.
  </Card>

  <Card icon="book" href="/tools/examples" title="Code Examples">
    Ready-to-use examples for HTTP, databases, Lodash, and more.
  </Card>

  <Card icon="terminal" href="/tools/sandbox" title="Sandbox API">
    Full reference for `sdk.http()`, `sdk.db()`, `env`, `params`, and `console`.
  </Card>

  <Card icon="list" href="/tools/parameters" title="Parameters">
    Define typed, validated inputs for your tools.
  </Card>

  <Card icon="lock" href="/tools/secrets" title="Secrets">
    Store and reference API keys and credentials securely.
  </Card>

  <Card icon="play" href="/tools/testing" title="Testing">
    Run tools with real parameters from the dashboard's Run panel.
  </Card>
</CardGroup>
