Guide6 min read
Build your first MCP tool in TypeScript and share it with your team
A Zenitya tool is a TypeScript function with a strict schema that every agent in your organization can call over MCP. Write one, run it locally, deploy it, grant it to a group and call it from Claude, ChatGPT, Cursor or Pi.
Jakub KotowskiCo-founder, Zenitya
A Zenitya tool is a TypeScript function with a strict input schema that every agent in your organization can call over MCP. Below we build one from scratch: write it, run it on your machine, deploy it, give it to a group and call it from Claude Code, Claude, ChatGPT, Cursor or Pi.
Most teams have a few workflows they ask an agent for every week. Find the late orders, pull a customer's invoices, check which campaign spent over budget. Each time the agent works the steps out again from a prompt. It reads the same docs, calls the same APIs in a slightly different order and spends tokens to reach an answer that should be the same as last week.
We built Zenitya around a simple alternative. You write the workflow once as a tool and every agent calls it. The tool does the same thing on every run, the model spends tokens only on deciding when to call it, and the whole team gets it through one MCP connection in the agent they already use.
What a Zenitya tool is
A tool has four parts: a name and description the model reads, an input schema, optional hints such as whether it only reads data, and an execute function. Tools live in a project, which is usually one repository, so billing tools sit next to billing code and go through the same pull requests. Agents see each tool as project.tool, for example order-tools.searchOrders.
Schemas are strict on purpose. Every property of an object is required and unknown properties are rejected. When a value can be missing you keep the property, mark it nullable and the model has to send null on purpose. A model that can leave fields out will at some point leave out the one that mattered, and a rejected call with a clear error is easier to recover from than a quiet wrong answer.
Install the CLI and sign in
The CLI is called zya, and zenitya works as the longer name. You need macOS or Linux and Bun 1.4 or newer.
curl -fsSL https://zenitya.dev/install.sh | sh
zya loginThe installer checks the release signature before it puts anything on your PATH. zya login opens Google sign-in in the browser and asks which organization to use. Zenitya is in private beta, so the first sign-in needs an invitation from zenitya.com/early-access.
Create a project
zya new order-tools
cd order-tools
bun installThis writes a zenitya.json, a package.json with @zenitya/sdk, a starter tool in src/index.ts and an AGENTS.md that points coding agents to the docs. The config is small:
{
"$schema": "https://zenitya.dev/schemas/project-v1.json",
"configVersion": 1,
"name": "order-tools",
"entrypoint": "src/index.ts"
}Write the tool
Replace the starter tool with something your team actually asks for. This one finds orders by status and calls a function that already exists in the repository:
import { Project } from "@zenitya/sdk";
import { s } from "@zenitya/sdk/schema";
import { findOrders } from "./orders";
const project = new Project();
export default project;
project.tool("searchOrders", {
title: "Search orders",
description: "Find orders by status, newest first. Returns at most `limit` orders.",
schema: s.object({
status: s.enum("open", "late", "shipped").describe("Order status to match."),
limit: s.integer().describe("How many orders to return, 1 to 50."),
}),
outputSchema: s.array(
s.object({
id: s.string(),
total: s.number(),
}),
),
hints: { readOnlyHint: true, idempotentHint: true },
execute: async ({ status, limit }, { logger, signal }) => {
logger.info({ status, limit }, "searching orders");
return findOrders(status, Math.min(limit, 50), signal);
},
});The enum gives the model exactly three valid statuses, so it cannot invent a fourth. The read-only and idempotent hints tell MCP clients that the call changes nothing and is safe to retry, so most clients will not ask for confirmation. The signal aborts when the call times out, so pass it on to anything that can be cancelled.
Run it locally
Before deploying, run the tool against the source on your machine. The input goes through the same schema validation as the deployed copy, so a bad input fails here first. Local runs also load .env from the project directory.
zya exec searchOrders --local --data '{"status":"late","limit":2}'
[{"id":"A-1042","total":31.5},{"id":"A-1039","total":112}]Deploy it
zya deployzya deploy uploads the source and Zenitya builds it remotely, so the result does not depend on whose laptop ran the command. The new version goes live only when every build step passes. A failed build leaves the previous version serving calls. Deploying needs an owner or admin role.
Deployed tools run in an isolated microVM per project with no internet access by default. If findOrders talks to a database or an API, turn on egress in zenitya.json and give the project its credentials as secrets. Each secret becomes an environment variable in the tool.
# in zenitya.json: "network": { "allowEgress": true }
zya secrets set DATABASE_URL --stdin < database-url.txt
zya deployGive it to a group
A deployed tool can be called only by the groups it is granted to. In the Zenitya app open Groups, pick a group and grant order-tools.searchOrders. Everyone is in the Default group, and owners and admins can create more, for example Support or Finance. Then call the deployed copy:
zya tools list
zya exec searchOrders --data '{"status":"late","limit":2}'Without --local, exec runs the deployed copy, which should return the same result you saw on your machine.
Call it from your agent
Every project's tools join one pool for the organization, served at one MCP endpoint: https://api.zenitya.com/mcp. In Claude Code adding it is one command:
claude mcp add --transport http --scope user zenitya https://api.zenitya.com/mcpRun /mcp in Claude Code, choose zenitya and sign in in the browser. The same URL works as a custom connector in Claude on web and desktop, as an MCP server in ChatGPT and Codex, in Cursor's mcp.json and in Pi. There is no key to copy. People sign in with OAuth and get the tools of every group they are in, while scripts, bots and cloud agents use a service account key with its own groups.
This is where a tool pays for itself. Without it an agent works the workflow out on every request: a few MCP calls, a throwaway script, a run, another try. In our own measurement of one task, the same workflow as one custom tool used 31% fewer tokens, cost 23% less and had 55% fewer failed calls. Each figure is the median of 3 runs each way.
Tell agents when to use it
A tool says what it does. A skill says how your team works and when to reach for which tool. Add a folder under skills/ with a SKILL.md, and zya deploy publishes it together with the tools:
---
name: chase-late-orders
description: Use when someone asks about late or delayed orders. Covers how to find them with order-tools.searchOrders and when to escalate to the warehouse team.
---
Call `order-tools.searchOrders` with status "late". Orders over 200 EUR go to
the warehouse channel, the rest get the standard delay email.Agents read skills through list_skills and load_skill on the same connection, and you grant them to groups like tools.
What to package first
- Something people ask an agent for at least weekly, where the steps are known and the answer should not change.
- Lookups across internal systems an agent cannot reach on its own, like a private database or an internal API.
- Anything where you caught an agent doing it slightly wrong, because a tool fixes it in one place for everyone.
Start with one tool and add the next one when someone asks an agent the same question twice.
Further reading
- Zenitya docs: Quickstart
- Zenitya docs: Writing tools
- Zenitya docs: Connecting agents over MCP
- Model Context Protocol: Specification: Tools
Jakub Kotowski is a co-founder and engineer at Zenitya, building the infrastructure that shares tools and skills across a whole team, in any agent or harness.
Jakub Kotowski on LinkedIn
zenitya