### Copy Example Prompts Source: https://github.com/apollographql/apollo-mcp-server/blob/main/examples/TheSpaceDevs/README.md Copy the example prompt files to the current working directory where the server is started. This makes them available for use with the server. ```sh cp -r examples/TheSpaceDevs/prompts . ``` -------------------------------- ### Navigate and Install Dependencies Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-quickstart.mdx Change into the newly created project directory and run the install script to set up all project dependencies and configurations. ```bash cd my-awesome-app ./install.sh ``` -------------------------------- ### MCP Server Output Example Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/debugging.mdx This is an example of the output you can expect when the MCP Inspector starts successfully over stdio. ```sh Starting MCP inspector... ⚙️ Proxy server listening on port 6277 🔍 MCP Inspector is up and running at http://127.0.0.1:6274 🚀 ``` -------------------------------- ### Clone Apollo MCP Server Repository Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/guides/auth-auth0.mdx Clone the repository for the example project to get started. ```sh git clone git@github.com:apollographql/apollo-mcp-server.git ``` -------------------------------- ### Apollo Client AI Apps Configuration Example Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-reference.mdx Example configuration file for Apollo Client AI Apps. Demonstrates how to set app name, description, version, entry points for different modes, CSP directives, widget settings, and tool invocation labels. ```typescript // apollo-client-ai-apps.config.ts import { ApolloClientAiAppsConfig } from "@apollo/client-ai-apps/config"; const config: ApolloClientAiAppsConfig.Config = { name: "My App", description: "My app description", version: "1.0.0", entry: { // Override the default entry point configuration for the 'development' mode. // When the value is a string, the location is used for both MCP and ChatGPT apps. development: "", // Override the default entry point configuration for the 'production' mode. production: { // Configures the 'mcp' environment entry point in production mode mcp: "...", // Configures the 'openai' environment entry point in production mode openai: "...", }, // All other keys are treated as custom modes which need a `--mode` option // provided to the vite CLI. staging: { /* ... */ }, }, csp: { connectDomains: ["https://example.com"], frameDomains: ["https://example.com"], redirectDomains: ["https://example.com"], resourceDomains: ["https://example.com"], baseUriDomains: ["https://example.com"], }, widgetSettings: { prefersBorder: true, description: "My widget description for ChatGPT apps", domain: "https://example.com", }, labels: { toolInvocation: { invoking: "Tool working...", invoked: "Complete!", }, }, }; export default config; ``` -------------------------------- ### Start MCP Server in Streamable HTTP Mode Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/debugging.mdx Run this command to start the MCP Server using the provided configuration for Streamable HTTP transport. This prepares the server for remote inspection. ```sh target/debug/apollo-mcp-server ``` -------------------------------- ### Start Demo GraphQL API Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-quickstart.mdx Initiate the demo e-commerce GraphQL API. This service is typically run in a separate terminal window. ```bash cd ecommerce-graph npm run dev ``` -------------------------------- ### Example Rover Command for Subgraph Publish Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/guides/auth-auth0.mdx This is an example command to publish a subgraph. You need to retrieve `YOUR_APOLLO_KEY` and `YOUR_APOLLO_GRAPH_REF` from a similar modal in GraphOS Studio. ```sh APOLLO_KEY= \ rover subgraph publish \ --schema ./products-schema.graphql \ --name your-subgraph-name \ --routing-url http://products.prod.svc.cluster.local:4001/graphql ``` -------------------------------- ### Install Latest Apollo MCP Server (Windows) Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/run.mdx Installs the latest release of Apollo MCP Server using PowerShell's Invoke-WebRequest. This is suitable for quick setup on Windows. ```terminal iwr 'https://mcp.apollo.dev/download/win/latest' | iex ``` -------------------------------- ### Start React App for E2E Testing Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-quickstart.mdx Build and serve the React application for end-to-end testing with your host. This is run in a separate terminal. ```bash cd dev/the-store npm run dev:e2e ``` -------------------------------- ### Start Local Observability Stack with Docker Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/telemetry.mdx Run the Grafana OTel LGTM stack locally to collect and visualize telemetry data. This command starts the necessary services for metrics and tracing. ```bash docker run -p 3000:3000 -p 4317:4317 -p 4318:4318 --rm -ti grafana/otel-lgtm ``` -------------------------------- ### Start React App for Local Development Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-quickstart.mdx Build and serve the React application for local development and testing within an emulator. This is run in a separate terminal. ```bash cd dev/the-store npm run dev ``` -------------------------------- ### Start MCP Server Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-quickstart.mdx Launch the Apollo MCP Server from the project root. This service loads app artifacts, connects to the GraphQL API, and serves the React app. ```bash ./start_mcp.sh ``` -------------------------------- ### Install Release Candidate Apollo MCP Server (Windows) Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/run.mdx Installs a release candidate version of Apollo MCP Server using PowerShell. Recommended for testing early builds. Note the `v` prefix and `-rc` suffix. ```terminal # Note the `v` prefixing the version number and the `-rc` suffix iwr 'https://mcp.apollo.dev/download/win/v1.14.0-rc.1' | iex ``` -------------------------------- ### Install Latest Apollo MCP Server (Linux/MacOS) Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/run.mdx Installs the latest release of Apollo MCP Server using curl. This is suitable for quick setup on Linux or MacOS. ```terminal curl -sSL https://mcp.apollo.dev/download/nix/latest | sh ``` -------------------------------- ### Platform-Specific Module Example Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-development.mdx Demonstrates how to create platform-specific modules using file extensions like `.openai.tsx` or `.mcp.tsx`. This allows for code that is only available to the targeted host. ```tsx import { Home } from "./Home"; ``` -------------------------------- ### Start MCP Inspector for Streamable HTTP Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/debugging.mdx Execute this command to launch the MCP Inspector. It will then prompt for connection details to the Streamable HTTP server. ```sh npx @modelcontextprotocol/inspector ``` -------------------------------- ### Run MCP Server and Router with Auth0 Configuration Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/guides/auth-auth0.mdx Start the MCP Server and router using `rover dev`, providing the necessary configuration files and GraphOS credentials. ```sh APOLLO_GRAPH_REF= APOLLO_KEY= \ rover dev --supergraph-config ./graphql/TheSpaceDevs/supergraph.yaml \ --router-config ./graphql/TheSpaceDevs/router.yaml \ --mcp ./graphql/TheSpaceDevs/config.yaml ``` -------------------------------- ### Run MCP Inspector Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/guides/auth-auth0.mdx Start the MCP Inspector from your terminal. This will open a browser window for the authentication flow. ```sh npx @modelcontextprotocol/inspector ``` -------------------------------- ### Install Specific Apollo MCP Server Version (Windows) Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/run.mdx Installs a specific version of Apollo MCP Server using PowerShell. Recommended for CI environments to ensure predictable behavior. Note the `v` prefix. ```terminal # Note the `v` prefixing the version number iwr 'https://mcp.apollo.dev/download/win/v1.14.0' | iex ``` -------------------------------- ### Call a prompt with arguments Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/prompts.mdx An example of an AI client requesting to execute the 'astronaut_bio' prompt with a specific argument value. ```json {"name": "astronaut_bio", "arguments": {"name": "Chris Hadfield"}} ``` -------------------------------- ### Run Apollo MCP Server with Config Source: https://github.com/apollographql/apollo-mcp-server/blob/main/AGENTS.md Commands to run the Apollo MCP Server binary. Use `cargo run -p apollo-mcp-server -- path/to/config.yaml` to start with a specific configuration file, or `cargo run -p apollo-mcp-server` to start using environment variables only. ```bash cargo run -p apollo-mcp-server -- path/to/config.yaml ``` ```bash cargo run -p apollo-mcp-server ``` -------------------------------- ### Example Config Using Introspection Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/define-tools.mdx Configuration enabling various introspection tools like execute, introspect, search, and validate. Includes minification settings and memory limits for search indexing. ```yaml introspection: execute: enabled: true introspect: enabled: true minify: true search: enabled: true minify: true index_memory_bytes: 50000000 leaf_depth: 1 validate: enabled: true ``` -------------------------------- ### Install Release Candidate Apollo MCP Server (Linux/MacOS) Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/run.mdx Installs a release candidate version of Apollo MCP Server using curl. Recommended for testing early builds. Note the `v` prefix and `-rc` suffix. ```terminal # Note the `v` prefixing the version number and the `-rc` suffix curl -sSL https://mcp.apollo.dev/download/nix/v1.14.0-rc.1 | sh ``` -------------------------------- ### Connect to Apollo MCP Server from Browser Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/cors.mdx Example JavaScript function demonstrating how to establish a connection to the Apollo MCP Server from a browser using fetch. It sends an 'initialize' request and extracts the session ID from response headers. ```javascript async function connectToMCP() { const response = await fetch("http://127.0.0.1:8000/mcp", { method: "POST", headers: { Accept: "application/json, text/event-stream", "Content-Type": "application/json", "MCP-Protocol-Version": "2025-06-18", }, body: JSON.stringify({ jsonrpc: "2.0", method: "initialize", params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "Browser Client", version: "1.0" }, }, id: 1, }), }); // Extract session ID from response headers (automatically exposed) const sessionId = response.headers.get("mcp-session-id"); // Handle SSE format response (starts with "data: ") const responseText = await response.text(); const jsonData = responseText.startsWith("data: ") ? responseText.slice(6) // Remove "data: " prefix : responseText; const result = JSON.parse(jsonData); console.log("Connected:", result); console.log("Session ID:", sessionId); } connectToMCP(); ``` -------------------------------- ### Install or Update Rover CLI Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/guides/auth-auth0.mdx Ensure you have at least v0.37 of the Rover CLI installed or update to the latest version. ```sh curl -sSL https://rover.apollo.dev/nix/latest | sh ``` -------------------------------- ### Run Apollo MCP Server Source: https://github.com/apollographql/apollo-mcp-server/blob/main/examples/TheSpaceDevs/README.md Execute the Apollo MCP Server using a specified configuration file. Ensure you have Cargo installed. ```sh cargo run -- examples/TheSpaceDevs/config.yaml ``` -------------------------------- ### Example config.yaml for introspection-based operations Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/config-file.mdx This configuration sets up Streamable HTTP transport, enables introspection, and derives all operations from introspection. ```yaml transport: type: streamable_http introspection: introspect: enabled: true operations: source: introspect ``` -------------------------------- ### Install Specific Apollo MCP Server Version (Linux/MacOS) Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/run.mdx Installs a specific version of Apollo MCP Server using curl. Recommended for CI environments to ensure predictable behavior. Note the `v` prefix. ```terminal # Note the `v` prefixing the version number curl -sSL https://mcp.apollo.dev/download/nix/v1.14.0 | sh ``` -------------------------------- ### Example config.yaml for local operations Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/config-file.mdx This configuration sets the endpoint, uses Streamable HTTP transport, enables introspection, and defines local MCP operations. ```yaml endpoint: http://localhost:4001/ transport: type: streamable_http introspection: introspect: enabled: true operations: source: local paths: - relative/path/to/your/operations/userDetails.graphql - relative/path/to/your/operations/listing.graphql ``` -------------------------------- ### Example Health Check Configuration Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/health-checks.mdx Enable and configure health checks, including the path and readiness probe settings. This configuration requires the `streamable_http` transport type. ```yaml transport: type: streamable_http address: 127.0.0.1 port: 8000 health_check: enabled: true path: /health readiness: allowed: 50 interval: sampling: 10s unready: 30s ``` -------------------------------- ### Run MCP Server Locally (Windows PowerShell) Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/quickstart.mdx Start the MCP server locally on Windows PowerShell by first loading environment variables from a .env file, then running the rover dev command with specified configuration files. ```powershell Get-Content .env | ForEach-Object { $name, $value = $_.split('=',2); [System.Environment]::SetEnvironmentVariable($name, $value) } rover dev --supergraph-config supergraph.yaml --mcp .apollo/mcp.local.yaml ``` -------------------------------- ### Build Apollo MCP Server from Source Source: https://github.com/apollographql/apollo-mcp-server/blob/main/README.md Use this command to build the Apollo MCP Server from source if you have Rust installed. The server will be located in the `target/debug` directory after a successful build. ```bash cargo build ``` -------------------------------- ### Run MCP Inspector with Stdio Transport Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/debugging.mdx Execute this command to start the MCP Server with the specified configuration for stdio debugging. The inspector will then be available. ```sh npx @modelcontextprotocol/inspector \ target/debug/apollo-mcp-server ``` -------------------------------- ### Import and Use Helper Module for Auth Headers Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/rhai-getting-started.mdx Organize scripts into modules by placing additional `.rhai` files in the `rhai/` directory and importing them using the `import` keyword. This example shows importing a helper module to add authentication headers. ```rhai // rhai/main.rhai import "helpers" as helpers; fn on_execute_graphql_operation(ctx) { helpers::add_auth_headers(ctx); } ``` ```rhai // rhai/helpers.rhai fn add_auth_headers(ctx) { ctx.headers["authorization"] = "Bearer " + Env::get("AUTH_TOKEN"); } ``` -------------------------------- ### Run Apollo MCP Server with Rover CLI Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/run.mdx Use the `rover dev --mcp` command to start an MCP server alongside your local graph. Provide an optional configuration file using the `--mcp` flag. Requires Rover CLI v0.37 or later. ```sh rover dev --mcp [...other rover dev flags] ``` -------------------------------- ### Run Standalone Apollo MCP Server Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/run.mdx Executes the installed Apollo MCP Server binary. Requires a configuration file path as an argument. Environment variables `APOLLO_GRAPH_REF` and `APOLLO_KEY` are needed if no config file is provided. ```sh ./apollo-mcp-server [OPTIONS] ``` -------------------------------- ### Invalid Configuration Example Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/config-file.mdx Apollo MCP Server validates configuration at startup and rejects invalid options, providing clear error messages about unknown fields and expected options. ```yaml # ❌ Wrong — auth is not a top-level option auth: servers: - https://auth-server.com transport: type: streamable_http ``` -------------------------------- ### Environment Variable Override Example Source: https://github.com/apollographql/apollo-mcp-server/blob/main/AGENTS.md Demonstrates how to override nested configuration values using environment variables. The format `APOLLO_MCP_
__` allows for precise configuration updates. ```bash APOLLO_MCP_INTROSPECTION__EXECUTE__ENABLED=true ``` -------------------------------- ### Run Apollo MCP Server Docker Container Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/run.mdx This command starts the MCP Server in a Docker container, mapping configuration files and forwarding the necessary port. Replace placeholder paths with your actual file locations. ```sh docker run \ -it --rm \ --name apollo-mcp-server \ -p 8000:8000 \ -v :/config.yaml \ -v :/data \ --pull always \ ghcr.io/apollographql/apollo-mcp-server:latest /config.yaml ``` -------------------------------- ### Detect Current Platform with Platform.target Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-development.mdx Use `Platform.target` to get a string representing the current platform (e.g., "openai" or "mcp"). This is useful for detecting the runtime environment. ```tsx import { Platform } from "@apollo/client-ai-apps"; function App() { // Use `Platform.target` to get a string representing the current platform const currentPlatform = Platform.target; // => "openai" | "mcp" // The `Platform.select` function selects the value for you using the current platform const label = Platform.select({ mcp: "Running in an MCP host", openai: "Running in ChatGPT", }); // `Platform.select` also accepts a function that is called immediately. // Useful when you want to avoid expensive computation for a value not used in // the current platform const value = Platform.select({ mcp: () => factorial(10), openai: () => factorial(20), }); return
{label}
; } ``` -------------------------------- ### Configure Uplink Operations for Production Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/guides/dev-to-prod-workflows.mdx Example MCP configuration for production environments when using persisted queries managed by GraphOS. Set the source to 'uplink'. Ensure APOLLO_GRAPH_REF and APOLLO_KEY are set as environment variables. ```yaml operations: source: uplink ``` -------------------------------- ### Emit Structured Logs with Trace ID Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/rhai-lifecycle.mdx This example demonstrates how to include the current OpenTelemetry trace ID in structured log output using `ctx.trace_id` and `ctx.tool_name`. This aids in correlating logs with distributed traces. ```rhai fn on_execute_graphql_operation(ctx) { print(`[MCP Request] trace_id=${ctx.trace_id} tool=${ctx.tool_name}`); } ``` -------------------------------- ### MCP Server Configuration Example Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-quickstart.mdx This YAML configuration defines the MCP server's endpoint, transport type, and host validation settings. Ensure `allowed_hosts` is updated when using ngrok to prevent security vulnerabilities. ```yaml endpoint: http://localhost:4000/ # Your GraphQL API transport: type: streamable_http stateful_mode: false port: 8000 host_validation: allowed_hosts: - your-ngrok-domain.ngrok-free.app # Required when using ngrok ``` -------------------------------- ### Initialize MCP Server Project Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/quickstart.mdx Use the Rover CLI to interactively initialize a new Apollo GraphOS project configured for MCP tools. ```bash rover init --mcp ``` -------------------------------- ### HTTP GET Request Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/rhai-functions.mdx Provides details on making GET requests with and without options. ```APIDOC ## GET /api/resource ### Description Sends a GET request to a specified URL. This function can be used with or without additional options. ### Method GET ### Endpoint `/api/resource` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rhai // Simple GET request let response = Http::get("https://api.example.com/data").wait(); // GET with custom headers and timeout let response = Http::get("https://api.example.com/data", #{ headers: #{ "authorization": "Bearer " + token, "accept": "application/json" }, timeout: 30 }).wait(); ``` ### Response #### Success Response (200) - **status** (Integer) - The HTTP status code. - **text()** (String) - The response body as a string. - **json()** (Dynamic) - Parses the response body as JSON. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Configure Initialize Instructions Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/config-file.mdx Provide initialization instructions for supported clients to inject into the model context. This can be configured using YAML with block scalars for multi-line content or via an environment variable. ```yaml instructions: | Prefer semantic search tools before listing. Check access tier rules before mutations. ``` -------------------------------- ### Send GET Request with Http::get Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/rhai-functions.mdx Use Http::get to send a GET request to a specified URL. The function returns a Promise that can be resolved with .wait(). ```rhai Http::get("https://api.example.com/health").wait() ``` ```rhai Http::get("https://api.example.com/data", #{ headers: #{ "x-api-key": key } }) ``` -------------------------------- ### Run Weather MCP Server Source: https://github.com/apollographql/apollo-mcp-server/blob/main/examples/weather/README.md Use this command to spin up both the local router and the MCP server. Ensure you are in the `examples/weather` directory. ```sh cd examples/weather rover dev --supergraph-config supergraph.yaml --mcp config.yaml ``` -------------------------------- ### Configure Server Information Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/config-file.mdx Set server metadata such as name, version, title, website URL, and description. These fields are optional and use sensible defaults if not specified. ```yaml server_info: name: "Acme Corp GraphQL Server" version: "2.0.0" title: "Acme MCP Server" website_url: "https://acme.com/mcp-docs" description: "MCP server for Acme Corp's GraphQL API" ``` -------------------------------- ### Code Coverage Source: https://github.com/apollographql/apollo-mcp-server/blob/main/AGENTS.md Command to generate code coverage reports. Requires `cargo-llvm-cov` to be installed. The output is saved to `codecov.json`. ```bash cargo llvm-cov --all-features --workspace --codecov --output-path codecov.json ``` -------------------------------- ### Create MCP App from Template Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-quickstart.mdx Scaffold a new MCP App project using the Apollo AI Apps Template. This command initializes the project structure and necessary files. ```bash npx tiged apollographql/ai-apps-template my-awesome-app ``` -------------------------------- ### Specify App with Query Parameter Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-quickstart.mdx Use the `app` query parameter in the URL to specify which MCP app to load. The app name should match its directory name. ```text ?app=the-store ``` -------------------------------- ### Set up ngrok Tunnel Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-quickstart.mdx Create a public tunnel to your locally running MCP server using ngrok. This command exposes your local server to the internet. ```bash ngrok http 8000 ``` -------------------------------- ### Configure Public API CORS for MCP Server Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/cors.mdx This setup is for public APIs where credentials are not required. It allows any origin but disables credential support. ```yaml cors: enabled: true allow_any_origin: true allow_credentials: false # Cannot use credentials with any origin ``` -------------------------------- ### Copy Incoming Header to Outgoing Request Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/rhai-lifecycle.mdx This example shows how to copy an 'authorization' header from the incoming request to a new 'x-forwarded-auth' header on the outgoing request, if the authorization header is present. ```rhai fn on_execute_graphql_operation(ctx) { let token = ctx.incoming_request.headers["authorization"]; if token != "" { ctx.headers["x-forwarded-auth"] = token; } } ``` -------------------------------- ### Configure OTLP Traces Exporter with HTTP/Protobuf Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/config-file.mdx Use this snippet to configure tracing telemetry to use the http/protobuf protocol and send data to a specified endpoint. It includes headers with each request. ```yaml telemetry: exporters: tracing: otlp: endpoint: http://localhost:4317 protocol: http/protobuf headers: key-name: some-value key-two: another-value ``` -------------------------------- ### Build Apollo MCP Server Docker Image Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/quickstart.mdx Build the Docker image for the Apollo MCP Server using the provided Dockerfile. Ensure you are in the project directory. ```bash docker build -f mcp.Dockerfile -t my-mcp-server . ``` -------------------------------- ### Configure Telemetry Exporters in config.yaml Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/telemetry.mdx Add this configuration to your Apollo MCP Server's config.yaml to enable OTLP export for metrics and tracing. Ensure the endpoints match your local observability stack setup. ```yaml telemetry: exporters: metrics: otlp: endpoint: "http://localhost:4318/v1/metrics" protocol: "http/protobuf" tracing: otlp: endpoint: "http://localhost:4318/v1/traces" protocol: "http/protobuf" ``` -------------------------------- ### Configure Claude Desktop MCP Server Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/quickstart.mdx Add this JSON configuration to your `claude_desktop_config.json` file to connect Claude Desktop to your MCP server. ```json { "mcpServers": { "mcp-My API": { "command": "npx", "args": [ "mcp-remote", "http://127.0.0.1:8000/mcp" ] } } } ``` -------------------------------- ### OpenAI App TypeScript Configuration Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-development.mdx Configuration targeting ChatGPT App-specific modules. Extends OpenAI configuration and includes .openai.* files. Includes openai/globals types for window.openai. Do not include if no ChatGPT-specific files exist. ```jsonc { "extends": ["@apollo/client-ai-apps/tsconfig/openai", "./tsconfig.base.json"], "compilerOptions": { "types": ["@apollo/client-ai-apps/openai/globals"], }, "include": [ ".apollo-client-ai-apps/types", "src/**/*.openai.ts", "src/**/*.openai.tsx", ], } ``` -------------------------------- ### Configure MCP Server Auth0 Settings Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/guides/auth-auth0.mdx Add this configuration to your `config.yaml` file to specify Auth0 as the authentication server, including domains, audiences, and scopes. ```yaml transport: type: streamable_http auth: servers: - https:// # Fill in your Auth0 domain audiences: - # Fill in your Auth0 Identifier resource: http://127.0.0.1:8000/mcp scopes: - read:users # Adjust scopes as needed ``` -------------------------------- ### Deploy Apollo Runtime Container with GraphOS Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/deploy.mdx Use this command to deploy the Apollo Runtime Container, which includes Apollo Router and Apollo MCP Server. It exposes ports 4000 for GraphQL and 8000 for MCP, and requires GraphOS credentials and a configuration file mount. ```bash docker run \ -p 4000:4000 \ -p 8000:8000 \ --env APOLLO_GRAPH_REF="" \ --env APOLLO_KEY="" \ --env MCP_ENABLE=1 \ -v /path/to/config:/config/mcp_config.yaml \ --rm \ ghcr.io/apollographql/apollo-runtime:latest ``` -------------------------------- ### Root TypeScript Configuration with Project References Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-development.mdx The base configuration that should include all project references. Omit MCP and OpenAI references if those specific configuration files are not created. ```jsonc { "files": [], "references": [ { "path": "./tsconfig.app.json" }, // Omit if you don't create this file { "path": "./tsconfig.mcp.json" }, // Omit if you don't create this file { "path": "./tsconfig.openai.json" }, ], } ``` -------------------------------- ### Persisting Global State in Rhai Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/rhai-lifecycle.mdx Define global variables at the top level of `main.rhai` to store configuration or constants that persist across all hook calls. This example shows how to load environment variables into global state for use in hook functions. ```rhai let backend_url = Env::get("BACKEND_URL"); let api_key = Env::get("API_KEY"); fn on_execute_graphql_operation(ctx) { ctx.endpoint = backend_url; ctx.headers["x-api-key"] = api_key; } ``` -------------------------------- ### Define GetProducts GraphQL Operation Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/quickstart.mdx Create this GraphQL query to retrieve product information. Save it as 'GetProducts' in your operation collection. ```graphql # Retrieves product information query GetProducts { products { id name description } } ``` -------------------------------- ### Enable Anonymous MCP Discovery Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/auth.mdx Set `allow_anonymous_mcp_discovery` to `true` to allow unauthenticated access to MCP discovery methods. This deviates from the MCP specification's requirement that authorization be present on every request. Unauthenticated clients will be able to discover which tools and resources the server exposes without providing a token. Only enable this when your deployment requires unauthenticated discovery, for example to support agent frameworks or platform registrations that list tools before initiating an OAuth flow. ```yaml transport: type: streamable_http auth: servers: - https://auth.example.com allow_anonymous_mcp_discovery: true ``` -------------------------------- ### MCP Server URL Format Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-quickstart.mdx The format for connecting your MCP server URL to a host like ChatGPT. Ensure the `/mcp?app=the-store` query parameter is included. ```text https://your-ngrok-url.ngrok-free.app/mcp?app=the-store ``` -------------------------------- ### Configure OTLP Metrics Exporter with Delta Temporality Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/config-file.mdx Configure metrics telemetry with delta temporality for platforms like New Relic and pass an API key via metadata. ```yaml telemetry: exporters: metrics: otlp: endpoint: https://otlp.nr-data.net:4317 protocol: grpc temporality: delta metadata: api-key: ``` -------------------------------- ### Verify MCP Server with Inspector Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/quickstart.mdx Use the MCP Inspector tool to connect to a running MCP server and verify its functionality by listing available tools. ```bash npx @modelcontextprotocol/inspector http://127.0.0.1:8000/mcp --transport http ``` -------------------------------- ### Working with Headers in Rhai Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/rhai-lifecycle.mdx Demonstrates reading and setting HTTP headers within the `on_execute_graphql_operation` hook. Headers can be accessed and modified using index syntax on the `ctx.headers` object. ```rhai fn on_execute_graphql_operation(ctx) { // Read a header value (returns empty string if not present) let auth = ctx.headers["authorization"]; // Set a header ctx.headers["x-request-id"] = "abc-123"; } ``` -------------------------------- ### Generate Documentation Source: https://github.com/apollographql/apollo-mcp-server/blob/main/AGENTS.md Command to generate documentation for the project. `cargo doc --no-deps` creates documentation without including dependencies. ```bash cargo doc --no-deps ``` -------------------------------- ### Configure OpenCode MCP Server Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/quickstart.mdx Add this JSON configuration to your `~/.config/opencode/opencode.json` to enable Apollo MCP Server in OpenCode. ```json { "$schema": "https://opencode.ai/config.json", "mcp": { "apollo-mcp": { "type": "local", "command": [ "npx", "mcp-remote", "http://127.0.0.1:8000/mcp" ], "enabled": true } } } ``` -------------------------------- ### Basic Vite Configuration for Apollo Client AI Apps Source: https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/mcp-apps-development.mdx Import and use the apolloClientAiApps plugin in your vite.config.ts. Set the 'targets' option to 'mcp' or 'openai' to define build environments. The 'appsOutDir' option specifies where build artifacts are written. ```typescript import { defineConfig } from "vite"; import { apolloClientAiApps } from "@apollo/client-ai-apps/vite"; export default defineConfig({ plugins: [ apolloClientAiApps({ targets: ["mcp", "openai"], appsOutDir: "../apps", // path where build artifacts are written }), // ... other plugins ], // ... other config }); ```