Skip to main content
The moon mcp command starts a Model Context Protocol (MCP) server that allows AI assistants and other MCP clients to interact with your moon workspace programmatically.
moon mcp

Overview

The MCP server exposes your moon workspace’s structure, configuration, and operations through a standardized protocol that AI assistants can use to:
  • Query workspace and project information
  • Read configuration files
  • Inspect task definitions
  • Understand project relationships and dependencies
  • Access the project graph
This enables AI assistants to provide more contextual and accurate help when working with moon projects.

How it works

  1. Loads the moon workspace and project graph
  2. Starts an MCP server that listens for client connections
  3. Handles incoming MCP protocol requests
  4. Gracefully shuts down on interrupt signals (Ctrl+C)
The server runs in the foreground and processes requests until manually stopped.

Usage

Start the MCP server

moon mcp
The server will:
  • Initialize the moon workspace
  • Load all project and configuration data
  • Start listening for MCP client connections
  • Continue running until interrupted

Stop the server

Press Ctrl+C or send a termination signal:
# Send interrupt signal
kill -INT <pid>

# Or use Ctrl+C in the terminal

Integration with AI assistants

To use the MCP server with an AI assistant:
  1. Start the moon MCP server in your workspace:
    moon mcp
    
  2. Configure your AI assistant to connect to the MCP server (configuration depends on your AI assistant)
  3. The assistant can now query workspace information through the MCP protocol

Examples

What an AI assistant can do through the MCP server:
  • Query projects: “List all projects in the workspace”
  • Read configurations: “Show me the configuration for the api project”
  • Inspect tasks: “What tasks are available in the web project?”
  • Understand dependencies: “Which projects depend on the shared library?”
  • Explore the graph: “Show me the project dependency graph”

Technical details

  • The server uses tokio for async operation
  • Signal handling is registered for graceful shutdown
  • The server runs with access to:
    • Application context
    • Workspace graph
    • Project configurations
    • Task definitions
    • Toolchain information

Exit behavior

The command uses std::process::exit(0) for clean termination after signal handling completes. This ensures:
  • All resources are properly cleaned up
  • The MCP server task is aborted
  • No hanging processes remain

Notes

The MCP server requires a valid moon workspace. Make sure you’re running it from a directory containing a .moon folder with proper configuration.
The server runs in the foreground and will block the terminal. If you need to run it as a background service, use process management tools or daemonization.

Build docs developers (and LLMs) love