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

# ConfigValidator

> Pure validation for TelemetryConfig — throws on bad input.

```ts theme={null}
class ConfigValidator {
  static validate(config: TelemetryConfig): void
}
```

A small static class that asserts a `TelemetryConfig` is well-formed. Used
internally by `TelemetryManager`'s constructor — exposed publicly so you can
validate configs in tests, CLIs, or at deploy time.

## Method

### `validate(config: TelemetryConfig): void`

Throws on invalid input. Returns nothing on success.

## Rules enforced

| Rule                                                             | Error message                                              |
| ---------------------------------------------------------------- | ---------------------------------------------------------- |
| `exporterEndpoint` required unless `exporterType: 'console'`     | `exporterEndpoint is required`                             |
| `samplingRate` must be in `[0, 1]` (when set)                    | `samplingRate must be between 0 and 1`                     |
| `metricExportIntervalMs` must be `> 0` (when set)                | `metricExportIntervalMs must be >0`                        |
| `batchTimeoutMs` must be `>= 0` (when set)                       | `batchTimeout must be >=0`                                 |
| `exporterAuth.type === 'bearer'` requires `token`                | `Bearer token is required when using bearer auth`          |
| `exporterAuth.type === 'apiKey'` requires `apiKey`               | `API key is required when using apiKey auth`               |
| `exporterAuth.type === 'basic'` requires `username` + `password` | `Username and password are required when using basic auth` |

## Example

```ts theme={null}
import { ConfigValidator } from '@sedata-ai/mcp'

try {
  ConfigValidator.validate({
    serverName: 'my-server',
    serverVersion: '1.0.0',
    samplingRate: 1.5,
  })
} catch (err) {
  console.error('Bad config:', (err as Error).message)
  // → Bad config: samplingRate must be between 0 and 1
}
```

## Use cases

<CardGroup cols={2}>
  <Card title="Config tests" icon="vial">
    Assert your environment-driven config is valid in unit tests.
  </Card>

  <Card title="Bootstrap script" icon="rocket">
    Fail fast at deploy time before connecting any transports.
  </Card>
</CardGroup>
