Getting Started
Quick Start
Get started with Surf in under 20 lines
Quick Start#
A complete Express server with Surf commands in under 20 lines:
typescript
import { createSurf } from '@surfjs/core'import express from 'express'ย const surf = await createSurf({ name: 'My Store', commands: { search: { description: 'Search products', params: { query: { type: 'string', required: true }, limit: { type: 'number', default: 10 }, }, run: async ({ query, limit }) => { return db.products.search(query, { limit }) }, }, },})ย const app = express()app.use(surf.middleware())app.listen(3000)Now any AI agent can discover and use your commands:
typescript
import { SurfClient } from '@surfjs/client'ย const client = await SurfClient.discover('http://localhost:3000')ย // List available commandsconsole.log(client.commands())// => { search: { description: 'Search products', params: {...} } }ย // Execute a commandconst result = await client.execute('search', { query: 'laptop' })// => { results: [...], total: 42 }