diff --git a/src/content/docs/en/pages/devtools/mcp/mcp-cache-testing.mdx b/src/content/docs/en/pages/devtools/mcp/mcp-cache-testing.mdx new file mode 100644 index 0000000000..efeae54bfe --- /dev/null +++ b/src/content/docs/en/pages/devtools/mcp/mcp-cache-testing.mdx @@ -0,0 +1,447 @@ +--- +title: MCP Cache Testing Guide +description: >- + Comprehensive guide for testing, debugging, and optimizing cache behavior + on Azion Platform using MCP tools and cURL commands. +meta_tags: 'mcp, cache, testing, debugging, optimization, performance' +namespace: documentation_devtools_mcp_cache_testing +menu_namespace: devtoolsMenu +permalink: /documentation/devtools/mcp/cache-testing/ +--- + +import Code from '~/components/Code/Code.astro' + +This guide provides methods for testing, debugging, and optimizing cache behavior on the Azion Edge Platform using MCP tools and direct cURL commands. + +--- + +## Cache debug headers + +Enable cache debug headers by including `Pragma: azion-debug-cache` in your requests. This returns detailed cache information. + +### Debug headers reference + +| Header | Description | Example Values | +|--------|-------------|----------------| +| `X-Cache` | Cache status of the request | `HIT`, `MISS`, `EXPIRED`, `UPDATING`, `STALE` | +| `X-Cache-Key` | The cache key used to store/retrieve the object | `/index.html@@cookie_name=value` | +| `X-Cache-File` | MD5 hash of the cache key | `a1b2c3d4e5f6789...` | +| `X-Cache-Since` | Unix timestamp when object was cached | `1640995200` | +| `X-Cache-Expire` | Unix timestamp when cache expires | `1640995800` | +| `X-Cache-Expire-In` | Seconds remaining until cache expires | `600` | +| `X-Cache-Valid` | Configured TTL in seconds | `3600` | +| `X-Cache-Config` | Azion configuration ID | `1595368520` | +| `X-Cache-ID` | Unique identifier for this request | `#AECFE66100000000C947B9B3...` | + +--- + +## Basic cache testing with cURL + +### Test Azion edge domain + +Always start by testing the `.map.azionedge.net` domain directly: + + + +### Test static assets + + + +### Test production domain via Azion edge + + + +--- + +## Cache key testing + +### Query parameter variations + + + +### Cookie-based variations + +/dev/null | grep "X-Cache-Key" +`} /> + +--- + +## Cache performance testing + +### Consistent edge location testing + +Fix the IP to ensure both requests go to the same edge server: + + + +:::note + The TTFB should be significantly lower on the second request when content is served from cache. +::: + +### Provider comparison + + + +--- + +## Network information + +Get network information including your IP, resolver, and edge location: + + + +This provides: +- Your public IP (useful for searching in Azion logs) +- DNS resolver being used +- Azion edge location serving the request +- Network health status + +--- + +## Real-Time Events monitoring + +### Using Azion CLI + + + +### Key log variables for cache analysis + +| Variable | Description | Example | +|----------|-------------|---------| +| `Cache Key` | Cache key used | `/index.html@@cookie_name=value` | +| `Cache TTL` | Cache duration in seconds | `31536000` | +| `Upstream Cache Status` | Cache status | `HIT`, `MISS`, `BYPASS`, `EXPIRED`, `STALE` | +| `Upstream Response Time` | Origin response time | `-` for cached content | +| `Bytes Sent` | Total bytes delivered | `1024` | +| `Request Time` | Total processing time | `0.001` | + +--- + +## GraphQL queries for cache analysis + +Use MCP's `create_graphql_query` tool or run directly: + + + +### Key performance indicators + +- **Cache Hit Ratio**: Should be >80% for static content +- **Edge Offload**: Percentage of requests served from cache vs origin +- **Origin Response Time**: Compare cached vs non-cached requests +- **Bandwidth Savings**: Bytes served from cache vs origin + +--- + +## Cache configuration via CLI + +### Create cache settings + + + +### Apply via Rules Engine + + + +--- + +## Cache optimization strategies + +### Query string strategy + +| Strategy | Use case | Configuration | +|----------|----------|---------------| +| **Ignore all** | Static assets | `--cache-by-query-string "ignore"` | +| **Whitelist** | APIs with functional params | `--cache-by-query-string "whitelist"` with specific params | +| **Blacklist** | Ignore tracking params | `--cache-by-query-string "blacklist"` with utm_*, fbclid, gclid | + +### Cookie strategy + +| Strategy | Use case | Configuration | +|----------|----------|---------------| +| **Ignore all** | Static content | `--cache-by-cookies "ignore"` | +| **Whitelist** | Personalized content | `--cache-by-cookies "whitelist"` with language, currency | + +### TTL strategy by content type + +| Content Type | Recommended TTL | Example | +|--------------|-----------------|---------| +| Static assets | 30 days | `2592000` seconds | +| Semi-static | 1 hour | `3600` seconds | +| Dynamic | 5 minutes | `300` seconds | +| Real-time | 30 seconds | `30` seconds | + +--- + +## Automated cache health check script + + HIT pattern" +`} /> + +--- + +## Troubleshooting cache issues + +### Low cache hit ratio (< 60%) + +**Diagnosis:** + + + +**Solutions:** +- Configure `cache-by-query-string` to `ignore` for static content +- Use `whitelist` for cookies instead of caching by all cookies +- Implement bypass rules for authenticated users + +### Stale content not updating + +**Diagnosis:** + + + +**Solutions:** + + + +### Dynamic content being cached + +**Diagnosis:** + + + +**Solutions:** +- Add bypass rule for personalized content paths +- Configure proper `cacheByCookie` settings +- Use shorter TTLs for user-specific content + +--- + +## Best practices + +1. **Use `Pragma: azion-debug-cache`** for immediate cache debugging +2. **Monitor Real-Time Events** for cache behavior analysis +3. **Test cache key variations** with different parameters/cookies +4. **Implement tiered TTL strategy** based on content type +5. **Use stale-while-revalidate** for better availability +6. **Monitor cache hit ratios** and optimize configurations +7. **Purge strategically** using wildcards and cache keys +8. **Test from multiple edge locations** using direct IP connections +9. **Automate cache health checks** with shell scripts +10. **Measure performance differences** between cached and non-cached requests + +--- + +## Next steps + +- [MCP Configuration Guide](/en/documentation/devtools/mcp/configuration/) +- [MCP Examples](/en/documentation/devtools/mcp/examples/) +- [MCP Troubleshooting](/en/documentation/devtools/mcp/troubleshooting/) diff --git a/src/content/docs/en/pages/devtools/mcp/mcp-configuration.mdx b/src/content/docs/en/pages/devtools/mcp/mcp-configuration.mdx index aeaab23e47..c96a043515 100644 --- a/src/content/docs/en/pages/devtools/mcp/mcp-configuration.mdx +++ b/src/content/docs/en/pages/devtools/mcp/mcp-configuration.mdx @@ -169,6 +169,68 @@ Create `.vscode/mcp.json` in your project root: --- +## Warp Terminal + +Configure MCP in Warp's settings. + +### Configuration + +Add to Warp MCP settings: + + + +--- + +## Kiro Code + +Kiro Code supports MCP through its settings file. + +### Setup + +Create `.kiro/settings/mcp.json`: + + + +--- + +## OpenCode + +OpenCode uses TOML configuration for MCP servers. + +### Setup + +Create `.codex/config.toml`: + + + +--- + ## Testing your connection ### Using MCP Inspector @@ -231,4 +293,6 @@ This endpoint provides access to all MCP tools and resources for interacting wit ## Next steps - [Explore MCP examples](/en/documentation/devtools/mcp/examples/) -- [Troubleshooting guide](/en/documentation/devtools/mcp/troubleshooting/) \ No newline at end of file +- [Troubleshooting guide](/en/documentation/devtools/mcp/troubleshooting/) +- [Local Development](/en/documentation/devtools/mcp/local-development/) +- [Cache Testing Guide](/en/documentation/devtools/mcp/cache-testing/) \ No newline at end of file diff --git a/src/content/docs/en/pages/devtools/mcp/mcp-examples.mdx b/src/content/docs/en/pages/devtools/mcp/mcp-examples.mdx index f8c42df5bd..137f8bbdeb 100644 --- a/src/content/docs/en/pages/devtools/mcp/mcp-examples.mdx +++ b/src/content/docs/en/pages/devtools/mcp/mcp-examples.mdx @@ -321,4 +321,6 @@ The assistant provides: ## Next steps - [Configure MCP](/en/documentation/devtools/mcp/configuration/) -- [Troubleshooting guide](/en/documentation/devtools/mcp/troubleshooting/) \ No newline at end of file +- [Troubleshooting guide](/en/documentation/devtools/mcp/troubleshooting/) +- [Local Development](/en/documentation/devtools/mcp/local-development/) +- [Cache Testing Guide](/en/documentation/devtools/mcp/cache-testing/) \ No newline at end of file diff --git a/src/content/docs/en/pages/devtools/mcp/mcp-local-development.mdx b/src/content/docs/en/pages/devtools/mcp/mcp-local-development.mdx new file mode 100644 index 0000000000..4fdfcdb72d --- /dev/null +++ b/src/content/docs/en/pages/devtools/mcp/mcp-local-development.mdx @@ -0,0 +1,224 @@ +--- +title: MCP Local Development +description: >- + Set up a local development environment for Azion MCP server, including + cloning, building, and deploying your own instance. +meta_tags: 'mcp, local development, setup, deployment, contributing' +namespace: documentation_devtools_mcp_local_development +menu_namespace: devtoolsMenu +permalink: /documentation/devtools/mcp/local-development/ +--- + +import Code from '~/components/Code/Code.astro' + +This guide covers how to set up a local development environment for the Azion MCP server, useful for testing, customization, or contributing to the project. + +--- + +## Prerequisites + +Before starting, ensure you have: + +- **Node.js 20+** installed +- **Yarn** package manager +- **Azion CLI** installed: [how to download](https://www.azion.com/en/documentation/products/azion-cli/overview/) +- **Git** for cloning the repository +- **OpenAI API Key** (required for AI features in local development) + +--- + +## Setup + +### 1. Clone the repository + + + +### 2. Install dependencies + + + +### 3. Configure environment variables + + + +### 4. Build the server + + + +--- + +## Running locally + +Start the development server: + + + +### Connect your code assistant + +Once the server is running, configure your code assistant to use the local endpoint: + + + +--- + +## Personal deployment + +Deploy your own instance of the MCP server to Azion Platform. + +### 1. Create personal configuration + + + +### 2. Deploy + + + +### 3. Configure environment variables + +After deployment, add the required environment variables in Azion Console: + +1. Navigate to your application in [Azion Console](https://console.azion.com) +2. Go to **Environment Variables** +3. Add `OPENAI_API_KEY` with your OpenAI API key + +### 4. Use your personal URL + +Update your MCP configuration to use your personal deployment URL instead of the production endpoint. + +--- + +## Testing + +### Using MCP Inspector + +Test your local or personal deployment with MCP Inspector: + + + +In the Inspector interface: + +1. Select **streamable-http** as transport type +2. Enter your URL: `http://localhost:3333` (local) or your personal deployment URL +3. Add authentication header: `Authorization: Bearer YOUR_PERSONAL_TOKEN` +4. Click **Connect** and test available tools + +### Test with Node.js directly + + + +--- + +## Project structure + +The MCP server project is organized as follows: + +| Directory/File | Description | +|----------------|-------------| +| `src/index.ts` | Main entry point | +| `src/core/` | Core functionality | +| `src/core/tools.ts` | Tool definitions | +| `src/core/resources.ts` | Resource definitions | +| `src/core/prompts.ts` | Prompt definitions | +| `src/middlewares/auth.ts` | Authentication middleware | +| `src/helpers/utils.ts` | Helper functions | +| `azion/production` | Production environment configuration | +| `azion/stage` | Stage environment configuration | + +--- + +## Configuration directories + +The project includes predefined configuration directories: + +- **`azion/production`**: Production environment configuration +- **`azion/stage`**: Stage environment configuration +- **`azion/personal`**: Your personal configuration (create this) + +:::note + Never modify the `production` or `stage` directories. Always use a personal configuration for development. +::: + +--- + +## Authentication methods + +The MCP server supports multiple authentication methods: + +| Method | Description | Format | +|--------|-------------|--------| +| **Fast Pass Token** | Internal token for Azion Copilot | Set via `MCP_COPILOT_SERVER_TOKEN` env var | +| **Personal Tokens** | Azion Personal Tokens | Format: `azion[a-zA-Z0-9]{35}` (40 chars) | +| **OAuth Tokens** | Bearer tokens from SSO OAuth flow | Validated against `/oauth/userinfo` | +| **JWT Tokens** | Bearer tokens for v4 API | Validated against `/v4/account/auth/token` | + +Token detection order: JWT first for Bearer tokens, then OAuth if JWT fails. + +--- + +## Troubleshooting local development + +### Server won't start + +1. Verify Node.js version: `node --version` (must be 20+) +2. Check if port 3333 is available +3. Ensure all dependencies are installed: `yarn install` + +### Authentication errors + +1. Verify your Personal Token is valid +2. Check the `OPENAI_API_KEY` is set correctly +3. Ensure the authorization header format is correct + +### Build failures + + + +--- + +## Next steps + +- [MCP Configuration Guide](/en/documentation/devtools/mcp/configuration/) +- [MCP Examples](/en/documentation/devtools/mcp/examples/) +- [MCP Troubleshooting](/en/documentation/devtools/mcp/troubleshooting/) diff --git a/src/content/docs/en/pages/devtools/mcp/mcp-overview.mdx b/src/content/docs/en/pages/devtools/mcp/mcp-overview.mdx index 67bd023534..21782e1fde 100644 --- a/src/content/docs/en/pages/devtools/mcp/mcp-overview.mdx +++ b/src/content/docs/en/pages/devtools/mcp/mcp-overview.mdx @@ -30,6 +30,17 @@ The Azion MCP server is available at: **Production URL**: `https://mcp.azion.com` +### Available environments + +Choose the appropriate environment based on your needs: + +| Environment | URL | Use case | +|-------------|-----|----------| +| **Production** | `https://mcp.azion.com` | Production console, main branch | +| **Stage** | `https://stage-mcp.azion.com` | Stage console, dev branch | +| **Local Development** | `http://localhost:3333` | Running `azion dev` locally | +| **Personal Deploy** | Your personal Azion URL | After deploying with `azion deploy --config-dir azion/personal` | + --- ## Capabilities @@ -48,6 +59,15 @@ The Azion MCP server provides nine specialized tools: | `create_graphql_query` | Build GraphQL queries for analytics | | `deploy_azion_static_site` | Get guides for deploying static sites | +### MCP Resources + +For clients supporting the MCP Resources Protocol, the following resources are available: + +| Resource URI | Description | +|--------------|-------------| +| `azion://static-site/deploy/*` | Step-by-step deployment guides | +| `azion://static-site/test-cache/*` | Cache testing workflows | + --- ## Requirements @@ -63,4 +83,6 @@ The Azion MCP server provides nine specialized tools: - [MCP Configuration Guide](/en/documentation/devtools/mcp/configuration/) - [MCP Examples](/en/documentation/devtools/mcp/examples/) - [MCP Troubleshooting](/en/documentation/devtools/mcp/troubleshooting/) +- [MCP Local Development](/en/documentation/devtools/mcp/local-development/) +- [MCP Cache Testing](/en/documentation/devtools/mcp/cache-testing/) - [Model Context Protocol Specification](https://modelcontextprotocol.io) \ No newline at end of file diff --git a/src/content/docs/en/pages/devtools/mcp/mcp-troubleshooting.mdx b/src/content/docs/en/pages/devtools/mcp/mcp-troubleshooting.mdx index 7de2868e5b..0c833ac59d 100644 --- a/src/content/docs/en/pages/devtools/mcp/mcp-troubleshooting.mdx +++ b/src/content/docs/en/pages/devtools/mcp/mcp-troubleshooting.mdx @@ -290,20 +290,75 @@ This guide helps resolve common issues with MCP configuration and usage. --- -## Getting help +## OAuth and SSO issues -If issues persist after trying these solutions: +### Token validation fails -1. **Contact support**: - - Include error messages - - Specify code assistant and version - - Provide configuration (without tokens) - - Describe steps to reproduce +**Symptoms:** +- "Invalid token" after OAuth flow +- UserInfo returns 401 -2. **Community resources**: - - [Azion Discord](https://discord.gg/azion) - - [Azion Forum](https://forum.azion.com) +**Solutions:** -:::note - When reporting issues, never include your Personal Token in logs or screenshots. -::: +1. **Verify token format**: + - Ensure the token is sent with `Bearer` prefix + - Check if using correct SSO domain (production vs stage) + +2. **Check token expiration**: + - OAuth tokens expire after a set period + - Request a new token if expired + +3. **Verify SSO endpoints**: + - Production: `https://sso.azion.com/oauth/*` + - Stage: `https://stage-sso.azion.com/oauth/*` + +### Client not authorized + +**Solutions:** + +1. Verify client ID and secret are correct +2. Check redirect URI matches exactly what's configured in SSO +3. Ensure required scopes are enabled for the client + +--- + +## Environment-specific issues + +### Stage environment not responding + +**Solutions:** + +1. **Verify URL**: + - Stage URL: `https://stage-mcp.azion.com` + - Production URL: `https://mcp.azion.com` + +2. **Check environment status**: + - Stage may have different availability than production + - Use production for critical workflows + +### Local development issues + +**Solutions:** + +1. **Verify server is running**: + + + +2. **Check environment variables**: + + + +3. **Restart local server**: + + + +--- + +## Next steps + + - [MCP Local Development](/en/documentation/devtools/mcp/local-development/) + - [MCP Cache Testing](/en/documentation/devtools/mcp/cache-testing/) + diff --git a/src/content/docs/pt-br/pages/devtools/mcp/mcp-configuracao.mdx b/src/content/docs/pt-br/pages/devtools/mcp/mcp-configuracao.mdx index c0b104fe4c..ab602606ee 100644 --- a/src/content/docs/pt-br/pages/devtools/mcp/mcp-configuracao.mdx +++ b/src/content/docs/pt-br/pages/devtools/mcp/mcp-configuracao.mdx @@ -159,6 +159,62 @@ O suporte MCP no VS Code pode requerer extensões adicionais. Verifique o market --- +## Warp Terminal + +Configure o MCP nas configurações do Warp. + +### Configuração + +Adicione às configurações MCP do Warp: + + + +--- + +## Kiro Code + +O Kiro Code suporta MCP através de seu arquivo de configurações. + +### Configuração + +Crie `.kiro/settings/mcp.json`: + + + +--- + +## OpenCode + +O OpenCode usa configuração TOML para servidores MCP. + +### Configuração + +Crie `.codex/config.toml`: + + + +--- + ## Testando sua conexão ### Usando o MCP Inspector @@ -221,4 +277,6 @@ Desenvolvimento local requer executar o servidor MCP localmente. Veja o [reposit ## Próximos passos - [Explorar exemplos MCP](/pt-br/documentacao/devtools/mcp/exemplos/) -- [Guia de solução de problemas](/pt-br/documentacao/devtools/mcp/solucao-de-problemas/) \ No newline at end of file +- [Guia de solução de problemas](/pt-br/documentacao/devtools/mcp/solucao-de-problemas/) +- [Desenvolvimento Local](/pt-br/documentacao/devtools/mcp/desenvolvimento-local/) +- [Guia de Teste de Cache](/pt-br/documentacao/devtools/mcp/teste-cache/) \ No newline at end of file diff --git a/src/content/docs/pt-br/pages/devtools/mcp/mcp-desenvolvimento-local.mdx b/src/content/docs/pt-br/pages/devtools/mcp/mcp-desenvolvimento-local.mdx new file mode 100644 index 0000000000..1ba2c59a72 --- /dev/null +++ b/src/content/docs/pt-br/pages/devtools/mcp/mcp-desenvolvimento-local.mdx @@ -0,0 +1,202 @@ +--- +title: Desenvolvimento Local MCP +description: >- + Configure um ambiente de desenvolvimento local para o servidor MCP da Azion, + incluindo clonagem, build e deploy de sua própria instância. +meta_tags: 'mcp, desenvolvimento local, setup, deployment, contribuição' +namespace: documentation_devtools_mcp_local_development +menu_namespace: devtoolsMenu +permalink: /documentacao/devtools/mcp/desenvolvimento-local/ +--- + +import Code from '~/components/Code/Code.astro' + +Este guia cobre como configurar um ambiente de desenvolvimento local para o servidor MCP da Azion, útil para testes, customização ou contribuição ao projeto. + +--- + +## Pré-requisitos + +Antes de começar, certifique-se de ter: + +- **Node.js 20+** instalado +- **Yarn** gerenciador de pacotes +- **Azion CLI** instalado: [como baixar](https://www.azion.com/pt-br/documentacao/produtos/azion-cli/visao-geral/) +- **Git** para clonar o repositório +- **Chave de API OpenAI** (necessária para recursos de IA no desenvolvimento local) + +--- + +## Configuração + +### 1. Clonar o repositório + + + +### 2. Instalar dependências + + + +### 3. Configurar variáveis de ambiente + + + +### 4. Build do servidor + + + +--- + +## Executando localmente + +Inicie o servidor de desenvolvimento: + + + +### Conectar seu assistente de código + +Uma vez que o servidor esteja rodando, configure seu assistente de código para usar o endpoint local: + + + +--- + +## Deploy pessoal + +Faça deploy de sua própria instância do servidor MCP na Plataforma Azion. + +### 1. Criar configuração pessoal + + + +### 2. Deploy + + + +### 3. Configurar variáveis de ambiente + +Após o deploy, adicione as variáveis de ambiente necessárias no Console Azion: + +1. Navegue até sua aplicação no [Console Azion](https://console.azion.com) +2. Vá para **Variáveis de Ambiente** +3. Adicione `OPENAI_API_KEY` com sua chave de API OpenAI + +### 4. Usar sua URL pessoal + +Atualize sua configuração MCP para usar a URL do seu deploy pessoal em vez do endpoint de produção. + +--- + +## Testes + +### Usando o MCP Inspector + +Teste seu deploy local ou pessoal com o MCP Inspector: + + + +Na interface do Inspector: + +1. Selecione **streamable-http** como tipo de transporte +2. Digite sua URL: `http://localhost:3333` (local) ou sua URL de deploy pessoal +3. Adicione o header de autenticação: `Authorization: Bearer SEU_PERSONAL_TOKEN` +4. Clique em **Connect** e teste as ferramentas disponíveis + +### Testar diretamente com Node.js + + + +--- + +## Estrutura do projeto + +O projeto do servidor MCP está organizado da seguinte forma: + +| Diretório/Arquivo | Descrição | +|-------------------|-----------| +| `src/index.ts` | Ponto de entrada principal | +| `src/core/` | Funcionalidade central | +| `src/core/tools.ts` | Definições de ferramentas | +| `src/core/resources.ts` | Definições de recursos | +| `src/core/prompts.ts` | Definições de prompts | +| `src/middlewares/auth.ts` | Middleware de autenticação | +| `src/helpers/utils.ts` | Funções auxiliares | +| `azion/production` | Configuração do ambiente de produção | +| `azion/stage` | Configuração do ambiente de stage | + +--- + +## Diretórios de configuração + +O projeto inclui diretórios de configuração predefinidos: + +- **`azion/production`**: Configuração do ambiente de produção +- **`azion/stage`**: Configuração do ambiente de stage +- **`azion/personal`**: Sua configuração pessoal (crie este) + +:::note +Nunca modifique os diretórios `production` ou `stage`. Sempre use uma configuração pessoal para desenvolvimento. +::: + +--- + +## Métodos de autenticação + +O servidor MCP suporta múltiplos métodos de autenticação: + +| Método | Descrição | Formato | +|--------|-----------|---------| +| **Fast Pass Token** | Token interno para Azion Copilot | Definido via variável de ambiente `MCP_COPILOT_SERVER_TOKEN` | +| **Personal Tokens** | Personal Tokens Azion | Formato: `azion[a-zA-Z0-9]{35}` (40 caracteres) | +| **OAuth Tokens** | Bearer tokens do fluxo OAuth SSO | Validado contra `/oauth/userinfo` | +| **JWT Tokens** | Bearer tokens para autenticação API v4 | Validado contra `/v4/account/auth/token` | + +Ordem de detecção de token: JWT primeiro para Bearer tokens, depois OAuth se JWT falhar. + +--- + +## Solução de problemas no desenvolvimento local + +### Servidor não inicia + +1. Verifique a versão do Node.js: `node --version` (deve ser 20+) +2. Verifique se a porta 3333 está disponível +3. Certifique-se de que todas as dependências estão instaladas: `yarn install` + +### Erros de autenticação + +1. Verifique se seu Personal Token é válido +2. Verifique se `OPENAI_API_KEY` está definido corretamente +3. Certifique-se de que o formato do header de autorização está correto + +### Falhas no build + + + +--- + +## Próximos passos + +- [Guia de Configuração MCP](/pt-br/documentacao/devtools/mcp/configuracao/) +- [Exemplos MCP](/pt-br/documentacao/devtools/mcp/exemplos/) +- [Solução de Problemas MCP](/pt-br/documentacao/devtools/mcp/solucao-de-problemas/) diff --git a/src/content/docs/pt-br/pages/devtools/mcp/mcp-exemplos.mdx b/src/content/docs/pt-br/pages/devtools/mcp/mcp-exemplos.mdx index 7c6279c77a..e3198cb941 100644 --- a/src/content/docs/pt-br/pages/devtools/mcp/mcp-exemplos.mdx +++ b/src/content/docs/pt-br/pages/devtools/mcp/mcp-exemplos.mdx @@ -316,3 +316,5 @@ O assistente fornece: - [Configurar MCP](/pt-br/documentacao/devtools/mcp/configuracao/) - [Guia de solução de problemas](/pt-br/documentacao/devtools/mcp/solucao-de-problemas/) +- [Desenvolvimento Local](/pt-br/documentacao/devtools/mcp/desenvolvimento-local/) +- [Guia de Teste de Cache](/pt-br/documentacao/devtools/mcp/teste-cache/) diff --git a/src/content/docs/pt-br/pages/devtools/mcp/mcp-overview.mdx b/src/content/docs/pt-br/pages/devtools/mcp/mcp-overview.mdx index adc5c8c543..65a81844d5 100644 --- a/src/content/docs/pt-br/pages/devtools/mcp/mcp-overview.mdx +++ b/src/content/docs/pt-br/pages/devtools/mcp/mcp-overview.mdx @@ -30,6 +30,17 @@ O servidor MCP da Azion está disponível em: **URL de Produção**: `https://mcp.azion.com` +### Ambientes disponíveis + +Escolha o ambiente apropriado baseado em suas necessidades: + +| Ambiente | URL | Caso de uso | +|----------|-----|-------------| +| **Produção** | `https://mcp.azion.com` | Console de produção, branch main | +| **Stage** | `https://stage-mcp.azion.com` | Console de stage, branch dev | +| **Desenvolvimento Local** | `http://localhost:3333` | Executando `azion dev` localmente | +| **Deploy Pessoal** | Sua URL pessoal Azion | Após deploy com `azion deploy --config-dir azion/personal` | + --- ## Capacidades @@ -48,6 +59,15 @@ O servidor MCP da Azion fornece nove ferramentas especializadas: | `create_graphql_query` | Construir queries GraphQL para analytics | | `deploy_azion_static_site` | Obter guias para deploy de sites estáticos | +### MCP Resources + +Para clientes que suportam o MCP Resources Protocol, os seguintes recursos estão disponíveis: + +| URI do Recurso | Descrição | +|----------------|-----------| +| `azion://static-site/deploy/*` | Guias de deploy passo a passo | +| `azion://static-site/test-cache/*` | Fluxos de trabalho para teste de cache | + --- ## Requisitos @@ -63,4 +83,6 @@ O servidor MCP da Azion fornece nove ferramentas especializadas: - [Guia de Configuração MCP](/pt-br/documentacao/devtools/mcp/configuracao/) - [Exemplos MCP](/pt-br/documentacao/devtools/mcp/exemplos/) - [Solução de Problemas MCP](/pt-br/documentacao/devtools/mcp/solucao-de-problemas/) +- [Desenvolvimento Local MCP](/pt-br/documentacao/devtools/mcp/desenvolvimento-local/) +- [Teste de Cache MCP](/pt-br/documentacao/devtools/mcp/teste-cache/) - [Especificação Model Context Protocol](https://modelcontextprotocol.io) \ No newline at end of file diff --git a/src/content/docs/pt-br/pages/devtools/mcp/mcp-solucao-de-problemas.mdx b/src/content/docs/pt-br/pages/devtools/mcp/mcp-solucao-de-problemas.mdx index f4a6557d3e..068c33d781 100644 --- a/src/content/docs/pt-br/pages/devtools/mcp/mcp-solucao-de-problemas.mdx +++ b/src/content/docs/pt-br/pages/devtools/mcp/mcp-solucao-de-problemas.mdx @@ -286,25 +286,74 @@ Nunca compartilhe seu Personal Token ou faça commit dele no controle de versão --- -## Obtendo ajuda +## Problemas de OAuth e SSO -Se os problemas persistirem após tentar estas soluções: +### Falha na validação do token -1. **Verificar GitHub Issues**: - - [Repositório Azion Copilot API](https://github.com/aziontech/azion-copilot-api/issues) - - Buscar issues existentes - - Criar nova issue com detalhes +**Sintomas:** +- "Invalid token" após fluxo OAuth +- UserInfo retorna 401 + +**Soluções:** + +1. **Verificar formato do token**: + - Certifique-se de que o token é enviado com prefixo `Bearer` + - Verifique se está usando o domínio SSO correto (produção vs stage) + +2. **Verificar expiração do token**: + - Tokens OAuth expiram após um período definido + - Solicite um novo token se expirado + +3. **Verificar endpoints SSO**: + - Produção: `https://sso.azion.com/oauth/*` + - Stage: `https://stage-sso.azion.com/oauth/*` + +### Cliente não autorizado + +**Soluções:** + +1. Verifique se client ID e secret estão corretos +2. Verifique se a URI de redirect corresponde exatamente ao configurado no SSO +3. Certifique-se de que os scopes necessários estão habilitados para o cliente + +--- + +## Problemas específicos de ambiente + +### Ambiente stage não responde -2. **Contatar suporte**: - - Inclua mensagens de erro - - Especifique assistente de código e versão - - Forneça configuração (sem tokens) - - Descreva passos para reproduzir +**Soluções:** + +1. **Verificar URL**: + - URL Stage: `https://stage-mcp.azion.com` + - URL Produção: `https://mcp.azion.com` + +2. **Verificar status do ambiente**: + - Stage pode ter disponibilidade diferente de produção + - Use produção para fluxos críticos + +### Problemas de desenvolvimento local + +**Soluções:** + +1. **Verificar se o servidor está rodando**: + + + +2. **Verificar variáveis de ambiente**: + + + +3. **Reiniciar servidor local**: + + + +--- -3. **Recursos da comunidade**: - - [Discord Azion](https://discord.gg/azion) - - [Fórum Azion](https://forum.azion.com) +## Próximos passos -:::note -Ao reportar problemas, nunca inclua seu Personal Token em logs ou screenshots. -::: \ No newline at end of file + - [Desenvolvimento Local MCP](/pt-br/documentacao/devtools/mcp/desenvolvimento-local/) + - [Teste de Cache MCP](/pt-br/documentacao/devtools/mcp/teste-cache/) diff --git a/src/content/docs/pt-br/pages/devtools/mcp/mcp-teste-cache.mdx b/src/content/docs/pt-br/pages/devtools/mcp/mcp-teste-cache.mdx new file mode 100644 index 0000000000..6b1b61c131 --- /dev/null +++ b/src/content/docs/pt-br/pages/devtools/mcp/mcp-teste-cache.mdx @@ -0,0 +1,413 @@ +--- +title: Guia de Teste de Cache MCP +description: >- + Guia completo para testar, debugar e otimizar o comportamento de cache + na Plataforma Azion usando ferramentas MCP e comandos cURL. +meta_tags: 'mcp, cache, teste, debug, otimização, performance' +namespace: documentation_devtools_mcp_cache_testing +menu_namespace: devtoolsMenu +permalink: /documentacao/devtools/mcp/teste-cache/ +--- + +import Code from '~/components/Code/Code.astro' + +Este guia fornece métodos para testar, debugar e otimizar o comportamento de cache na Plataforma Edge da Azion usando ferramentas MCP e comandos cURL diretos. + +--- + +## Headers de debug de cache + +Habilite os headers de debug de cache incluindo `Pragma: azion-debug-cache` em suas requisições. Isso retorna informações detalhadas sobre o cache. + +### Referência de headers de debug + +| Header | Descrição | Valores de Exemplo | +|--------|-----------|-------------------| +| `X-Cache` | Status do cache da requisição | `HIT`, `MISS`, `EXPIRED`, `UPDATING`, `STALE` | +| `X-Cache-Key` | A chave de cache usada para armazenar/recuperar o objeto | `/index.html@@cookie_name=value` | +| `X-Cache-File` | Hash MD5 da chave de cache | `a1b2c3d4e5f6789...` | +| `X-Cache-Since` | Timestamp Unix de quando o objeto foi cacheado | `1640995200` | +| `X-Cache-Expire` | Timestamp Unix de quando o cache expira | `1640995800` | +| `X-Cache-Expire-In` | Segundos restantes até o cache expirar | `600` | +| `X-Cache-Valid` | TTL configurado em segundos | `3600` | +| `X-Cache-Config` | ID de configuração Azion | `1595368520` | +| `X-Cache-ID` | Identificador único para esta requisição | `#AECFE66100000000C947B9B3...` | + +--- + +## Teste básico de cache com cURL + +### Testar domínio edge da Azion + +Sempre comece testando o domínio `.map.azionedge.net` diretamente: + + + +### Testar assets estáticos + + + +### Testar domínio de produção via edge Azion + + + +--- + +## Teste de chave de cache + +### Variações de parâmetros de query + + + +### Variações baseadas em cookies + +/dev/null | grep "X-Cache-Key"`} /> + +--- + +## Teste de performance de cache + +### Teste consistente de localização edge + +Fixe o IP para garantir que ambas as requisições vão para o mesmo servidor edge: + + + +:::note +O TTFB deve ser significativamente menor na segunda requisição quando o conteúdo é servido do cache. +::: + +### Comparação de provedores + + + +--- + +## Informações de rede + +Obtenha informações de rede incluindo seu IP, resolver e localização edge: + + + +Isso fornece: +- Seu IP público (útil para buscar nos logs Azion) +- Resolver DNS sendo usado +- Localização edge Azion servindo a requisição +- Status de saúde da rede + +--- + +## Monitoramento de Real-Time Events + +### Usando Azion CLI + + + +### Variáveis de log chave para análise de cache + +| Variável | Descrição | Exemplo | +|----------|-----------|---------| +| `Cache Key` | Chave de cache usada | `/index.html@@cookie_name=value` | +| `Cache TTL` | Duração do cache em segundos | `31536000` | +| `Upstream Cache Status` | Status do cache | `HIT`, `MISS`, `BYPASS`, `EXPIRED`, `STALE` | +| `Upstream Response Time` | Tempo de resposta da origem | `-` para conteúdo cacheado | +| `Bytes Sent` | Total de bytes entregues | `1024` | +| `Request Time` | Tempo total de processamento | `0.001` | + +--- + +## Queries GraphQL para análise de cache + +Use a ferramenta `create_graphql_query` do MCP ou execute diretamente: + + + +### Indicadores chave de performance + +- **Taxa de Cache Hit**: Deve ser >80% para conteúdo estático +- **Edge Offload**: Porcentagem de requisições servidas do cache vs origem +- **Tempo de Resposta da Origem**: Compare requisições cacheadas vs não-cacheadas +- **Economia de Bandwidth**: Bytes servidos do cache vs origem + +--- + +## Configuração de cache via CLI + +### Criar configurações de cache + + + +### Aplicar via Rules Engine + + + +--- + +## Estratégias de otimização de cache + +### Estratégia de query string + +| Estratégia | Caso de uso | Configuração | +|------------|-------------|--------------| +| **Ignorar todas** | Assets estáticos | `--cache-by-query-string "ignore"` | +| **Whitelist** | APIs com params funcionais | `--cache-by-query-string "whitelist"` com params específicos | +| **Blacklist** | Ignorar params de tracking | `--cache-by-query-string "blacklist"` com utm_*, fbclid, gclid | + +### Estratégia de cookies + +| Estratégia | Caso de uso | Configuração | +|------------|-------------|--------------| +| **Ignorar todos** | Conteúdo estático | `--cache-by-cookies "ignore"` | +| **Whitelist** | Conteúdo personalizado | `--cache-by-cookies "whitelist"` com language, currency | + +### Estratégia de TTL por tipo de conteúdo + +| Tipo de Conteúdo | TTL Recomendado | Exemplo | +|------------------|-----------------|---------| +| Assets estáticos | 30 dias | `2592000` segundos | +| Semi-estático | 1 hora | `3600` segundos | +| Dinâmico | 5 minutos | `300` segundos | +| Tempo real | 30 segundos | `30` segundos | + +--- + +## Script automatizado de verificação de cache + + HIT"`} /> + +--- + +## Solução de problemas de cache + +### Baixa taxa de cache hit (< 60%) + +**Diagnóstico:** + + + +**Soluções:** +- Configure `cache-by-query-string` para `ignore` para conteúdo estático +- Use `whitelist` para cookies em vez de cachear por todos os cookies +- Implemente regras de bypass para usuários autenticados + +### Conteúdo stale não atualizando + +**Diagnóstico:** + + + +**Soluções:** + + + +### Conteúdo dinâmico sendo cacheado + +**Diagnóstico:** + + + +**Soluções:** +- Adicione regra de bypass para caminhos de conteúdo personalizado +- Configure as configurações de `cacheByCookie` adequadamente +- Use TTLs mais curtos para conteúdo específico do usuário + +--- + +## Boas práticas + +1. **Use `Pragma: azion-debug-cache`** para debug imediato de cache +2. **Monitore Real-Time Events** para análise de comportamento de cache +3. **Teste variações de chave de cache** com diferentes parâmetros/cookies +4. **Implemente estratégia de TTL em camadas** baseada no tipo de conteúdo +5. **Use stale-while-revalidate** para melhor disponibilidade +6. **Monitore taxas de cache hit** e otimize configurações +7. **Purgue estrategicamente** usando wildcards e chaves de cache +8. **Teste de múltiplas localizações edge** usando conexões IP diretas +9. **Automatize verificações de saúde do cache** com scripts shell +10. **Meça diferenças de performance** entre requisições cacheadas e não-cacheadas + +--- + +## Próximos passos + +- [Guia de Configuração MCP](/pt-br/documentacao/devtools/mcp/configuracao/) +- [Exemplos MCP](/pt-br/documentacao/devtools/mcp/exemplos/) +- [Solução de Problemas MCP](/pt-br/documentacao/devtools/mcp/solucao-de-problemas/)