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

# How do I generate a new token for my MCP server?

> Understand the critical workflow to secure your Model Context Protocol runtime via authenticating tokens.

# Generating a Server Token

In order for a local desktop LLM client or an automated CI pipeline orchestrator to actively fetch tools from your HasMCP server layer, they must authorize their network handshake.

This authentication is achieved through standard HTTP Bearer Tokens generated distinctively against each server entity.

## Using HasMCP UI

<img src="https://mintcdn.com/hasmcp/J3U3Tv-0tpxoj7dc/images/kb/generate-server-token.png?fit=max&auto=format&n=J3U3Tv-0tpxoj7dc&q=85&s=4f3f51c2f07ca891e1da24fb81f3fffd" alt="Generate Server Token" width="2560" height="1440" data-path="images/kb/generate-server-token.png" />

1. Open your target environment from the **MCP Servers** layout.
2. Select the **Configuration** tab.
3. Locate the **Server Tokens** management table.
4. Click the **Generate Token** button nested within that pane.
5. Provide a recognizable `name` so you remember its purpose later (e.g., `Claude Desktop - MacBook`).
6. Define an optional expiration date.
7. Click **Create** to instantly produce the cryptography key.

> **CRITICAL SECURITY NOTE:** Standard tokens manifest explicitly upon creation. You must copy the actual string value immediately. The platform only stores a one-way hashed derivation of the string for security purposes and will never display the raw token string to you again.

## Using REST API

For DevOps automation pipelines booting fresh agent infrastructures, you can generate authenticating credentials programmatically via the `POST` interface.

### The API Endpoint

**`POST /servers/{serverId}/tokens`**

### Generating the Payload

The generation sequence requires passing a `token` object that optionally defines an expiration sequence and strictly names the credential contextually.

```bash theme={null}
curl -X POST https://app.hasmcp.com/api/v1/servers/sE8vKd2qLp9/tokens \
 -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{
 "token": {
 "name": "productionBotKey",
 "expiresAt": "2026-12-31T23:59:59Z"
 }
 }'
```

If successful, the manager responds with a [`CreateServerTokenResponse`](/api-reference/servers/tokens/create-mcp-server-token) payload that contains the unencrypted, raw bearer token string in the `value` property that you must immediately securely inject into your deployment pipeline.
