> ## Documentation Index
> Fetch the complete documentation index at: https://redop.useagents.site/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Basic Server Example

> Start from the smallest Redop HTTP server with a health tool and a simple typed echo tool.

Use this example when you want the smallest useful Redop server.

## What it shows

* `serverInfo` for MCP-facing metadata
* a no-input `ping` tool
* a JSON-Schema-style `echo` tool
* HTTP transport startup with `.listen(3000)`

## Full code

```ts theme={null}
import { Redop } from "../src/index";

new Redop<{ startedAt?: number }>({
  serverInfo: {
    name: "redop",
    title: "Redop",
    description: "Hello mcp world",
  },
})
  .onBeforeHandle(({ ctx }) => {
    ctx.startedAt = performance.now();
  })
  .tool("ping", {
    description: "Health check",
    handler: () => ({ pong: true, ts: Date.now() }),
  })
  .tool("echo", {
    handler: ({ input }) =>
      typeof input.message === "string"
        ? input.message.toUpperCase()
        : input.message,
    inputSchema: {
      type: "object",
      properties: { message: { type: "string" } },
      required: ["message"],
    },
  })
  .listen(3000);
```

## Why this example is useful

* the constructor uses `serverInfo` instead of the older top-level metadata fields
* `onBeforeHandle(...)` adds request-scoped timing data
* the server exposes `ping` and `echo` over HTTP at `/mcp`

## Run it

```sh theme={null}
bun run packages/redop/examples/basic.ts
```

## Related pages

* [Your first server](/docs/getting-started/first-server)
* [Connect over HTTP](/docs/getting-started/connect-http)
* [Redop API Reference](/docs/reference/redop)
