diff --git a/README.md b/README.md index b20297d..c28277e 100644 --- a/README.md +++ b/README.md @@ -115,12 +115,9 @@ The API is configured via environment variables. Create a `.env` file or set the | `ADDITIONAL_RESOLVERS` | Comma-separated list of resolver types to generate | - | No | | `LOG_LEVELS` | Comma-separated list of log levels to enable (e.g. `DEBUG,INFO,ERROR`) | - | No | | `VERBOSITY` | Verbosity level for GraphQL logging (0=off, 1=parameters, 2=parameters+responses) | `0` | No | -| `VERBOSITY_PARAMETERS` | Enable detailed logging of parameters for GraphQL requests | `0` | No | -| `VERBOSITY_RESPONSES` | Enable detailed logging of responses for GraphQL requests | `0` | No | -| `MCP_LOG_LEVEL` | Log level for the MCP server (`trace`, `debug`, `info`, `warn`, `error`) | `info` | No | -| `APOLLO_MCP_SERVER_VERSION` | Version tag for the Apollo MCP server Docker image (minimum recommended and tested with: `v1.7.0`) | `v1.7.0` | No | -| `MCP_LOG_PARAMETERS` | **(Deprecated)** Use `VERBOSITY_PARAMETERS` instead. | `false` | No | -| `MCP_LOG_RESPONSES` | **(Deprecated)** Use `VERBOSITY_RESPONSES` instead. | `false` | No | +| `MCP_LOG_LEVEL` | Log level for the MCP server | `info` | No | +| `MCP_LOG_PARAMETERS` | Whether to log parameters of MCP calls | `false` | No | +| `MCP_LOG_RESPONSES` | Whether to log responses of MCP calls | `false` | No | | `HOST_TYPE_FILTER_DEFAULT` | Default filter for host types | - | No | | `HOST_GROUP_FILTER_DEFAULT` | Default filter for host groups | - | No | diff --git a/docker-compose.yml b/docker-compose.yml index b667ccd..c938d1f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,16 +12,14 @@ services: - SCHEMA_PATH=/usr/app/dist/schema/ - ZABBIX_DEVELOPMENT_TOKEN=${ZABBIX_DEVELOPMENT_TOKEN} - VERBOSITY=${VERBOSITY:-0} - - VERBOSITY_PARAMETERS=${VERBOSITY_PARAMETERS:-0} - - VERBOSITY_RESPONSES=${VERBOSITY_RESPONSES:-0} - LOG_LEVELS=${LOG_LEVELS:-INFO} volumes: - ./samples:/usr/app/dist/samples apollo-mcp-server: - image: ghcr.io/apollographql/apollo-mcp-server:${APOLLO_MCP_SERVER_VERSION:-v1.7.0} + image: ghcr.io/apollographql/apollo-mcp-server:latest ports: - - "3000:3000" + - "3000:8000" volumes: - ./mcp-config.yaml:/mcp-config.yaml - mcp-shared:/mcp-data:ro @@ -30,8 +28,8 @@ services: environment: - APOLLO_GRAPH_REF=local@main - MCP_LOG_LEVEL=${MCP_LOG_LEVEL:-info} - # Note: MCP_LOG_PARAMETERS and MCP_LOG_RESPONSES are deprecated and not supported by apollo-mcp-server v1.7.0+ - # Detailed logging is handled by the zabbix-graphql-api service via the VERBOSITY variable. + - MCP_LOG_PARAMETERS=${MCP_LOG_PARAMETERS:-false} + - MCP_LOG_RESPONSES=${MCP_LOG_RESPONSES:-false} depends_on: schema-gen: condition: service_completed_successfully @@ -45,7 +43,7 @@ services: - mcp-shared:/mcp-data command: sh -c "cat /schema/*.graphql > /mcp-data/schema.graphql" - zabbix-db: + postgres-server: image: postgres:16-alpine profiles: - zabbix-local @@ -63,13 +61,13 @@ services: ports: - "10051:10051" environment: - - DB_SERVER_HOST=zabbix-db + - DB_SERVER_HOST=postgres-server - POSTGRES_USER=zabbix - POSTGRES_PASSWORD=zabbix - POSTGRES_DB=zabbix - ZBX_ALLOWUNSUPPORTEDDBVERSIONS=1 depends_on: - - zabbix-db + - postgres-server zabbix-web: image: zabbix/zabbix-web-nginx-pgsql:${ZABBIX_VERSION:-alpine-7.0-latest} @@ -79,14 +77,14 @@ services: - "8080:8080" environment: - ZBX_SERVER_HOST=zabbix-server - - DB_SERVER_HOST=zabbix-db + - DB_SERVER_HOST=postgres-server - POSTGRES_USER=zabbix - POSTGRES_PASSWORD=zabbix - POSTGRES_DB=zabbix - PHP_TZ=UTC - ZBX_ALLOWUNSUPPORTEDDBVERSIONS=1 depends_on: - - zabbix-db + - postgres-server - zabbix-server volumes: diff --git a/docs/howtos/local_development.md b/docs/howtos/local_development.md index 4c9bf96..99bc147 100644 --- a/docs/howtos/local_development.md +++ b/docs/howtos/local_development.md @@ -8,7 +8,7 @@ The project includes a Docker Compose profile that launches a complete Zabbix st ### Included Services - **`zabbix-graphql-api`**: The main GraphQL server. - **`apollo-mcp-server`**: The Model Context Protocol server for AI integration. -- **`zabbix-db`**: PostgreSQL 16 database for Zabbix. +- **`postgres-server`**: PostgreSQL 16 database for Zabbix. - **`zabbix-server`**: Zabbix Server (PostgreSQL version). - **`zabbix-web`**: Zabbix Web interface (Nginx/PostgreSQL). diff --git a/docs/howtos/mcp.md b/docs/howtos/mcp.md index 7124f08..1c3752f 100644 --- a/docs/howtos/mcp.md +++ b/docs/howtos/mcp.md @@ -13,7 +13,7 @@ By leveraging GraphQL, the API provides a strongly-typed and introspectable inte You can start both the Zabbix GraphQL API and the Apollo MCP Server using Docker Compose. This setup uses a local `mcp-config.yaml` and a generated `schema.graphql`. -- **Prerequisites**: Ensure you have a `.env` file with the required Zabbix connection details and the `APOLLO_MCP_SERVER_VERSION` variable (minimum recommended and tested with: `v1.7.0`). +- **Prerequisites**: Ensure you have a `.env` file with the required Zabbix connection details. - **Prepare Operations**: Create the operations directory if it doesn't exist: ```bash mkdir -p mcp/operations @@ -25,7 +25,7 @@ You can start both the Zabbix GraphQL API and the Apollo MCP Server using Docker This will: - Start the `zabbix-graphql-api` on `http://localhost:4001/graphql` (internal port 4000). -- Start the `apollo-mcp-server` on `http://localhost:3000/mcp` (internal port 3000), configured to connect to the local API via `mcp-config.yaml`. +- Start the `apollo-mcp-server` on `http://localhost:3000/mcp` (mapped from internal port 8000), configured to connect to the local API via `mcp-config.yaml`. ### Using with Claude Desktop @@ -50,7 +50,7 @@ To use this integration with Claude Desktop, add the following configuration to "-v", "/path/to/your/project/schema.graphql:/mcp-data/schema.graphql:ro", "-v", "/path/to/your/project/mcp/operations:/mcp/operations", "-e", "APOLLO_GRAPH_REF=local@main", - "ghcr.io/apollographql/apollo-mcp-server:v1.7.0", + "ghcr.io/apollographql/apollo-mcp-server:latest", "/mcp-config.yaml" ] } @@ -110,13 +110,9 @@ You can control the logging level and verbosity of both the GraphQL API and the - **GraphQL API Verbosity**: - `VERBOSITY=1`: Logs GraphQL operation names and parameters (variables). - `VERBOSITY=2`: Logs operation names, parameters, and the full response body. - - `VERBOSITY_PARAMETERS=1`: Specifically enable parameter logging (can be used independently of `VERBOSITY`). - - `VERBOSITY_RESPONSES=1`: Specifically enable response logging (can be used independently of `VERBOSITY`). - **MCP Server Logging**: - - `MCP_LOG_LEVEL`: Sets the log level for the Apollo MCP server (`trace`, `debug`, `info`, `warn`, `error`). - - `debug`: Recommended for development as it provides a full configuration dump and detailed tool loading information. - - `trace`: extremely verbose, including periodic file system rescan events. - - `info`: Default level, provides a clean output while suppressing noisy internal library logs. - - *Note*: As of `apollo-mcp-server` v1.7.0, environment variable expansion in `mcp-config.yaml` requires the `env.` prefix (e.g. `${env.MCP_LOG_LEVEL:-info}`). Additionally, the previously used `MCP_LOG_PARAMETERS` and `MCP_LOG_RESPONSES` are **not supported** and will cause a startup failure if present in the config file. These have been replaced by API-level verbosity settings (`VERBOSITY_PARAMETERS` and `VERBOSITY_RESPONSES`). + - `MCP_LOG_LEVEL`: Sets the log level for the Apollo MCP server (`debug`, `info`, `warn`, `error`). + - `MCP_LOG_PARAMETERS=true`: Enables logging of parameters in the MCP server. + - `MCP_LOG_RESPONSES=true`: Enables logging of responses in the MCP server. When running via Docker Compose, these can be set in your `.env` file. diff --git a/mcp-config.yaml b/mcp-config.yaml index c900c32..035c784 100644 --- a/mcp-config.yaml +++ b/mcp-config.yaml @@ -19,4 +19,6 @@ introspection: search: enabled: true logging: - level: ${env.MCP_LOG_LEVEL:-info} + level: ${MCP_LOG_LEVEL:-info} + parameters: ${MCP_LOG_PARAMETERS:-false} + responses: ${MCP_LOG_RESPONSES:-false} diff --git a/src/api/start.ts b/src/api/start.ts index 0dc5e19..7a4ac42 100644 --- a/src/api/start.ts +++ b/src/api/start.ts @@ -63,10 +63,7 @@ async function startApolloServer() { // Request logging plugin { async requestDidStart(requestContext) { - const logParameters = Config.VERBOSITY > 0 || Config.VERBOSITY_PARAMETERS > 0; - const logResponses = Config.VERBOSITY > 1 || Config.VERBOSITY_RESPONSES > 0; - - if (logParameters) { + if (Config.VERBOSITY > 0) { logger.info(`GraphQL Request: ${requestContext.request.operationName || 'Unnamed Operation'}`); if (requestContext.request.variables) { logger.info(`Parameters: ${JSON.stringify(requestContext.request.variables, null, 2)}`); @@ -74,7 +71,7 @@ async function startApolloServer() { } return { async willSendResponse(requestContext) { - if (logResponses) { + if (Config.VERBOSITY > 1) { logger.info(`GraphQL Response for ${requestContext.request.operationName || 'Unnamed Operation'}:`); logger.info(JSON.stringify(requestContext.response.body, null, 2)); } diff --git a/src/common_utils.ts b/src/common_utils.ts index 997027a..0f9efdd 100644 --- a/src/common_utils.ts +++ b/src/common_utils.ts @@ -16,8 +16,6 @@ static readonly DRY_RUN = process.env.DRY_RUN static readonly ZABBIX_PERMISSION_TEMPLATE_GROUP_NAME_PREFIX = process.env.ZABBIX_PERMISSION_TEMPLATE_GROUP_NAME_PREFIX || "Permissions" static readonly LOG_LEVELS = process.env.LOG_LEVELS static readonly VERBOSITY = process.env.VERBOSITY ? parseInt(process.env.VERBOSITY) : 0 - static readonly VERBOSITY_PARAMETERS = process.env.VERBOSITY_PARAMETERS ? (parseInt(process.env.VERBOSITY_PARAMETERS) || (process.env.VERBOSITY_PARAMETERS === 'true' ? 1 : 0)) : 0 - static readonly VERBOSITY_RESPONSES = process.env.VERBOSITY_RESPONSES ? (parseInt(process.env.VERBOSITY_RESPONSES) || (process.env.VERBOSITY_RESPONSES === 'true' ? 1 : 0)) : 0 static readonly HOST_TYPE_FILTER_DEFAULT = process.env.HOST_TYPE_FILTER_DEFAULT; static readonly HOST_GROUP_FILTER_DEFAULT = process.env.HOST_GROUP_FILTER_DEFAULT; } \ No newline at end of file