Server tools
Server tools run on your backend. Use them for database access, secrets, and actions that need server-side permission checks.patchsmith.ts
createServer. Your readMember function should check access using the verified scope:
Server handler
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
createClient configuration:
Client handlers
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
Importtool 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.Can a client tool access my database directly?
Can a client tool access my database directly?
Put database access in a server tool. Client tools run in the browser and
use the frontend APIs you explicitly provide.
Does input validation replace permission checks?
Does input validation replace permission checks?
No. Validation checks the shape of the data. Your server handler must still
check whether the verified identity and scope can perform the operation.