Getting Started
Use dashboard or CLI to deploy your first function, then verify execution and logs through the same control plane.
Step-by-Step Guide
1.Create a function in dashboard
Start in /dashboard/new, set slug/metadata, and write a small main function.
- Draft changes are editable before deployment.
- Add required secrets in function settings before first production run.
typescript
import fn, { secret } from "@hostfunc/sdk";export async function main(input: { name?: string }) { const token = await secret.getRequired("INTERNAL_API_TOKEN"); return { ok: true, greeting: `hello ${input.name ?? "world"}`, tokenLoaded: Boolean(token) };}2.Deploy and invoke
Deploy creates an immutable version and updates the function pointer used by runtime dispatch.
- Invoke over HTTP at
/run/:orgSlug/:fnSlug. - If HTTP trigger requires auth, pass a workspace API token.
typescript
curl -X POST "https://run.hostfunc.io/run/acme/invoice-sync" \ -H "content-type: application/json" \ -d '{"invoiceId":"inv_123"}'3.Set up CLI for repeatable deploys
CLI maps directly to /api/cli/* routes and uses API token auth.
- Credentials are stored under
~/.hostfuncby default. - Project defaults live in
hostfunc.json.
bash
npm install -g @hostfunc/clihostfunc login --token <api-token> --url http://localhost:3000hostfunc init --fnId <fn_id>hostfunc deployhostfunc run --payload ./payload.jsonhostfunc logs --executionId <execution_id>4.Connect MCP clients when needed
Use /api/mcp with bearer token auth for AI/editor tool access.
- Methods implemented:
initialize,tools/list,tools/call,ping. - Tools implemented:
functions.*,executions.*.
json
{ "mcpServers": { "hostfunc": { "command": "npx", "args": [ "-y", "mcp-remote", "http://localhost:3000/api/mcp", "--header", "Authorization: Bearer <api-token>" ] } }}