Files
n8n-mcp-server/docs/development/index.md
leonardsellem 2cd565cfa6 Initial commit of n8n MCP Server
A Model Context Protocol (MCP) server that integrates with n8n, providing tools for workflow and execution management via the n8n API.
2025-03-12 17:12:35 +01:00

2.7 KiB

Development Guide

This section provides information for developers who want to understand, maintain, or extend the n8n MCP Server.

Overview

The n8n MCP Server is built with TypeScript and implements the Model Context Protocol (MCP) to provide AI assistants with access to n8n workflows and executions. This development guide covers the architecture, extension points, and testing procedures.

Topics

  • Architecture: Overview of the codebase organization and design patterns
  • Extending the Server: Guide to adding new tools and resources
  • Testing: Information on testing procedures and writing tests

Development Setup

To set up a development environment:

  1. Clone the repository:

    git clone https://github.com/yourusername/n8n-mcp-server.git
    cd n8n-mcp-server
    
  2. Install dependencies:

    npm install
    
  3. Create a .env file for local development:

    cp .env.example .env
    # Edit the .env file with your n8n API credentials
    
  4. Start the development server:

    npm run dev
    

This will compile the TypeScript code in watch mode, allowing you to make changes and see them take effect immediately.

Project Structure

The project follows a modular structure:

n8n-mcp-server/
├── src/                  # Source code
│   ├── api/              # API client for n8n
│   ├── config/           # Configuration and environment settings
│   ├── errors/           # Error handling
│   ├── resources/        # MCP resources implementation
│   │   ├── static/       # Static resources
│   │   └── dynamic/      # Dynamic (parameterized) resources
│   ├── tools/            # MCP tools implementation
│   │   ├── workflow/     # Workflow management tools
│   │   └── execution/    # Execution management tools
│   ├── types/            # TypeScript type definitions
│   └── utils/            # Utility functions
├── tests/                # Test files
│   ├── unit/             # Unit tests
│   ├── integration/      # Integration tests
│   └── e2e/              # End-to-end tests
└── build/                # Compiled output

Build and Distribution

To build the project for distribution:

npm run build

This will compile the TypeScript code to JavaScript in the build directory and make the executable script file.

Development Workflow

  1. Create a feature branch for your changes
  2. Make your changes and ensure tests pass
  3. Update documentation as needed
  4. Submit a pull request

For more detailed instructions on specific development tasks, see the linked guides.