Skip to main content
A tool exposes one of your product’s functions to apps. You define its input and output schemas and implement it in your frontend or backend. For example, a client tool can show a message using your toast library, open a dialog, or navigate to a page. A server tool can fetch a member, save a record, or call an external API using your existing backend code.

Server tools

Server tools run on your backend. Use them for database access, secrets, and actions that need server-side permission checks.
patchsmith.ts
Register the handler in createServer. Your readMember function should check access using the verified scope:
Server handler
Pass this tools object to createServer({ contract, tools, ... }) alongside your authentication configuration. See Installation.

Client tools

Client tools run in your frontend. Use them for actions such as showing a toast, opening a dialog, or navigating. Add a client tool alongside the server tool:
Inside your contract's tools
Implement it in your existing createClient configuration:
Client handlers
Here, toast is your toast library. The handler needs no output schema because it returns no value. Keep credentials and privileged operations on the server. See Write app UI for calling tools from UI.

SDK reference

Import tool and defineContract from patchsmith. Register server handlers with createServer from patchsmith/server, and client handlers with createClient from patchsmith/react. Handlers receive { input, context } and can return a value or a promise. input is the validated argument. context includes the verified installation identity, scope, and request ID.
identity includes installation, app, project, and deployment IDs, plus the required authenticated subjectId and an expiry. scope has a name and its scoped values. Apply your permission checks in the handler. Tools can be nested in objects, such as tools.members.read.

Frequently asked questions

Keep privileged operations on the server and check permissions separately from input validation.
Put database access in a server tool. Client tools run in the browser and use the frontend APIs you explicitly provide.
No. Validation checks the shape of the data. Your server handler must still check whether the verified identity and scope can perform the operation.