The Nais MCP (Model Context Protocol) server allows LLMs and AI assistants to interact with the Nais platform. It provides dynamic access to the Nais GraphQL API through schema exploration and query execution tools.
Ensure you're authenticated with the Nais CLI:
nais login -nAdd to your MCP settings file:
GitHub Copilot CLI (~/.mcp/config.json):
{
"mcpServers": {
"nais": {
"command": "nais",
"args": ["alpha", "mcp", "serve"],
"tools": ["*"]
}
}
}Zed (~/.config/zed/settings.json):
{
"context_servers": {
"nais": {
"enabled": true,
"command": "nais",
"args": ["alpha", "mcp", "serve"]
}
}
}VS Code (with Cline extension):
- Open the command palette
- Select "MCP: Add Server..."
- Select "Command (stdio)"
- Insert
naisin the command input and press Enter - Insert
alpha mcp servein the args input and press Enter - When prompted for a name, insert
nais - Select if you want to add it as a Global or Workspace MCP server
IntelliJ IDEA (with GitHub Copilot):
See GitHub Copilot MCP documentation for setup instructions.
Local server configuration:
{
"servers": {
"nais": {
"command": "nais",
"args": [
"alpha",
"mcp",
"serve"
]
}
}
}get_nais_context- Get current user, teams, and console URL patternsexecute_graphql- Execute GraphQL queries against the Nais APIvalidate_graphql- Validate a GraphQL query without executing it
schema_list_types- List all types in the API schemaschema_get_type- Get details about a specific typeschema_list_queries- List all available query operationsschema_list_mutations- List all mutation operations (read-only server)schema_get_field- Get details about a specific fieldschema_get_enum- Get enum values and descriptionsschema_search- Search the schema by name or descriptionschema_get_implementors- Get types implementing an interfaceschema_get_union_types- Get member types of a union
Add this to your AGENTS.md or system prompt to help the LLM use the Nais MCP effectively:
You have access to the Nais MCP server for interacting with the Nais platform.
**Initial Setup:**
1. Always start with `get_nais_context` to understand the user, their teams, and available console URLs
2. Use schema exploration tools (`schema_list_queries`, `schema_get_type`) to discover available data
3. Construct GraphQL queries based on the schema
4. Execute queries with `execute_graphql`
**Query Guidelines:**
- Use pagination with reasonable page sizes (20-50 items, max 100)
- Filter queries when possible (by team, environment, name)
- Use `__typename` for union/interface types
- Include `pageInfo { hasNextPage endCursor }` for paginated results
All operations are read-only and use the user's authenticated identity.nais alpha mcp serve [flags]| Flag | Default | Description |
|---|---|---|
--transport, -t |
stdio |
Transport: stdio, http, or sse |
--listen, -l |
:8080 |
Listen address (for http/sse) |
--rate-limit, -r |
10 |
Max requests per minute (0 = unlimited) |
--log-file |
- | Write logs to file instead of stderr |
The server exposes these resources:
nais://schema- Complete Nais GraphQL API schemanais://api-best-practices- API usage guidelines (pagination, optimization, rate limiting)