> For the complete documentation index, see [llms.txt](https://docs.callumg.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.callumg.net/server/server-callbacks.md). Agents can also search and read this documentation through its [MCP server](https://docs.callumg.net/~gitbook/mcp).

# Server Callbacks

Allows for callbacks initiated from the client used to return information to a client from the server.

## `RegisterServerCallback(name, func)`

Registers a callback on the server-side ready to be called from a client.

* name<mark style="color:red;">\*</mark> (string) - uniquely identifying name of the callback
* func<mark style="color:red;">\*</mark> (function (source, callback, ...) ) - function to call when the callback is called. All optional arguments sent from the client will be the optional arguments of this function.

<mark style="color:red;">\*</mark> = required arguments

Example (paired with the client-side example):

```lua
FOM.RegisterServerCallback('test', function(source, cb, s1, s2)
    print(s1 .. ' ' .. s2)
    cb('hello', 1)
end)
```

See [Server Callbacks on the client-side](https://docs.callumg.net/client/server-callbacks.md) for triggering a callback.

Reference: `utils/sv_callback.lua`
