commit 65d65a5204ee2f174ab91f8457da4a3133bfaadc Author: mindesbunister Date: Tue Oct 7 11:43:20 2025 +0200 Initial commit: n8n MCP server for VS Code integration - Implemented MCP server with 8 n8n tools - Added n8n API client for workflow operations - Configured VS Code settings with API authentication - Added comprehensive documentation and setup guides - Tested and verified connection to n8n instance diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..3b12dac --- /dev/null +++ b/.env.example @@ -0,0 +1,8 @@ +# Example .env file for n8n MCP server +# Copy this to .env and fill in your values + +# n8n instance URL (default: http://srvdocker02:8098) +N8N_BASE_URL=http://srvdocker02:8098 + +# n8n API key (optional, required for authenticated instances) +# N8N_API_KEY=your-api-key-here diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a2e91d --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +node_modules/ +dist/ +*.log +.env +.DS_Store +*.swp +*.swo +*~ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d604a7e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,14 @@ +{ + "mcpServers": { + "n8n": { + "command": "node", + "args": [ + "/home/rwiegand/Nextcloud/entwicklung/Werkzeuge/n8n_vscode_integration/dist/index.js" + ], + "env": { + "N8N_BASE_URL": "http://srvdocker02:8098", + "N8N_API_KEY": "n8n_api_42f1838c1e2de90cadcb669f78083de92697a85322c0b6009ad2e55760db992ab0bf61515a3cf0e1" + } + } + } +} diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md new file mode 100644 index 0000000..ae44b70 --- /dev/null +++ b/GETTING_STARTED.md @@ -0,0 +1,157 @@ +# ๐ŸŽ‰ n8n VS Code Integration - Ready to Use! + +Your n8n MCP (Model Context Protocol) server has been successfully set up and configured! + +## โœ… What's Been Installed + +1. **MCP Server** - TypeScript-based server that connects VS Code to n8n +2. **n8n API Client** - Handles all communication with your n8n instance +3. **Configuration Files** - Pre-configured with your n8n instance and API key +4. **Documentation** - Complete setup and usage guides + +## ๐Ÿ”ง Current Configuration + +- **n8n Instance**: `http://srvdocker02:8098` +- **API Key**: Configured โœ“ +- **Connection Status**: โœ… Successfully connected +- **Workflows Found**: 1 workflow ("My workflow") + +## ๐Ÿš€ Next Steps + +### 1. Restart VS Code +For the MCP server to be available in GitHub Copilot Chat, you need to restart VS Code: +- Close and reopen VS Code +- Or use `Cmd/Ctrl + Shift + P` โ†’ "Developer: Reload Window" + +### 2. Start Using It! + +Open GitHub Copilot Chat and try these commands: + +#### List Workflows +``` +@workspace List all my n8n workflows +``` + +#### Get Workflow Details +``` +@workspace Show me the details of the workflow "My workflow" +``` + +#### Execute a Workflow +``` +@workspace Execute the workflow with ID Zk4gbBzjxVppHiCB +``` + +#### View Executions +``` +@workspace Show me recent executions +``` + +#### Update a Workflow +``` +@workspace Update workflow Zk4gbBzjxVppHiCB to deactivate it +``` + +## ๐Ÿ“‹ Available Operations + +The MCP server provides these tools to GitHub Copilot: + +| Tool | Description | +|------|-------------| +| `list_workflows` | List all workflows in your n8n instance | +| `get_workflow` | Get complete workflow details including nodes | +| `update_workflow` | Modify workflow configuration | +| `activate_workflow` | Activate a workflow | +| `deactivate_workflow` | Deactivate a workflow | +| `execute_workflow` | Manually trigger a workflow | +| `get_execution` | Get details of a specific execution | +| `list_executions` | View execution history | + +## ๐Ÿงช Testing + +Test the connection anytime with: +```bash +node test-connection.js +``` + +Expected output: +``` +โœ“ Successfully connected to n8n! +โœ“ Found 1 workflow(s) +``` + +## ๐Ÿ“ Project Structure + +``` +n8n_vscode_integration/ +โ”œโ”€โ”€ src/ +โ”‚ โ”œโ”€โ”€ index.ts # Main MCP server +โ”‚ โ””โ”€โ”€ n8n-client.ts # n8n API client +โ”œโ”€โ”€ dist/ # Compiled JavaScript +โ”œโ”€โ”€ .vscode/ +โ”‚ โ””โ”€โ”€ settings.json # VS Code MCP configuration +โ”œโ”€โ”€ .env # Environment variables (API key) +โ”œโ”€โ”€ package.json # Dependencies +โ”œโ”€โ”€ README.md # Full documentation +โ”œโ”€โ”€ SETUP.md # Setup guide +โ””โ”€โ”€ test-connection.js # Connection test script +``` + +## ๐Ÿ”’ Security Note + +Your API key is stored in: +- `.env` file (for local testing) +- `.vscode/settings.json` (for MCP server) + +Both files are in `.gitignore` to prevent accidental commits. Keep your API key secure! + +## ๐Ÿ› ๏ธ Development + +If you want to modify the server: + +```bash +# Watch for changes and rebuild automatically +npm run watch + +# Or build manually +npm run build + +# After rebuilding, restart VS Code to reload the MCP server +``` + +## ๐Ÿ“– Documentation + +- **README.md** - Complete documentation and API reference +- **SETUP.md** - Detailed setup instructions +- **THIS FILE** - Quick start guide + +## ๐Ÿ’ก Example Use Cases + +1. **Workflow Development**: Ask Copilot to help you understand and modify workflows +2. **Automation**: Execute workflows directly from VS Code +3. **Monitoring**: Check execution history and debug failures +4. **Documentation**: Have Copilot explain what your workflows do +5. **Batch Operations**: Use Copilot to perform operations on multiple workflows + +## ๐Ÿ†˜ Need Help? + +If something doesn't work: + +1. Check that VS Code has been restarted +2. Verify the connection: `node test-connection.js` +3. Check VS Code Output panel: View โ†’ Output โ†’ GitHub Copilot Chat +4. Review SETUP.md for troubleshooting steps + +## ๐ŸŽฏ What You Can Ask Copilot + +- "List all my n8n workflows" +- "Show me the most recent executions" +- "Execute workflow X" +- "What does workflow Y do?" (Copilot will fetch and analyze it) +- "Activate all inactive workflows" +- "Show me failed executions" +- "Update workflow X to change [setting]" + +--- + +**You're all set! Restart VS Code and start using n8n with GitHub Copilot Chat! ๐Ÿš€** diff --git a/README.md b/README.md new file mode 100644 index 0000000..bdbc908 --- /dev/null +++ b/README.md @@ -0,0 +1,210 @@ +# n8n MCP Server for VS Code + +A Model Context Protocol (MCP) server that integrates n8n workflow automation directly into VS Code through GitHub Copilot Chat. + +## Features + +- **List Workflows**: Browse all workflows in your n8n instance +- **Get Workflow Details**: View complete workflow configuration, nodes, and connections +- **Update Workflows**: Modify workflow settings, nodes, and connections +- **Activate/Deactivate**: Control workflow activation state +- **Execute Workflows**: Manually trigger workflow execution +- **View Executions**: Check execution history and results + +## Prerequisites + +- Node.js (v18 or higher) +- VS Code with GitHub Copilot Chat extension +- Access to an n8n instance (running at `http://srvdocker02:8098` by default) + +## Installation + +1. Clone or navigate to this repository: +```bash +cd /home/rwiegand/Nextcloud/entwicklung/Werkzeuge/n8n_vscode_integration +``` + +2. Install dependencies: +```bash +npm install +``` + +3. Build the project: +```bash +npm run build +``` + +4. Configure your n8n instance URL (if different from default): + - Copy `.env.example` to `.env` + - Update `N8N_BASE_URL` with your n8n instance URL + - If your n8n instance requires authentication, add your API key: + ``` + N8N_API_KEY=your-api-key-here + ``` + +## Configuration + +### For VS Code + +The `.vscode/settings.json` file is already configured to use this MCP server. The configuration looks like: + +```json +{ + "mcpServers": { + "n8n": { + "command": "node", + "args": [ + "/home/rwiegand/Nextcloud/entwicklung/Werkzeuge/n8n_vscode_integration/dist/index.js" + ], + "env": { + "N8N_BASE_URL": "http://srvdocker02:8098" + } + } + } +} +``` + +### For GitHub Copilot Chat (Global Configuration) + +To use this MCP server across all VS Code workspaces, add it to your global VS Code settings: + +1. Open VS Code Settings (JSON) with `Cmd/Ctrl + Shift + P` โ†’ "Preferences: Open User Settings (JSON)" +2. Add the MCP server configuration: + +```json +{ + "github.copilot.chat.mcp.servers": { + "n8n": { + "command": "node", + "args": [ + "/home/rwiegand/Nextcloud/entwicklung/Werkzeuge/n8n_vscode_integration/dist/index.js" + ], + "env": { + "N8N_BASE_URL": "http://srvdocker02:8098" + } + } + } +} +``` + +If your n8n instance requires an API key, add it to the env section: +```json +"env": { + "N8N_BASE_URL": "http://srvdocker02:8098", + "N8N_API_KEY": "your-api-key-here" +} +``` + +## Usage + +After installation and configuration, you can interact with your n8n instance through GitHub Copilot Chat in VS Code using natural language: + +### Example Commands + +**List all workflows:** +``` +@workspace List all my n8n workflows +``` + +**Get workflow details:** +``` +@workspace Show me the details of workflow ID 123 +``` + +**Update a workflow:** +``` +@workspace Update workflow 123 to change its name to "New Name" +``` + +**Activate/Deactivate workflows:** +``` +@workspace Activate workflow 123 +@workspace Deactivate workflow 456 +``` + +**Execute a workflow:** +``` +@workspace Execute workflow 123 +``` + +**View execution history:** +``` +@workspace Show me the recent executions for workflow 123 +@workspace Show me the last 10 executions +``` + +**Get execution details:** +``` +@workspace Show me details of execution abc-123 +``` + +## Available MCP Tools + +The server exposes the following tools: + +1. **list_workflows** - List all workflows +2. **get_workflow** - Get detailed workflow information +3. **update_workflow** - Update workflow configuration +4. **activate_workflow** - Activate a workflow +5. **deactivate_workflow** - Deactivate a workflow +6. **execute_workflow** - Execute a workflow manually +7. **get_execution** - Get execution details +8. **list_executions** - List workflow executions + +## Development + +### Watch Mode +```bash +npm run watch +``` + +### Build +```bash +npm run build +``` + +### Run Directly +```bash +npm run dev +``` + +## Troubleshooting + +### Server Not Connecting + +1. Verify the build is up to date: `npm run build` +2. Check that the path in settings.json is correct +3. Restart VS Code after making configuration changes +4. Check the Output panel in VS Code for error messages + +### Authentication Issues + +If your n8n instance requires authentication: +1. Generate an API key in your n8n instance (Settings โ†’ API) +2. Add the `N8N_API_KEY` environment variable to your configuration + +### Network Issues + +If you can't connect to your n8n instance: +1. Verify the n8n instance is running: `curl http://srvdocker02:8098/healthz` +2. Check firewall settings +3. Verify the URL in your configuration is correct + +## API Reference + +### n8n API Endpoints Used + +- `GET /api/v1/workflows` - List workflows +- `GET /api/v1/workflows/:id` - Get workflow +- `PATCH /api/v1/workflows/:id` - Update workflow +- `POST /api/v1/workflows/:id/execute` - Execute workflow +- `GET /api/v1/executions` - List executions +- `GET /api/v1/executions/:id` - Get execution + +## License + +MIT + +## Contributing + +Contributions are welcome! Please feel free to submit a Pull Request. diff --git a/SETUP.md b/SETUP.md new file mode 100644 index 0000000..dafe26f --- /dev/null +++ b/SETUP.md @@ -0,0 +1,114 @@ +# Quick Setup Guide + +## Step 1: Get Your n8n API Key + +1. Open your n8n instance at `http://srvdocker02:8098` +2. Go to **Settings** โ†’ **API** +3. Click **Create API Key** +4. Copy the generated API key + +## Step 2: Configure the API Key + +### Option A: Create .env file (Recommended for local testing) + +Create a `.env` file in this directory: + +```bash +N8N_BASE_URL=http://srvdocker02:8098 +N8N_API_KEY=your-api-key-here +``` + +### Option B: Update VS Code Settings + +Edit `.vscode/settings.json` and add your API key: + +```json +{ + "mcpServers": { + "n8n": { + "command": "node", + "args": [ + "/home/rwiegand/Nextcloud/entwicklung/Werkzeuge/n8n_vscode_integration/dist/index.js" + ], + "env": { + "N8N_BASE_URL": "http://srvdocker02:8098", + "N8N_API_KEY": "your-api-key-here" + } + } + } +} +``` + +### Option C: Global VS Code Settings + +For use across all workspaces, add to your User Settings JSON: + +1. Press `Cmd/Ctrl + Shift + P` +2. Type "Preferences: Open User Settings (JSON)" +3. Add: + +```json +{ + "github.copilot.chat.mcp.servers": { + "n8n": { + "command": "node", + "args": [ + "/home/rwiegand/Nextcloud/entwicklung/Werkzeuge/n8n_vscode_integration/dist/index.js" + ], + "env": { + "N8N_BASE_URL": "http://srvdocker02:8098", + "N8N_API_KEY": "your-api-key-here" + } + } + } +} +``` + +## Step 3: Test the Connection + +Run the test script: + +```bash +N8N_API_KEY=your-api-key-here node test-connection.js +``` + +You should see: +``` +โœ“ Successfully connected to n8n! +โœ“ Found X workflow(s) +``` + +## Step 4: Restart VS Code + +After updating the configuration, restart VS Code to load the MCP server. + +## Step 5: Use in Copilot Chat + +Open Copilot Chat and try: + +``` +@workspace List all my n8n workflows +``` + +## Troubleshooting + +### "401 Unauthorized" Error +- Your API key is missing or incorrect +- Make sure you've added `N8N_API_KEY` to the environment variables +- Generate a new API key in n8n if needed + +### "Connection Refused" Error +- Verify n8n is running: `curl http://srvdocker02:8098/healthz` +- Check if the URL is correct +- Verify network connectivity to the server + +### MCP Server Not Found in Copilot +- Make sure you've run `npm run build` +- Verify the path in settings.json is correct +- Restart VS Code +- Check VS Code Output panel for errors (View โ†’ Output โ†’ GitHub Copilot Chat) + +### Changes Not Taking Effect +- Run `npm run build` after code changes +- Restart VS Code to reload the MCP server +- Check that your settings.json is valid JSON diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..6d8786b --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1135 @@ +{ + "name": "n8n-mcp-server", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "n8n-mcp-server", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@modelcontextprotocol/sdk": "^1.0.4", + "axios": "^1.7.9", + "zod": "^3.24.1" + }, + "bin": { + "n8n-mcp-server": "dist/index.js" + }, + "devDependencies": { + "@types/node": "^22.10.5", + "typescript": "^5.7.3" + } + }, + "node_modules/@modelcontextprotocol/sdk": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.19.1.tgz", + "integrity": "sha512-3Y2h3MZKjec1eAqSTBclATlX+AbC6n1LgfVzRMJLt3v6w0RCYgwLrjbxPDbhsYHt6Wdqc/aCceNJYgj448ELQQ==", + "dependencies": { + "ajv": "^6.12.6", + "content-type": "^1.0.5", + "cors": "^2.8.5", + "cross-spawn": "^7.0.5", + "eventsource": "^3.0.2", + "eventsource-parser": "^3.0.0", + "express": "^5.0.1", + "express-rate-limit": "^7.5.0", + "pkce-challenge": "^5.0.0", + "raw-body": "^3.0.0", + "zod": "^3.23.8", + "zod-to-json-schema": "^3.24.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@types/node": { + "version": "22.18.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.18.8.tgz", + "integrity": "sha512-pAZSHMiagDR7cARo/cch1f3rXy0AEXwsVsVH09FcyeJVAzCnGgmYis7P3JidtTUjyadhTeSo8TgRPswstghDaw==", + "dev": true, + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.12.2.tgz", + "integrity": "sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.4", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/body-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz", + "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.0", + "http-errors": "^2.0.0", + "iconv-lite": "^0.6.3", + "on-finished": "^2.4.1", + "qs": "^6.14.0", + "raw-body": "^3.0.0", + "type-is": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/content-disposition": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", + "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/eventsource": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", + "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", + "dependencies": { + "eventsource-parser": "^3.0.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/eventsource-parser": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.6.tgz", + "integrity": "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg==", + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/express": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", + "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.0", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express-rate-limit": { + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.1.tgz", + "integrity": "sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/express-rate-limit" + }, + "peerDependencies": { + "express": ">= 4.11" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + }, + "node_modules/finalhandler": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", + "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", + "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/form-data/node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/form-data/node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/http-errors/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==" + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", + "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-to-regexp": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", + "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/pkce-challenge": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.0.tgz", + "integrity": "sha512-ueGLflrrnvwB3xuo/uGob5pd5FN7l0MsLf0Z87o/UQmRtwjvfylfc9MurIxRAWywCYTgrvpXBcqjV4OfCYGCIQ==", + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.1.tgz", + "integrity": "sha512-9G8cA+tuMS75+6G/TzW8OtLzmBDMo8p1JRxN5AZ+LAp8uxGA8V8GZm4GQ4/N5QNQEnLmg6SS7wyuSmbKepiKqA==", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.7.0", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/raw-body/node_modules/iconv-lite": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz", + "integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/send": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", + "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "dependencies": { + "debug": "^4.3.5", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "mime-types": "^3.0.1", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "engines": { + "node": ">=8" + } + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/zod": { + "version": "3.25.76", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", + "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zod-to-json-schema": { + "version": "3.24.6", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.24.6.tgz", + "integrity": "sha512-h/z3PKvcTcTetyjl1fkj79MHNEjm+HpD6NXheWjzOekY7kV+lwDYnHw+ivHkijnCSMz1yJaWBD9vu/Fcmk+vEg==", + "peerDependencies": { + "zod": "^3.24.1" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..1b00b9f --- /dev/null +++ b/package.json @@ -0,0 +1,34 @@ +{ + "name": "n8n-mcp-server", + "version": "1.0.0", + "description": "Model Context Protocol server for n8n integration with VS Code", + "type": "module", + "main": "dist/index.js", + "bin": { + "n8n-mcp-server": "dist/index.js" + }, + "scripts": { + "build": "tsc", + "watch": "tsc --watch", + "start": "node dist/index.js", + "dev": "npm run build && npm run start" + }, + "keywords": [ + "n8n", + "mcp", + "model-context-protocol", + "vscode", + "workflow" + ], + "author": "", + "license": "MIT", + "dependencies": { + "@modelcontextprotocol/sdk": "^1.0.4", + "axios": "^1.7.9", + "zod": "^3.24.1" + }, + "devDependencies": { + "@types/node": "^22.10.5", + "typescript": "^5.7.3" + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..9afbf6d --- /dev/null +++ b/src/index.ts @@ -0,0 +1,294 @@ +#!/usr/bin/env node + +import { Server } from '@modelcontextprotocol/sdk/server/index.js'; +import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; +import { + CallToolRequestSchema, + ListToolsRequestSchema, + Tool, +} from '@modelcontextprotocol/sdk/types.js'; +import { N8nClient } from './n8n-client.js'; + +// Get n8n configuration from environment variables +const N8N_BASE_URL = process.env.N8N_BASE_URL || 'http://srvdocker02:8098'; +const N8N_API_KEY = process.env.N8N_API_KEY; + +// Initialize n8n client +const n8nClient = new N8nClient({ + baseUrl: N8N_BASE_URL, + apiKey: N8N_API_KEY, +}); + +// Define available tools +const tools: Tool[] = [ + { + name: 'list_workflows', + description: 'List all n8n workflows in the instance', + inputSchema: { + type: 'object', + properties: {}, + required: [], + }, + }, + { + name: 'get_workflow', + description: 'Get detailed information about a specific n8n workflow including nodes and connections', + inputSchema: { + type: 'object', + properties: { + workflowId: { + type: 'string', + description: 'The ID of the workflow to retrieve', + }, + }, + required: ['workflowId'], + }, + }, + { + name: 'update_workflow', + description: 'Update an existing n8n workflow with new configuration, nodes, or connections', + inputSchema: { + type: 'object', + properties: { + workflowId: { + type: 'string', + description: 'The ID of the workflow to update', + }, + workflow: { + type: 'object', + description: 'The workflow data to update (partial update supported)', + }, + }, + required: ['workflowId', 'workflow'], + }, + }, + { + name: 'activate_workflow', + description: 'Activate a workflow to make it run automatically', + inputSchema: { + type: 'object', + properties: { + workflowId: { + type: 'string', + description: 'The ID of the workflow to activate', + }, + }, + required: ['workflowId'], + }, + }, + { + name: 'deactivate_workflow', + description: 'Deactivate a workflow to stop it from running automatically', + inputSchema: { + type: 'object', + properties: { + workflowId: { + type: 'string', + description: 'The ID of the workflow to deactivate', + }, + }, + required: ['workflowId'], + }, + }, + { + name: 'execute_workflow', + description: 'Execute a workflow manually', + inputSchema: { + type: 'object', + properties: { + workflowId: { + type: 'string', + description: 'The ID of the workflow to execute', + }, + }, + required: ['workflowId'], + }, + }, + { + name: 'get_execution', + description: 'Get details about a specific workflow execution', + inputSchema: { + type: 'object', + properties: { + executionId: { + type: 'string', + description: 'The ID of the execution to retrieve', + }, + }, + required: ['executionId'], + }, + }, + { + name: 'list_executions', + description: 'List recent workflow executions, optionally filtered by workflow ID', + inputSchema: { + type: 'object', + properties: { + workflowId: { + type: 'string', + description: 'Optional: Filter executions by workflow ID', + }, + limit: { + type: 'number', + description: 'Maximum number of executions to return (default: 20)', + }, + }, + required: [], + }, + }, +]; + +// Create MCP server +const server = new Server( + { + name: 'n8n-mcp-server', + version: '1.0.0', + }, + { + capabilities: { + tools: {}, + }, + } +); + +// Handle list tools request +server.setRequestHandler(ListToolsRequestSchema, async () => { + return { tools }; +}); + +// Handle tool call request +server.setRequestHandler(CallToolRequestSchema, async (request) => { + const { name, arguments: args } = request.params; + + try { + switch (name) { + case 'list_workflows': { + const workflows = await n8nClient.listWorkflows(); + return { + content: [ + { + type: 'text', + text: JSON.stringify(workflows, null, 2), + }, + ], + }; + } + + case 'get_workflow': { + const { workflowId } = args as { workflowId: string }; + const workflow = await n8nClient.getWorkflow(workflowId); + return { + content: [ + { + type: 'text', + text: JSON.stringify(workflow, null, 2), + }, + ], + }; + } + + case 'update_workflow': { + const { workflowId, workflow } = args as { workflowId: string; workflow: any }; + const updatedWorkflow = await n8nClient.updateWorkflow(workflowId, workflow); + return { + content: [ + { + type: 'text', + text: JSON.stringify(updatedWorkflow, null, 2), + }, + ], + }; + } + + case 'activate_workflow': { + const { workflowId } = args as { workflowId: string }; + const workflow = await n8nClient.activateWorkflow(workflowId); + return { + content: [ + { + type: 'text', + text: `Workflow ${workflowId} activated successfully.\n${JSON.stringify(workflow, null, 2)}`, + }, + ], + }; + } + + case 'deactivate_workflow': { + const { workflowId } = args as { workflowId: string }; + const workflow = await n8nClient.deactivateWorkflow(workflowId); + return { + content: [ + { + type: 'text', + text: `Workflow ${workflowId} deactivated successfully.\n${JSON.stringify(workflow, null, 2)}`, + }, + ], + }; + } + + case 'execute_workflow': { + const { workflowId } = args as { workflowId: string }; + const execution = await n8nClient.executeWorkflow(workflowId); + return { + content: [ + { + type: 'text', + text: `Workflow ${workflowId} executed successfully.\nExecution ID: ${execution.id}\n${JSON.stringify(execution, null, 2)}`, + }, + ], + }; + } + + case 'get_execution': { + const { executionId } = args as { executionId: string }; + const execution = await n8nClient.getExecution(executionId); + return { + content: [ + { + type: 'text', + text: JSON.stringify(execution, null, 2), + }, + ], + }; + } + + case 'list_executions': { + const { workflowId, limit } = args as { workflowId?: string; limit?: number }; + const executions = await n8nClient.listExecutions(workflowId, limit); + return { + content: [ + { + type: 'text', + text: JSON.stringify(executions, null, 2), + }, + ], + }; + } + + default: + throw new Error(`Unknown tool: ${name}`); + } + } catch (error: any) { + return { + content: [ + { + type: 'text', + text: `Error: ${error.message}`, + }, + ], + isError: true, + }; + } +}); + +// Start server +async function main() { + const transport = new StdioServerTransport(); + await server.connect(transport); + console.error('n8n MCP server running on stdio'); +} + +main().catch((error) => { + console.error('Fatal error:', error); + process.exit(1); +}); diff --git a/src/n8n-client.ts b/src/n8n-client.ts new file mode 100644 index 0000000..36e147f --- /dev/null +++ b/src/n8n-client.ts @@ -0,0 +1,129 @@ +import axios, { AxiosInstance } from 'axios'; + +export interface N8nWorkflow { + id: string; + name: string; + active: boolean; + nodes: any[]; + connections: any; + settings: any; + tags?: any[]; + createdAt?: string; + updatedAt?: string; +} + +export interface N8nExecution { + id: string; + finished: boolean; + mode: string; + retryOf?: string; + retrySuccessId?: string; + startedAt: string; + stoppedAt?: string; + workflowId: string; + workflowData?: any; + data?: any; +} + +export interface N8nConfig { + baseUrl: string; + apiKey?: string; +} + +export class N8nClient { + private client: AxiosInstance; + + constructor(config: N8nConfig) { + this.client = axios.create({ + baseURL: config.baseUrl, + headers: { + 'Content-Type': 'application/json', + ...(config.apiKey && { 'X-N8N-API-KEY': config.apiKey }), + }, + }); + } + + async listWorkflows(): Promise { + try { + const response = await this.client.get('/api/v1/workflows'); + return response.data.data || response.data; + } catch (error: any) { + throw new Error(`Failed to list workflows: ${error.message}`); + } + } + + async getWorkflow(workflowId: string): Promise { + try { + const response = await this.client.get(`/api/v1/workflows/${workflowId}`); + return response.data.data || response.data; + } catch (error: any) { + throw new Error(`Failed to get workflow ${workflowId}: ${error.message}`); + } + } + + async updateWorkflow(workflowId: string, workflow: Partial): Promise { + try { + const response = await this.client.patch(`/api/v1/workflows/${workflowId}`, workflow); + return response.data.data || response.data; + } catch (error: any) { + throw new Error(`Failed to update workflow ${workflowId}: ${error.message}`); + } + } + + async activateWorkflow(workflowId: string): Promise { + try { + const response = await this.client.patch(`/api/v1/workflows/${workflowId}`, { active: true }); + return response.data.data || response.data; + } catch (error: any) { + throw new Error(`Failed to activate workflow ${workflowId}: ${error.message}`); + } + } + + async deactivateWorkflow(workflowId: string): Promise { + try { + const response = await this.client.patch(`/api/v1/workflows/${workflowId}`, { active: false }); + return response.data.data || response.data; + } catch (error: any) { + throw new Error(`Failed to deactivate workflow ${workflowId}: ${error.message}`); + } + } + + async executeWorkflow(workflowId: string): Promise { + try { + const response = await this.client.post(`/api/v1/workflows/${workflowId}/execute`); + return response.data.data || response.data; + } catch (error: any) { + throw new Error(`Failed to execute workflow ${workflowId}: ${error.message}`); + } + } + + async getExecution(executionId: string): Promise { + try { + const response = await this.client.get(`/api/v1/executions/${executionId}`); + return response.data.data || response.data; + } catch (error: any) { + throw new Error(`Failed to get execution ${executionId}: ${error.message}`); + } + } + + async listExecutions(workflowId?: string, limit: number = 20): Promise { + try { + const params: any = { limit }; + if (workflowId) { + params.workflowId = workflowId; + } + const response = await this.client.get('/api/v1/executions', { params }); + return response.data.data || response.data; + } catch (error: any) { + throw new Error(`Failed to list executions: ${error.message}`); + } + } + + async deleteExecution(executionId: string): Promise { + try { + await this.client.delete(`/api/v1/executions/${executionId}`); + } catch (error: any) { + throw new Error(`Failed to delete execution ${executionId}: ${error.message}`); + } + } +} diff --git a/test-connection.js b/test-connection.js new file mode 100644 index 0000000..81fb8c9 --- /dev/null +++ b/test-connection.js @@ -0,0 +1,49 @@ +#!/usr/bin/env node + +/** + * Test script to verify n8n MCP server connectivity + * Usage: node test-connection.js + */ + +import { N8nClient } from './dist/n8n-client.js'; + +const N8N_BASE_URL = process.env.N8N_BASE_URL || 'http://srvdocker02:8098'; +const N8N_API_KEY = process.env.N8N_API_KEY; + +console.log('Testing n8n connection...'); +console.log('n8n URL:', N8N_BASE_URL); +console.log('API Key:', N8N_API_KEY ? '***configured***' : 'not set'); +console.log(''); + +const client = new N8nClient({ + baseUrl: N8N_BASE_URL, + apiKey: N8N_API_KEY, +}); + +async function test() { + try { + console.log('Fetching workflows...'); + const workflows = await client.listWorkflows(); + console.log(`โœ“ Successfully connected to n8n!`); + console.log(`โœ“ Found ${workflows.length} workflow(s)`); + + if (workflows.length > 0) { + console.log('\nFirst few workflows:'); + workflows.slice(0, 5).forEach((wf) => { + console.log(` - ${wf.name} (ID: ${wf.id}, Active: ${wf.active})`); + }); + } + + process.exit(0); + } catch (error) { + console.error('โœ— Connection failed:', error.message); + console.error('\nTroubleshooting:'); + console.error('1. Verify n8n is running:'); + console.error(` curl ${N8N_BASE_URL}/healthz`); + console.error('2. Check if the URL is correct in your configuration'); + console.error('3. If authentication is required, set N8N_API_KEY environment variable'); + process.exit(1); + } +} + +test(); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..f4624bd --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "Node16", + "moduleResolution": "Node16", + "outDir": "./dist", + "rootDir": "./src", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "declaration": true, + "declarationMap": true, + "sourceMap": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +}