# Amp

> Connect Amp to Last9 MCP to query logs, traces, metrics, and alerts from your Amp threads.

Source: https://last9.io/docs/integrations/amp/

[Amp](https://ampcode.com) is an AI coding agent that runs in the terminal, in your editor, on the web, and in cloud sandboxes called orbs. It supports the Model Context Protocol (MCP), so you can connect it to Last9's hosted MCP server and give the agent direct access to your production observability data — logs, traces, metrics, exceptions, and alerts.

Ask Amp questions like _"Why is payment-service throwing 500s right now?"_ or _"What are the slowest database queries in prod?"_ and the agent will query Last9 in real time, then work on the code that fixes it.

## Prerequisites

- **Amp account** — sign in at [ampcode.com](https://ampcode.com)
- **Last9 account** — with observability data flowing in via OpenTelemetry
- **Org slug**: Find it in `https://app.last9.io/v2/organizations/<org_slug>/...`.

Amp stores the Last9 connection on ampcode.com and handles the OAuth sign-in there, so you do not need an API token or a local binary. The connection works in every Amp client, including orbs.

## Setup

**Amp settings (recommended)**

1. **Add the Last9 MCP server**

   Open [Settings → Integrations & MCP](https://ampcode.com/settings/integrations) and click **Add MCP Server**. Enter `Last9` as the name and this URL, replacing `<org_slug>` with your organization slug:

   ```
   https://app.last9.io/api/v4/organizations/<org_slug>/mcp
   ```

   Amp detects that the server uses OAuth.

2. **Sign in to Last9**

   Click **Connect** on the Last9 server and authorize access with your Last9 account in the browser window.

   To share the server with your team, add it under [Workspace Settings → Integrations & MCP](https://ampcode.com/workspace/integrations) instead. Each member then signs in with their own Last9 account.

3. **Verify the connection**

   Start a new Amp thread and ask:

   ```
   What's firing in Last9 right now?
   ```

   Amp calls the Last9 MCP server and answers with the active alerts.

**Amp CLI**

1. **Add the Last9 MCP server**

   Replace `<org_slug>` with your organization slug:

   ```bash
   amp mcp remote --personal add last9 "https://app.last9.io/api/v4/organizations/<org_slug>/mcp" --auth oauth
   ```

   Use `--workspace <workspace>` instead of `--personal` to share the server with your Amp workspace.

2. **Sign in to Last9**

   ```bash
   amp mcp remote --personal login last9
   ```

   Open the printed URL and authorize access with your Last9 account.

3. **Verify the connection**

   ```bash
   amp mcp remote --personal check last9
   ```

   Then start a thread and ask _"What's firing in Last9 right now?"_

## Example Use Cases

### Check active alerts

```
Are there any firing alerts right now?
```

Amp calls `get_alerts` to list currently active alerts with severity, current value, and firing timestamps.

### Debug production exceptions

```
I'm seeing errors from user-service in prod. What's the root cause?
```

Amp can use `get_exceptions` and `get_service_logs` to inspect exceptions and error logs, then read the code in your repository that raises them.

### Investigate slow endpoints

```
Which API endpoints are slowest in payment-service right now?
```

Amp calls `get_service_operations_summary` to break down latency and errors by endpoint.

### Correlate errors with deployments

```
We had a spike in errors around 3pm. Was there a deployment at that time?
```

Amp calls `get_change_events` and `analyze_change_impact` to find deployments and compare error rates before and after them.

### Surface slow database queries

```
What are the slowest PostgreSQL queries hitting orders-db in the last 30 minutes?
```

Amp calls `get_database_slow_queries` to return query patterns ranked by duration.

## Controlling tools

Amp loads MCP tools on demand, so Last9's tools do not fill the model's context window.

To limit what agents can do, expand **Tools** on the Last9 server in [Integrations & MCP settings](https://ampcode.com/settings/integrations) and set a policy for each tool:

- **Allow** — agents call the tool without asking (default).
- **Ask First** — agents ask you to approve each call. Use this for write tools such as `create_alert`, `mute_alert_group`, or `acknowledge_alert`.
- **Disabled** — agents cannot use the tool.

## Available tools

Once connected, Amp can use all Last9 tools. For the full list and parameters, see the [Last9 MCP](/docs/ai/mcp/) reference.

---

## Troubleshooting

**Last9 tools not showing up in Amp**

- Check that the Last9 server shows as connected in [Integrations & MCP settings](https://ampcode.com/settings/integrations). If not, click **Connect** and sign in again.
- Check that your org slug in the URL is correct (no trailing slash, no extra path segments)
- Start a new thread. Existing threads pick up new MCP servers after **Reload MCP**.

**"No data returned" for queries**

- Make sure your services are sending telemetry to Last9 via the [OpenTelemetry integration](https://app.last9.io/integrations?integration=OpenTelemetry)
- Try broadening the time range in your question ("last 2 hours" instead of "last 15 minutes")

Please get in touch with us on [Discord](https://discord.com/invite/Q3p2EEucx9) or [Email](mailto:support@last9.io) if you have any questions.
