From f3336697a04262cb8536026619d61e29e7fbef15 Mon Sep 17 00:00:00 2001 From: Nicholas Cioli Date: Thu, 17 Jul 2025 13:59:38 -0400 Subject: [PATCH 1/4] feat!: use new config file for MCP This commit updates the MCP run script to use the new config file instead of arguments to comply with breaking changes in the MCP server. BREAKING: Certain environment variables are now ignored. --- Dockerfile | 2 +- README.md | 12 +--- config/mcp_config.yaml | 23 +++++++ s6_service_definitions/mcp/run | 115 ++++++++++++++------------------- 4 files changed, 74 insertions(+), 78 deletions(-) create mode 100644 config/mcp_config.yaml diff --git a/Dockerfile b/Dockerfile index f86c619..2241dfb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ ARG S6_OVERLAY_VERSION=3.2.1.0 # renovate: datasource=github-releases depName=apollographql/router ARG APOLLO_ROUTER_VERSION=2.4.0 # renovate: datasource=github-releases depName=apollographql/apollo-mcp-server -ARG APOLLO_MCP_SERVER_VERSION=0.5.2 +ARG APOLLO_MCP_SERVER_VERSION=0.6.0 LABEL org.opencontainers.image.version=0.0.8 LABEL org.opencontainers.image.vendor="Apollo GraphQL" diff --git a/README.md b/README.md index a4339f3..431b02b 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ If you wish to enable it for testing purposes then set the environment variable ... ``` -See [below](#configuring-using-environment-variables) for information on configuring the MCP Server +See the example [config file](config/mcp_config.yaml) for information on configuring the MCP Server. ## Configuring Using Local Files @@ -149,14 +149,4 @@ these are as follows: |----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `APOLLO_KEY` | A valid API Key for Apollo Studio | | `APOLLO_GRAPH_REF` | The Graph Ref in Apollo Studio referenced by the Router and MCP Server | -| `MCP_ALLOW_MUTATIONS` | Possible values: `none`, don't allow any mutations, `explicit` allow explicit mutations, but don't allow the LLM to build them, `all` Allow the LLM to build mutations | -| `MCP_COLLECTION` | The ID of an operation collection to use as the source for operations (requires `APOLLO_KEY`). | -| `MCP_DISABLE_TYPE_DESCRIPTION` | Disable operation root field types in tool description | -| `MCP_DISABLE_SCHEMA_DESCRIPTION` | Disable schema type definitions referenced by all fields returned by the operation in the tool description | | `MCP_ENABLE` | Enable the MCP Server | -| `MCP_EXPLORER` | Expose a tool that returns the URL to open a GraphQL operation in Apollo Explorer (requires `APOLLO_GRAPH_REF`) | -| `MCP_HEADERS` | A list of comma separated, key value pairs (separated by `:`s), of headers to send to the GraphQL endpoint | -| `MCP_INTROSPECTION` | Enable the `--introspection` option for the MCP Server | -| `MCP_LOG_LEVEL` | Change the level at which the MCP Server logs, possible values: `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE` | -| `MCP_SSE` | Use SSE as the transport protocol rather than streamable HTTP | -| `MCP_UPLINK_MANIFEST` | Enable use of Uplink to get the persisted queries (Requires `APOLLO_KEY` and `APOLLO_GRAPH_REF`) | diff --git a/config/mcp_config.yaml b/config/mcp_config.yaml new file mode 100644 index 0000000..1d02249 --- /dev/null +++ b/config/mcp_config.yaml @@ -0,0 +1,23 @@ +# yaml-language-server: $schema=../../mcp-apollo/schema.json + +################################################################################ +# Example MCP configuration +# +# Note that some of these options are overwritten by the run script depending on +# the presence of certain files. Refer to the README for more information. +################################################################################ + +# Use uplink for operations +operations: + source: uplink + +# Use uplink for schema information +schema: + source: uplink + +# Configure the MCP server to listen for streamable HTTP messages on port 5000 +# for all addresses +transport: + type: streamable_http + address: "0.0.0.0" + port: 5000 diff --git a/s6_service_definitions/mcp/run b/s6_service_definitions/mcp/run index 5a00c08..e64ec1a 100755 --- a/s6_service_definitions/mcp/run +++ b/s6_service_definitions/mcp/run @@ -3,72 +3,55 @@ # Set our working directory cd /opt || exit -if [ -v MCP_ENABLE ]; then - - if [[ -f /config/api_schema.graphql ]]; then - ARGS+=(--schema /config/api_schema.graphql) - fi - - if [[ -f /config/custom_scalars.graphql ]]; then - ARGS+=(--custom-scalars-config /config/custom_scalars.graphql) - fi - - if [[ -v MCP_HEADERS ]]; then - IFS=',' read -ra HEADERS <<< "$MCP_HEADERS" - for header in "${HEADERS[@]}"; do - ARGS+=(--header "$header") - done - fi - - if [[ -v MCP_SSE ]]; then - ARGS+=(--sse-address 0.0.0.0) - else - ARGS+=(--http-address 0.0.0.0) - fi - - if [[ -v MCP_INTROSPECTION ]]; then - ARGS+=(--introspection) - fi - - if [[ -v MCP_UPLINK_MANIFEST ]]; then - ARGS+=(--uplink-manifest) - fi - - if [[ -v MCP_COLLECTION ]]; then - ARGS+=(--collection "$MCP_COLLECTION") - fi - - # Only pass through operations if the folder contains files - if [ "$(ls -A /config/operations)" ]; then - ARGS+=(--operations /config/operations) - fi +LOCAL_CUSTOM_SCALARS="/config/custom_scalars.graphql" +LOCAL_OPERATIONS="/config/operations" +LOCAL_SCHEMA="/config/api_schema.graphql" +LOCAL_PQ_MANIFEST="/config/persisted_queries_manifest.json" + +# Options set below are overrides using environment variables that match the +# format expected by the MCP server, which is as follows: +# +# - The prefix `APOLLO_MCP_` +# - The keys of the setting, separated by `__` for nesting +# +# e.g. The key `introspection.execute.enabled` would correspond to the env var +# `APOLLO_MCP_INTROSPECTION__EXECUTE__ENABLED`. - if [[ -v MCP_EXPLORER ]]; then - ARGS+=(--explorer) - fi - - if [[ -f /config/persisted_queries_manifest.json ]]; then - ARGS+=(--manifest /config/persisted_queries_manifest.json) - fi - - if [[ -v MCP_DISABLE_TYPE_DESCRIPTION ]]; then - ARGS+=(--disable-type-description) - fi - - if [[ -v MCP_DISABLE_SCHEMA_DESCRIPTION ]]; then - ARGS+=(--disable-schema-description) - fi - - if [[ -v MCP_ALLOW_MUTATIONS ]]; then - ARGS+=(--allow-mutations "$MCP_ALLOW_MUTATIONS") - fi - - if [[ -v MCP_LOG_LEVEL ]]; then - ARGS+=(--log "$MCP_LOG_LEVEL") - fi - - exec /opt/apollo-mcp-server "${ARGS[@]}" +if [ -v MCP_ENABLE ]; then + # If the user has provided an API schema, then overwrite the default config + # option of using uplink to use the file instead + if [[ -f "$LOCAL_SCHEMA" ]]; then + echo "Using local API schema found at $LOCAL_SCHEMA instead of uplink. Delete this file to use uplink instead" + + export APOLLO_MCP_SCHEMA__SOURCE="local" + export APOLLO_MCP_SCHEMA__PATH="$LOCAL_SCHEMA" + fi + + # If the user has provided a custom scalar map, then overwrite the default config + # option of using uplink to use the supplied file instead + if [[ -f "$LOCAL_CUSTOM_SCALARS" ]]; then + echo "Using custom scalar map found at $LOCAL_CUSTOM_SCALARS. Delete this file to disable" + + export APOLLO_MCP_CUSTOM_SCALARS="$LOCAL_CUSTOM_SCALARS" + fi + + # For the operation source, the user can either place operations in the + # right folder, or place a PQ manifest. If both are supplied, then the PQ manifest + # takes precedence. + if [[ -f "$LOCAL_PQ_MANIFEST" ]]; then + echo "Using persisted query manifest found at $LOCAL_PQ_MANIFEST." + echo " NOTE: If you wish to use local operations in $LOCAL_OPERATIONS instead, make sure to remove the manifest first" + + export APOLLO_MCP_OPERATIONS__SOURCE="manifest" + export APOLLO_MCP_OPERATIONS__PATH="$LOCAL_PQ_MANIFEST" + elif [ "$(ls -A $LOCAL_OPERATIONS)" ]; then + echo "Using operations contained in $LOCAL_OPERATIONS" + + export APOLLO_MCP_OPERATIONS__SOURCE="local" + export APOLLO_MCP_OPERATIONS__PATHS="[$LOCAL_OPERATIONS]" + fi + + exec /opt/apollo-mcp-server "/config/mcp_config.yaml" else - while true; do sleep 10000; done + while true; do sleep 10000; done fi - From ef28ba5e92756e0d3e2ba2ec9445481a2f86ffdd Mon Sep 17 00:00:00 2001 From: Nicholas Cioli Date: Mon, 28 Jul 2025 16:44:49 -0400 Subject: [PATCH 2/4] remove local schema reference --- config/mcp_config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/mcp_config.yaml b/config/mcp_config.yaml index 1d02249..3b4849c 100644 --- a/config/mcp_config.yaml +++ b/config/mcp_config.yaml @@ -1,4 +1,4 @@ -# yaml-language-server: $schema=../../mcp-apollo/schema.json +# yaml-language-server: $schema=https://github.com/apollographql/apollo-mcp-server/releases/download/v0.6.0/config.schema.json ################################################################################ # Example MCP configuration From 8c5296906eb6294eb77067743e909bcbb065d61a Mon Sep 17 00:00:00 2001 From: Nicholas Cioli Date: Mon, 28 Jul 2025 16:53:13 -0400 Subject: [PATCH 3/4] address comments Co-authored-by: jonathanrainer --- config/mcp_config.yaml | 36 ++++++++++++++++++++++++++++++-- s6_service_definitions/mcp/run | 38 ---------------------------------- 2 files changed, 34 insertions(+), 40 deletions(-) diff --git a/config/mcp_config.yaml b/config/mcp_config.yaml index 3b4849c..ebc466a 100644 --- a/config/mcp_config.yaml +++ b/config/mcp_config.yaml @@ -3,15 +3,47 @@ ################################################################################ # Example MCP configuration # -# Note that some of these options are overwritten by the run script depending on -# the presence of certain files. Refer to the README for more information. +# Note: Refer to the official documentation for info on what should be present +# https://www.apollographql.com/docs/apollo-mcp-server/command-reference ################################################################################ +# If you have custom scalars that you wish to use in your operations / schema, use the following +# configuration +# +# ```yaml +# custom_scalars: /config/custom_scalars.graphql +# ``` + # Use uplink for operations +# +# Note: If you wish to use files inside the container instead, use the following configuration: +# +# ```yaml +# operations: +# source: local +# paths: +# - /config/operations +# ``` +# +# Note: If you wish to use a persisted query manifest instead, use the following configuration: +# +# ```yaml +# operations: +# source: manifest +# path: /config/persisted_queries_manifest.json +# ``` operations: source: uplink # Use uplink for schema information +# +# Note: If you wish to use a file inside the container instead, use the following configuration: +# +# ```yaml +# schema: +# source: local +# path: /config/api_schema.graphql +# ``` schema: source: uplink diff --git a/s6_service_definitions/mcp/run b/s6_service_definitions/mcp/run index e64ec1a..38e97d0 100755 --- a/s6_service_definitions/mcp/run +++ b/s6_service_definitions/mcp/run @@ -3,11 +3,6 @@ # Set our working directory cd /opt || exit -LOCAL_CUSTOM_SCALARS="/config/custom_scalars.graphql" -LOCAL_OPERATIONS="/config/operations" -LOCAL_SCHEMA="/config/api_schema.graphql" -LOCAL_PQ_MANIFEST="/config/persisted_queries_manifest.json" - # Options set below are overrides using environment variables that match the # format expected by the MCP server, which is as follows: # @@ -18,39 +13,6 @@ LOCAL_PQ_MANIFEST="/config/persisted_queries_manifest.json" # `APOLLO_MCP_INTROSPECTION__EXECUTE__ENABLED`. if [ -v MCP_ENABLE ]; then - # If the user has provided an API schema, then overwrite the default config - # option of using uplink to use the file instead - if [[ -f "$LOCAL_SCHEMA" ]]; then - echo "Using local API schema found at $LOCAL_SCHEMA instead of uplink. Delete this file to use uplink instead" - - export APOLLO_MCP_SCHEMA__SOURCE="local" - export APOLLO_MCP_SCHEMA__PATH="$LOCAL_SCHEMA" - fi - - # If the user has provided a custom scalar map, then overwrite the default config - # option of using uplink to use the supplied file instead - if [[ -f "$LOCAL_CUSTOM_SCALARS" ]]; then - echo "Using custom scalar map found at $LOCAL_CUSTOM_SCALARS. Delete this file to disable" - - export APOLLO_MCP_CUSTOM_SCALARS="$LOCAL_CUSTOM_SCALARS" - fi - - # For the operation source, the user can either place operations in the - # right folder, or place a PQ manifest. If both are supplied, then the PQ manifest - # takes precedence. - if [[ -f "$LOCAL_PQ_MANIFEST" ]]; then - echo "Using persisted query manifest found at $LOCAL_PQ_MANIFEST." - echo " NOTE: If you wish to use local operations in $LOCAL_OPERATIONS instead, make sure to remove the manifest first" - - export APOLLO_MCP_OPERATIONS__SOURCE="manifest" - export APOLLO_MCP_OPERATIONS__PATH="$LOCAL_PQ_MANIFEST" - elif [ "$(ls -A $LOCAL_OPERATIONS)" ]; then - echo "Using operations contained in $LOCAL_OPERATIONS" - - export APOLLO_MCP_OPERATIONS__SOURCE="local" - export APOLLO_MCP_OPERATIONS__PATHS="[$LOCAL_OPERATIONS]" - fi - exec /opt/apollo-mcp-server "/config/mcp_config.yaml" else while true; do sleep 10000; done From dcb54ccacdda162fb8faf01ab8371a32eb62b71a Mon Sep 17 00:00:00 2001 From: Nicholas Cioli Date: Tue, 29 Jul 2025 11:23:08 -0400 Subject: [PATCH 4/4] address comments --- s6_service_definitions/mcp/run | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/s6_service_definitions/mcp/run b/s6_service_definitions/mcp/run index 38e97d0..33dd7f3 100755 --- a/s6_service_definitions/mcp/run +++ b/s6_service_definitions/mcp/run @@ -3,14 +3,8 @@ # Set our working directory cd /opt || exit -# Options set below are overrides using environment variables that match the -# format expected by the MCP server, which is as follows: -# -# - The prefix `APOLLO_MCP_` -# - The keys of the setting, separated by `__` for nesting -# -# e.g. The key `introspection.execute.enabled` would correspond to the env var -# `APOLLO_MCP_INTROSPECTION__EXECUTE__ENABLED`. +# See documentation for available options +# https://www.apollographql.com/docs/apollo-mcp-server/command-reference if [ -v MCP_ENABLE ]; then exec /opt/apollo-mcp-server "/config/mcp_config.yaml"