Skip to content

Latest commit

 

History

History
133 lines (104 loc) · 3.74 KB

File metadata and controls

133 lines (104 loc) · 3.74 KB

Nais MCP Server

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.

Quick Start

Installation

Ensure you're authenticated with the Nais CLI:

nais login -n

Configuration

Add 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):

  1. Open the command palette
  2. Select "MCP: Add Server..."
  3. Select "Command (stdio)"
  4. Insert nais in the command input and press Enter
  5. Insert alpha mcp serve in the args input and press Enter
  6. When prompted for a name, insert nais
  7. 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"
      ]
    }
  }
}

Available Tools

Context & Execution

  • get_nais_context - Get current user, teams, and console URL patterns
  • execute_graphql - Execute GraphQL queries against the Nais API
  • validate_graphql - Validate a GraphQL query without executing it

Schema Exploration

  • schema_list_types - List all types in the API schema
  • schema_get_type - Get details about a specific type
  • schema_list_queries - List all available query operations
  • schema_list_mutations - List all mutation operations (read-only server)
  • schema_get_field - Get details about a specific field
  • schema_get_enum - Get enum values and descriptions
  • schema_search - Search the schema by name or description
  • schema_get_implementors - Get types implementing an interface
  • schema_get_union_types - Get member types of a union

Recommended Agent Prompt

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.

Command Reference

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

Resources

The server exposes these resources:

  • nais://schema - Complete Nais GraphQL API schema
  • nais://api-best-practices - API usage guidelines (pagination, optimization, rate limiting)