---
title: ".serve()"
description: "Mount the agent's MCP server on its fetch-native Hono application."
---

> Documentation Index
> Fetch the complete documentation index at: https://xsaf.ilha.build/llms.txt
> Use this file to discover all available pages before exploring further.

# .serve()

## Signature

```ts
agent.serve(config?: ServeConfig): XsafAgent
```

`.serve()` configures MCP serving without opening a socket.

## Usage

```ts
agent.serve({
  path: "/mcp",
  name: "support_agent",
  version: "0.1.0",
});
```

The built-in server uses HTTP. The path defaults to `/mcp`; the name defaults to the configured agent name and then `xsaf`; the version defaults to XSAF's package version.

## Fetch-native hosting

The agent always owns a Hono app with `GET /health` and `POST /invoke`. Pass `agent.fetch` to srvx, a Node adapter, Workers, or another compatible fetch-native host. XSAF mounts routes but does not own the listener.

Call `.serve()` at most once. An optional `driver` can replace the built-in MCP mounting implementation. See [MCP](/xsaf/mcp) for protocol and security details.

Source: https://xsaf.ilha.build/xsaf/serve/index.mdx
