---
name: azion-troubleshoot-a-deployment-with-the-mcp-server
description: >-
  Ask a coding agent connected to the Azion MCP servers to debug a deployment that returns error 503, and to propose Core Web Vitals improvements.
---

# Troubleshoot a deployment with the MCP server

You can debug a deployment that fails with error 503 by asking a coding agent connected to the [Azion MCP servers](/en/documentation/devtools/mcp/) for a workflow, then checking each point it raises. The same agent proposes ways to improve the Core Web Vitals scores of a site. The docs server only reads documentation. The build server can apply a fix to your account, and each of its write tools previews the request without running it when the agent sets `dry_run`. For problems with the MCP servers themselves, refer to [Troubleshoot the MCP server](/en/documentation/devtools/mcp/troubleshooting/).

---

## Prerequisites

- An application deployed on Azion that returns error 503, and its URL.
- A coding agent connected to the docs server, `https://docs-mcp.azion.com/mcp`. To write the GraphQL query, also connect the observe server, `https://observe-mcp.azion.com/mcp`. To connect a server, refer to [MCP server quickstart](/en/documentation/devtools/mcp/quickstart/).
- The Azion CLI, installed and logged in. To set it up, refer to [Azion CLI quickstart](/en/documentation/devtools/cli/quickstart/).
- `curl` on your machine.

---

## Debug a 503 error with your agent

The agent searches the Azion documentation for the error and returns a debugging workflow of five checks. You run each check, in order, and give the agent what you find. To debug the deployment:

1. **Ask your agent about the error**

   Send the agent a prompt that names the error, such as:

   ```text
   My deployment is failing with error 503. How can I debug this?
   ```

   The prompt reaches the `search_azion_docs_and_site` tool, which returns Azion documentation on debugging.

2. **Check the deployment logs**

   Read the HTTP event logs of your applications with the Azion CLI:

   ```bash
   azion logs http --tail
   ```

   The command prints the logs of the last 5 minutes and keeps running, one entry per request with its status. Look for the entries with status `503`. `--limit` sets how many entries the command shows, and `--pretty` prints each field on its own line. For the console logs of a function, run `azion logs cells`. For every flag, refer to [Azion CLI logs](/en/documentation/devtools/cli/logs/).

3. **Verify the connector configuration**

   Azion reaches your origin through a connector. The agent searches for connector troubleshooting documentation and gives you a checklist of common connector issues. For the symptoms and their fixes, refer to [Troubleshoot Connectors](/en/documentation/platform/connectors/troubleshooting/).

4. **Test the connectivity of the origin**

   Request the headers of your origin directly, replacing the host with yours:

   ```bash
   curl -I https://<your-origin-host>
   ```

   The command prints the status line and the headers the origin returns.

5. **Review the Rules Engine**

   With the agent, check the rules of your application for redirect loops, and validate the cache configurations the rules apply. For the criteria and behaviors a rule takes, refer to [Rules Engine for Applications](/en/documentation/platform/applications/rules-engine/).

6. **Monitor Real-Time Metrics**

   Ask the agent for a GraphQL query that analyzes the errors of your application in [Real-Time Metrics](/en/documentation/platform/real-time-metrics/). For how the observe server writes and validates a query, refer to [Generate GraphQL queries with the MCP server](/en/documentation/guides/platform/observability/generate-graphql-queries-with-mcp/).

You end with the log entries of the failing requests, the results of the connector and origin checks, and the rules to correct. Apply each change in your application, or ask an agent connected to the build server to apply it, with a `dry_run` preview first.

---

## Optimize Core Web Vitals with your agent

A request to improve the Core Web Vitals scores of a site returns proposals in four areas. To ask for them, send the agent a prompt such as:

```text
Optimize my site's Core Web Vitals scores
```

The agent provides:

- Image optimization strategies.
- Cache configuration recommendations.
- Rules Engine rules for resource hints.
- GraphQL queries to monitor the improvements.

You apply the rules and cache changes in your application, or ask an agent connected to the build server to create them, and you run the queries with the GraphQL API. To create a rule through the build server, refer to [Create Rules Engine rules with the MCP server](/en/documentation/guides/application-development/getting-started/generate-rules-engine-rules-with-mcp/).

---

## Next steps

- [Generate GraphQL queries with the MCP server](/en/documentation/guides/platform/observability/generate-graphql-queries-with-mcp.md): Ask the agent for a query, then run it to read the errors of your application.
- [Azion CLI logs](/en/documentation/devtools/cli/logs.md): Every flag of the commands that print HTTP event logs and function console logs.
- [Troubleshoot Connectors](/en/documentation/platform/connectors/troubleshooting.md): The symptoms a connector shows in traffic, each with its cause and its fix.
- [Troubleshoot Applications](/en/documentation/platform/applications/troubleshooting.md): What to check when requests never reach the origin or the origin returns an error.
