> Documentation index: https://metorial.com/llms.txt. Every page is available as Markdown by adding .md to its URL.

# Create Magic MCP servers, endpoints and tokens from the terminal
URL: https://metorial.com/docs/platform/cli/magic-mcp

Use metorial-admin magic-mcp to create a server from an integration, combine servers behind one endpoint, issue a token for it and list the sessions it served.

---

A Magic MCP server is a stable MCP URL for one integration. `metorial-admin magic-mcp` creates servers, combines several behind one endpoint, issues the tokens that let a client connect, and lists the sessions each server has handled. Use it to script what the dashboard does under **Integrations**, **Magic MCP**.

**What you'll learn**

* How to create a Magic MCP server and see its tools
* How to put several servers behind one endpoint
* How to issue, scope and delete tokens

**Before you start**

* The `metorial-admin` CLI, signed in ([install and sign in](https://metorial.com/docs/platform/cli))
* An integration that is already configured ([create an integration](https://metorial.com/docs/platform/integrations/create-integration))

The five subcommands map to five objects:

| Subcommand  | What it manages                               |
| ----------- | --------------------------------------------- |
| `servers`   | One MCP entry point backed by one integration |
| `endpoints` | One URL that routes to several servers        |
| `groups`    | Labels for servers, used to scope tokens      |
| `tokens`    | Secrets that authorize a client to connect    |
| `sessions`  | Connections a server has handled              |

Add `--format json` to any command to get full objects with their IDs.

## Create a server

### 1. Find the integration instance

A server is created from an integration instance, which is an integration with its configuration and authentication filled in.

```bash
metorial-admin integrations instances list --search github
```

### 2. Create the server

```bash
metorial-admin magic-mcp servers create \
  --name "GitHub" \
  --description "Issues and pull requests" \
  --integration-instance-id <integration-instance-id>
```

The response contains the server ID and an `endpoints` list with the server's URL.

### 3. Check the tools

```bash
metorial-admin magic-mcp servers tools <server-id>
```

This returns the tools a client will see through the server, after the integration's tool filters.

To find servers later, filter the list. By default, `list` can leave out servers that belong to one person. Pass `--ownership all` to include everything you are allowed to see.

```bash
metorial-admin magic-mcp servers list --search github
metorial-admin magic-mcp servers list --ownership all --status active
metorial-admin magic-mcp servers update <server-id> --name "GitHub (read-only)"
metorial-admin magic-mcp servers delete <server-id>
```

`delete` archives the server. Its URL stops working.

## Put several servers behind one endpoint

An endpoint gives a client a single URL for several servers, so one entry in the client's config covers all of them.

```bash
metorial-admin magic-mcp endpoints create \
  --name "Engineering tools" \
  --magic-mcp-servers '[{"magic_mcp_server_id":"<server-id-1>"},{"magic_mcp_server_id":"<server-id-2>"}]'
```

The response includes the endpoint's `url`. To change the set of servers later:

```bash
metorial-admin magic-mcp endpoints add-servers <magic-mcp-endpoint-id> \
  --magic-mcp-servers '[{"magic_mcp_server_id":"<server-id-3>"}]'
metorial-admin magic-mcp endpoints list --magic-mcp-server-id <server-id>
```

Each entry in `--magic-mcp-servers` can also carry a `tool_filters` field to narrow that server's tools on this endpoint only.

## Issue a token

A token is bound to one of three things: a server, an endpoint, or one or more groups.

```bash
# For one server
metorial-admin magic-mcp tokens create --name "CI agent" --magic-mcp-server-id <server-id>

# For one endpoint
metorial-admin magic-mcp tokens create --name "Support bot" --magic-mcp-endpoint-id <magic-mcp-endpoint-id>
```

The response includes the token's `secret`. Give it to the client as part of the URL:

```text
https://<endpoint-url>?key=<secret>
```

Treat that URL as a password. Create one token per client or per job, so you can remove one without breaking the others.

```bash
metorial-admin magic-mcp tokens list --magic-mcp-server-id <server-id>
metorial-admin magic-mcp tokens delete <magic-mcp-token-id>
```

### Scope a token with groups

Groups let one token reach a named set of servers. Add a server to the group and every token bound to that group can use it.

```bash
metorial-admin magic-mcp groups create --name "Read-only tools"
metorial-admin magic-mcp groups add-servers <magic-mcp-group-id> --magic-mcp-server-ids <server-id-1>,<server-id-2>
metorial-admin magic-mcp tokens create --name "Analyst agent" --magic-mcp-group-ids <magic-mcp-group-id>
```

`tokens add-groups` and `tokens remove-groups` change a token's groups later. `groups delete` fails while the group is the only group of an active token, so deleting a group can never widen what a token reaches.

## See the sessions a server handled

```bash
metorial-admin magic-mcp sessions list --magic-mcp-server-id <server-id>
metorial-admin magic-mcp sessions get <magic-mcp-session-id>
```

For the tool calls inside a session, see [See what happened from the terminal](https://metorial.com/docs/platform/cli/logs-and-audit).

## Check it worked

Run `metorial-admin magic-mcp servers tools <server-id>`. If it lists tools, the server is live. Then add the URL with the token to an MCP client and call one tool. A new row appears in `metorial-admin magic-mcp sessions list`.

## Next steps

* [Manage a portal from the terminal](https://metorial.com/docs/platform/cli/manage-a-portal)
* [See what happened from the terminal](https://metorial.com/docs/platform/cli/logs-and-audit)
* [Set up a Magic MCP server in the dashboard](https://metorial.com/docs/platform/integrations/setup-magic-mcp-server)