***

title: AgentServer
slug: /reference/typescript/agents/agent-server
description: Host multiple AI agents on a single Hono HTTP server with shared routing and health checks.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base

[agentbase-serve]: /docs/server-sdks/reference/typescript/agents/agent-base/serve

[agentbase-run]: /docs/server-sdks/reference/typescript/agents/agent-base/run

[getagent]: /docs/server-sdks/reference/typescript/agents/agent-server/get-agent

[getagents]: /docs/server-sdks/reference/typescript/agents/agent-server/get-agents

[register]: /docs/server-sdks/reference/typescript/agents/agent-server/register

[run]: /docs/server-sdks/reference/typescript/agents/agent-server/run

[servestaticfiles]: /docs/server-sdks/reference/typescript/agents/agent-server/static-files

[unregister]: /docs/server-sdks/reference/typescript/agents/agent-server/unregister

`AgentServer` hosts multiple [`AgentBase`][agentbase] instances
on a single Hono HTTP server. Each agent registers at its own URL route, and the server
provides unified health monitoring and static file serving. Use `AgentServer` when you
have several related agents (sales, support, billing) that share the same deployment.

For a single agent, use [`AgentBase.serve()`][agentbase-serve]
or [`AgentBase.run()`][agentbase-run] instead.

## **Constructor**

```typescript {3}
import { AgentServer } from '@signalwire/sdk';

const server = new AgentServer({ host: '0.0.0.0', port: 3000 });
```

### Constructor Parameters

<ParamField path="opts" type="object" toc={true}>
  Optional server configuration.
</ParamField>

<Indent>
  <ParamField path="opts.host" type="string" default="0.0.0.0" toc={true}>
    Hostname the server binds to.
  </ParamField>

  <ParamField path="opts.port" type="number" default="3000" toc={true}>
    Port the server listens on. Also reads from the `PORT` environment variable.
  </ParamField>
</Indent>

## **Properties**

<ParamField path="host" type="string" toc={true}>
  The hostname the server binds to.
</ParamField>

<ParamField path="port" type="number" toc={true}>
  The port the server listens on.
</ParamField>

## **Methods**

<CardGroup cols={3}>
  <Card title="getAgent" href="/docs/server-sdks/reference/typescript/agents/agent-server/get-agent">
    Retrieve a specific registered agent by its route.
  </Card>

  <Card title="getAgents" href="/docs/server-sdks/reference/typescript/agents/agent-server/get-agents">
    Return all registered agents as a Map.
  </Card>

  <Card title="register" href="/docs/server-sdks/reference/typescript/agents/agent-server/register">
    Register an agent at a URL route on the server.
  </Card>

  <Card title="run" href="/docs/server-sdks/reference/typescript/agents/agent-server/run">
    Start the multi-agent HTTP server.
  </Card>

  <Card title="serveStaticFiles" href="/docs/server-sdks/reference/typescript/agents/agent-server/static-files">
    Serve static files from a directory alongside agent routes.
  </Card>

  <Card title="unregister" href="/docs/server-sdks/reference/typescript/agents/agent-server/unregister">
    Remove an agent from the server's registry by route.
  </Card>

  <Card title="getApp" href="/docs/server-sdks/reference/typescript/agents/agent-server/get-app">
    Get the fully configured Hono application.
  </Card>
</CardGroup>

## **Example**

```typescript {11-14}
import { AgentBase, AgentServer } from '@signalwire/sdk';

const salesAgent = new AgentBase({ name: 'sales-agent', route: '/sales' });
salesAgent.addLanguage({ name: 'English', code: 'en-US', voice: 'rime.spore' });
salesAgent.promptAddSection('Role', { body: 'You are a sales representative.' });

const supportAgent = new AgentBase({ name: 'support-agent', route: '/support' });
supportAgent.addLanguage({ name: 'English', code: 'en-US', voice: 'rime.spore' });
supportAgent.promptAddSection('Role', { body: 'You are a support specialist.' });

const server = new AgentServer({ host: '0.0.0.0', port: 3000 });
server.register(salesAgent, '/sales');
server.register(supportAgent, '/support');
await server.run();
```

After starting, agents are available at:

| Endpoint                        | Description     |
| ------------------------------- | --------------- |
| `http://localhost:3000/sales`   | Sales agent     |
| `http://localhost:3000/support` | Support agent   |
| `http://localhost:3000/health`  | Health check    |
| `http://localhost:3000/ready`   | Readiness check |