Subchapter 13.8
references/init.mdMarkdown6 KBView on GitHub
Initialize a new federated graph project with rover init. This interactive wizard authenticates with GraphOS, creates a graph in the registry, downloads a starter template, and scaffolds a ready-to-run project directory.
# Interactive mode (prompts for every option)
rover init
# Initialize with MCP server capabilities
rover init --mcp
# Specify an output directory
rover init --path ./my-projectrover init requires authentication. If you have not signed in, the wizard prompts you to authenticate before continuing.
When run without flags, rover init walks through these steps:
rover auth login, rover config auth or APOLLO_KEY).| Type | Description |
|---|---|
| Create new | Scaffold a brand-new federated graph from a template. |
| Add subgraph | Add a new subgraph to an existing federated graph. |
| Use case | Template | Best for |
|---|---|---|
| Connectors | start-with-rest | Connecting REST APIs to your graph via Apollo Connectors. |
| GraphQL | start-with-typescript | Wrapping existing GraphQL endpoints into a federated subgraph. |
A typical rover init run produces:
my-project/
├── supergraph.yaml # Supergraph composition config
├── schema.graphql # Starter subgraph schema
├── .env # APOLLO_KEY and APOLLO_GRAPH_REF
├── package.json # (if TypeScript template)
└── src/ # Subgraph server sourceThe wizard also:
.env file in the project directory.Use --mcp to scaffold a project with an Apollo MCP Server, making your graph’s capabilities accessible to AI agents.
rover init --mcpThe MCP flow prompts you to choose between two setup paths:
| Setup | Description |
|---|---|
| New project | Create a new graph with MCP server from a template (REST Connectors or GraphQL). |
| Existing graph | Add MCP server capabilities to a graph already registered in GraphOS. |
Files created (in addition to standard project files):
my-project/
├── .apollo/
│ ├── mcp.local.yaml # Local MCP server config
│ └── mcp.claude.yaml # Claude Desktop MCP config
├── mcp.Dockerfile # Container image for MCP server
├── claude_desktop_config.json # Ready-to-use Claude Desktop config
├── .env # Credentials (APOLLO_KEY, APOLLO_GRAPH_REF)
└── supergraph.yaml # Composition config.env file.# With a specific graph (skip the selection prompt)
rover init --mcp --graph-id my-graph@productionAfter rover init --mcp completes, start the server:
# Linux/macOS
set -a && source .env && set +a && rover dev --supergraph-config supergraph.yaml --mcp .apollo/mcp.local.yaml
# Windows 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.yamlThe router runs at http://localhost:4000 and the MCP server at http://localhost:5050.
docker build -f mcp.Dockerfile -t my-project-mcp .
docker run --env-file .env -p5050:5050 my-project-mcp| Option | Description |
|---|---|
--mcp | Enable MCP server scaffolding. |
--path <PATH> | Output directory for the project (default: current directory). |
--project-type <TYPE> | Skip the project type prompt (create-new or add-subgraph). |
--organization <ORG> | Pre-select an organization by name or ID. |
--project-name <NAME> | Pre-set the project name. |
--graph-id <ID> | Pre-set the graph ID (format: graph-id or graph-id@variant). |
--project-use-case <CASE> | Pre-select the use case (connectors or graphql-template). |
PATH.rover auth login, rover config auth or APOLLO_KEY environment variable).Cannot initialize because the current directory is not emptyRun rover init from an empty directory, or use --path to specify one.
If the wizard fails at the authentication step, run rover auth login, rover config auth or set APOLLO_KEY first, then retry.
If the generated graph ID conflicts with an existing graph, the wizard prompts you to choose a different one. You can retry up to three times before the command exits.