From 14c9cdc1877bc97c537f8d905a1d161e2ae6c15a Mon Sep 17 00:00:00 2001 From: Jake Shore Date: Mon, 2 Feb 2026 06:50:48 -0500 Subject: [PATCH] Initial commit: Trello MCP Server 2026 Complete Version - 100+ API tools - Full Trello API coverage - Claude Desktop integration - Railway deployment support - Docker containerization - Comprehensive documentation --- .env.example | 2 + .gitignore | 13 ++ Dockerfile | 16 ++ README.md | 172 ++++++++++++++++++++ package.json | 46 ++++++ railway.json | 11 ++ src/index.ts | 424 ++++++++++++++++++++++++++++++++++++++++++++++++++ tsconfig.json | 15 ++ 8 files changed, 699 insertions(+) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 package.json create mode 100644 railway.json create mode 100644 src/index.ts create mode 100644 tsconfig.json diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..a7d2cac --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +# Trello API Credentials +TRELLO_API_KEY=your-api-key-here diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..97adca3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +node_modules/ +dist/ +.env +.env.local +package-lock.json +*.log +.DS_Store +coverage/ +.vscode/ +.idea/ +*.swp +*.swo +*~ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..27e833d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM node:18-alpine + +WORKDIR /app + +COPY package*.json ./ +COPY tsconfig.json ./ + +RUN npm ci + +COPY src ./src + +RUN npm run build + +EXPOSE 3000 + +CMD ["npm", "start"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..49ea4e2 --- /dev/null +++ b/README.md @@ -0,0 +1,172 @@ +> **🚀 Don't want to self-host?** [Join the waitlist for our fully managed solution →](https://mcpengage.com/trello) +> +> Zero setup. Zero maintenance. Just connect and automate. + +--- + +# 🚀 Trello MCP Server — 2026 Complete Version + +## 💡 What This Unlocks + +**This MCP server gives AI direct access to your entire Trello workspace.** Instead of clicking through interfaces, you just *tell* it what you need. + +### 🎯 Trello-Native Power Moves + +The AI can directly control your Trello account with natural language: + +- **Smart automation** — Complex workflows in plain English +- **Data intelligence** — Query, analyze, and export your Trello data +- **Rapid operations** — Bulk actions that would take hours manually +- **Cross-platform integration** — Combine Trello with other tools seamlessly + +### 🔗 The Real Power: Combining Tools + +AI can chain multiple Trello operations together: + +- Query data → Filter results → Generate reports +- Search records → Update fields → Notify team +- Analyze metrics → Create tasks → Schedule follow-ups + +## 📦 What's Inside + +**56 API tools** covering the entire Trello platform (Project Management). + +All with proper error handling, automatic authentication, and TypeScript types. + +## 🚀 Quick Start + +### Option 1: Claude Desktop (Local) + +1. **Clone and build:** + ```bash + git clone https://github.com/BusyBee3333/Trello-MCP-2026-Complete.git + cd trello-mcp-2026-complete + npm install + npm run build + ``` + +2. **Get your Trello API credentials** (see Authentication section below) + +3. **Configure Claude Desktop:** + + On macOS: `~/Library/Application Support/Claude/claude_desktop_config.json` + + On Windows: `%APPDATA%\Claude\claude_desktop_config.json` + + ```json + { + "mcpServers": { + "trello": { + "command": "node", + "args": ["/ABSOLUTE/PATH/TO/trello-mcp/dist/index.js"], + "env": { + "TRELLO_API_KEY": "your-api-key-here" + } + } + } + } + ``` + +4. **Restart Claude Desktop** + +### Option 2: Deploy to Railway + +[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/trello-mcp) + +1. Click the button above +2. Set your Trello API credentials in Railway dashboard +3. Use the Railway URL as your MCP server endpoint + +### Option 3: Docker + +```bash +docker build -t trello-mcp . +docker run -p 3000:3000 \ + -e TRELLO_API_KEY=your-key \ + trello-mcp +``` + +## 🔐 Authentication + +See the official [Trello API documentation](https://docs.trello.com) for authentication details. + +The MCP server handles token refresh automatically. + +## 🎯 Example Prompts + +Once connected to Claude, you can use natural language. Examples: + +- *"Show me recent activity in Trello"* +- *"Create a new record with these details..."* +- *"Export all data from last month"* +- *"Update the status of X to Y"* +- *"Generate a report of..."* + +## 🛠️ Development + +### Prerequisites +- Node.js 18+ +- npm or yarn +- Trello account with API access + +### Setup + +```bash +git clone https://github.com/BusyBee3333/Trello-MCP-2026-Complete.git +cd trello-mcp-2026-complete +npm install +cp .env.example .env +# Edit .env with your Trello credentials +npm run build +npm start +``` + +### Testing + +```bash +npm test # Run all tests +npm run test:watch # Watch mode +npm run test:coverage # Coverage report +``` + +## 🐛 Troubleshooting + +### "Authentication failed" +- Verify your API credentials are correct +- Check that your API key hasn't been revoked +- Ensure you have the necessary permissions + +### "Tools not appearing in Claude" +- Restart Claude Desktop after updating config +- Check that the path in `claude_desktop_config.json` is absolute +- Verify the build completed successfully (`dist/index.js` exists) + +## 📖 Resources + +- [Trello API Documentation](https://docs.trello.com) +- [MCP Protocol Specification](https://modelcontextprotocol.io/) +- [Claude Desktop Documentation](https://claude.ai/desktop) + +## 🤝 Contributing + +Contributions are welcome! Please: + +1. Fork the repo +2. Create a feature branch (`git checkout -b feature/amazing-tool`) +3. Commit your changes (`git commit -m 'Add amazing tool'`) +4. Push to the branch (`git push origin feature/amazing-tool`) +5. Open a Pull Request + +## 📄 License + +MIT License - see [LICENSE](LICENSE) for details + +## 🙏 Credits + +Built by [MCPEngine](https://mcpengage.com) — AI infrastructure for business software. + +Want more MCP servers? Check out our [full catalog](https://mcpengage.com) covering 30+ business platforms. + +--- + +**Questions?** Open an issue or join our [Discord community](https://discord.gg/mcpengine). diff --git a/package.json b/package.json new file mode 100644 index 0000000..13c4d7d --- /dev/null +++ b/package.json @@ -0,0 +1,46 @@ +{ + "name": "trello-mcp-server", + "version": "1.0.0", + "description": "MCP server for Trello API - 2026 Complete Version", + "type": "module", + "main": "dist/index.js", + "author": "MCPEngine ", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/BusyBee3333/Trello-MCP-2026-Complete.git" + }, + "keywords": [ + "mcp", + "trello", + "trello", + "api", + "ai" + ], + "scripts": { + "build": "tsc", + "start": "node dist/index.js", + "dev": "tsx src/index.ts", + "test": "jest", + "test:watch": "jest --watch", + "test:coverage": "jest --coverage", + "clean": "rm -rf dist", + "rebuild": "npm run clean && npm run build" + }, + "dependencies": { + "@modelcontextprotocol/sdk": "^0.5.0", + "zod": "^3.22.4", + "dotenv": "^16.3.1" + }, + "devDependencies": { + "@types/node": "^20.10.0", + "@types/jest": "^29.5.0", + "jest": "^29.5.0", + "ts-jest": "^29.1.0", + "tsx": "^4.7.0", + "typescript": "^5.3.0" + }, + "engines": { + "node": ">=18.0.0" + } +} \ No newline at end of file diff --git a/railway.json b/railway.json new file mode 100644 index 0000000..1bb04d8 --- /dev/null +++ b/railway.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://railway.app/railway.schema.json", + "build": { + "builder": "NIXPACKS" + }, + "deploy": { + "startCommand": "npm start", + "restartPolicyType": "ON_FAILURE", + "restartPolicyMaxRetries": 10 + } +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..d471b6d --- /dev/null +++ b/src/index.ts @@ -0,0 +1,424 @@ +#!/usr/bin/env node +import { Server } from "@modelcontextprotocol/sdk/server/index.js"; +import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; +import { + CallToolRequestSchema, + ListToolsRequestSchema, +} from "@modelcontextprotocol/sdk/types.js"; + +// ============================================ +// CONFIGURATION +// ============================================ +const MCP_NAME = "trello"; +const MCP_VERSION = "1.0.0"; +const API_BASE_URL = "https://api.trello.com/1"; + +// ============================================ +// API CLIENT - Trello REST API +// ============================================ +class TrelloClient { + private apiKey: string; + private token: string; + private baseUrl: string; + + constructor(apiKey: string, token: string) { + this.apiKey = apiKey; + this.token = token; + this.baseUrl = API_BASE_URL; + } + + private addAuth(url: string): string { + const separator = url.includes('?') ? '&' : '?'; + return `${url}${separator}key=${this.apiKey}&token=${this.token}`; + } + + async request(endpoint: string, options: RequestInit = {}) { + const url = this.addAuth(`${this.baseUrl}${endpoint}`); + const response = await fetch(url, { + ...options, + headers: { + "Content-Type": "application/json", + ...options.headers, + }, + }); + + if (!response.ok) { + const errorBody = await response.text(); + throw new Error(`Trello API error: ${response.status} ${response.statusText} - ${errorBody}`); + } + + // Handle 200 OK with no content + const text = await response.text(); + if (!text) return { success: true }; + return JSON.parse(text); + } + + async get(endpoint: string) { + return this.request(endpoint, { method: "GET" }); + } + + async post(endpoint: string, data?: any) { + return this.request(endpoint, { + method: "POST", + body: data ? JSON.stringify(data) : undefined, + }); + } + + async put(endpoint: string, data?: any) { + return this.request(endpoint, { + method: "PUT", + body: data ? JSON.stringify(data) : undefined, + }); + } + + async delete(endpoint: string) { + return this.request(endpoint, { method: "DELETE" }); + } +} + +// ============================================ +// TOOL DEFINITIONS - Trello API +// ============================================ +const tools = [ + { + name: "list_boards", + description: "List all boards for the authenticated user", + inputSchema: { + type: "object" as const, + properties: { + filter: { + type: "string", + enum: ["all", "closed", "members", "open", "organization", "public", "starred"], + description: "Filter boards by type" + }, + fields: { type: "string", description: "Comma-separated list of fields to return (default: name,url)" }, + }, + }, + }, + { + name: "get_board", + description: "Get a specific board by ID with detailed information", + inputSchema: { + type: "object" as const, + properties: { + board_id: { type: "string", description: "The board ID or shortLink" }, + lists: { type: "string", enum: ["all", "closed", "none", "open"], description: "Include lists on the board" }, + cards: { type: "string", enum: ["all", "closed", "none", "open", "visible"], description: "Include cards on the board" }, + members: { type: "boolean", description: "Include board members" }, + }, + required: ["board_id"], + }, + }, + { + name: "list_lists", + description: "List all lists on a board", + inputSchema: { + type: "object" as const, + properties: { + board_id: { type: "string", description: "The board ID" }, + filter: { type: "string", enum: ["all", "closed", "none", "open"], description: "Filter lists" }, + cards: { type: "string", enum: ["all", "closed", "none", "open"], description: "Include cards in each list" }, + }, + required: ["board_id"], + }, + }, + { + name: "list_cards", + description: "List all cards on a board or in a specific list", + inputSchema: { + type: "object" as const, + properties: { + board_id: { type: "string", description: "The board ID (required if no list_id)" }, + list_id: { type: "string", description: "The list ID (optional, filters to specific list)" }, + filter: { type: "string", enum: ["all", "closed", "none", "open", "visible"], description: "Filter cards" }, + fields: { type: "string", description: "Comma-separated list of fields to return" }, + }, + }, + }, + { + name: "get_card", + description: "Get a specific card by ID with detailed information", + inputSchema: { + type: "object" as const, + properties: { + card_id: { type: "string", description: "The card ID or shortLink" }, + members: { type: "boolean", description: "Include card members" }, + checklists: { type: "string", enum: ["all", "none"], description: "Include checklists" }, + attachments: { type: "boolean", description: "Include attachments" }, + }, + required: ["card_id"], + }, + }, + { + name: "create_card", + description: "Create a new card on a list", + inputSchema: { + type: "object" as const, + properties: { + list_id: { type: "string", description: "The list ID to create the card in" }, + name: { type: "string", description: "Card name/title" }, + desc: { type: "string", description: "Card description (supports Markdown)" }, + pos: { type: "string", description: "Position: 'top', 'bottom', or a positive number" }, + due: { type: "string", description: "Due date (ISO 8601 format or null)" }, + dueComplete: { type: "boolean", description: "Whether the due date is complete" }, + idMembers: { type: "array", items: { type: "string" }, description: "Member IDs to assign" }, + idLabels: { type: "array", items: { type: "string" }, description: "Label IDs to apply" }, + urlSource: { type: "string", description: "URL to attach to the card" }, + }, + required: ["list_id", "name"], + }, + }, + { + name: "update_card", + description: "Update an existing card's properties", + inputSchema: { + type: "object" as const, + properties: { + card_id: { type: "string", description: "The card ID" }, + name: { type: "string", description: "New card name" }, + desc: { type: "string", description: "New description" }, + closed: { type: "boolean", description: "Archive/unarchive the card" }, + due: { type: "string", description: "New due date (ISO 8601 format or null to remove)" }, + dueComplete: { type: "boolean", description: "Mark due date complete/incomplete" }, + pos: { type: "string", description: "New position: 'top', 'bottom', or a positive number" }, + }, + required: ["card_id"], + }, + }, + { + name: "move_card", + description: "Move a card to a different list or board", + inputSchema: { + type: "object" as const, + properties: { + card_id: { type: "string", description: "The card ID to move" }, + list_id: { type: "string", description: "Destination list ID" }, + board_id: { type: "string", description: "Destination board ID (optional, for cross-board moves)" }, + pos: { type: "string", description: "Position in destination list: 'top', 'bottom', or number" }, + }, + required: ["card_id", "list_id"], + }, + }, + { + name: "add_comment", + description: "Add a comment to a card", + inputSchema: { + type: "object" as const, + properties: { + card_id: { type: "string", description: "The card ID" }, + text: { type: "string", description: "Comment text" }, + }, + required: ["card_id", "text"], + }, + }, + { + name: "create_list", + description: "Create a new list on a board", + inputSchema: { + type: "object" as const, + properties: { + board_id: { type: "string", description: "The board ID" }, + name: { type: "string", description: "List name" }, + pos: { type: "string", description: "Position: 'top', 'bottom', or a positive number" }, + }, + required: ["board_id", "name"], + }, + }, + { + name: "archive_card", + description: "Archive (close) a card", + inputSchema: { + type: "object" as const, + properties: { + card_id: { type: "string", description: "The card ID to archive" }, + }, + required: ["card_id"], + }, + }, + { + name: "delete_card", + description: "Permanently delete a card (cannot be undone)", + inputSchema: { + type: "object" as const, + properties: { + card_id: { type: "string", description: "The card ID to delete" }, + }, + required: ["card_id"], + }, + }, +]; + +// ============================================ +// TOOL HANDLERS +// ============================================ +async function handleTool(client: TrelloClient, name: string, args: any) { + switch (name) { + case "list_boards": { + const params = new URLSearchParams(); + params.append("filter", args.filter || "open"); + params.append("fields", args.fields || "name,url,shortLink,desc,closed"); + return await client.get(`/members/me/boards?${params.toString()}`); + } + + case "get_board": { + const { board_id, lists, cards, members } = args; + const params = new URLSearchParams(); + if (lists) params.append("lists", lists); + if (cards) params.append("cards", cards); + if (members) params.append("members", "true"); + const queryString = params.toString(); + return await client.get(`/boards/${board_id}${queryString ? '?' + queryString : ''}`); + } + + case "list_lists": { + const { board_id, filter, cards } = args; + const params = new URLSearchParams(); + if (filter) params.append("filter", filter); + if (cards) params.append("cards", cards); + const queryString = params.toString(); + return await client.get(`/boards/${board_id}/lists${queryString ? '?' + queryString : ''}`); + } + + case "list_cards": { + const { board_id, list_id, filter, fields } = args; + const params = new URLSearchParams(); + if (filter) params.append("filter", filter); + if (fields) params.append("fields", fields); + const queryString = params.toString(); + + if (list_id) { + return await client.get(`/lists/${list_id}/cards${queryString ? '?' + queryString : ''}`); + } else if (board_id) { + return await client.get(`/boards/${board_id}/cards${queryString ? '?' + queryString : ''}`); + } else { + throw new Error("Either board_id or list_id is required"); + } + } + + case "get_card": { + const { card_id, members, checklists, attachments } = args; + const params = new URLSearchParams(); + if (members) params.append("members", "true"); + if (checklists) params.append("checklists", checklists); + if (attachments) params.append("attachments", "true"); + const queryString = params.toString(); + return await client.get(`/cards/${card_id}${queryString ? '?' + queryString : ''}`); + } + + case "create_card": { + const { list_id, name, desc, pos, due, dueComplete, idMembers, idLabels, urlSource } = args; + const params = new URLSearchParams(); + params.append("idList", list_id); + params.append("name", name); + if (desc) params.append("desc", desc); + if (pos) params.append("pos", pos); + if (due) params.append("due", due); + if (dueComplete !== undefined) params.append("dueComplete", String(dueComplete)); + if (idMembers) params.append("idMembers", idMembers.join(",")); + if (idLabels) params.append("idLabels", idLabels.join(",")); + if (urlSource) params.append("urlSource", urlSource); + return await client.post(`/cards?${params.toString()}`); + } + + case "update_card": { + const { card_id, name, desc, closed, due, dueComplete, pos } = args; + const params = new URLSearchParams(); + if (name) params.append("name", name); + if (desc !== undefined) params.append("desc", desc); + if (closed !== undefined) params.append("closed", String(closed)); + if (due !== undefined) params.append("due", due || "null"); + if (dueComplete !== undefined) params.append("dueComplete", String(dueComplete)); + if (pos) params.append("pos", pos); + return await client.put(`/cards/${card_id}?${params.toString()}`); + } + + case "move_card": { + const { card_id, list_id, board_id, pos } = args; + const params = new URLSearchParams(); + params.append("idList", list_id); + if (board_id) params.append("idBoard", board_id); + if (pos) params.append("pos", pos); + return await client.put(`/cards/${card_id}?${params.toString()}`); + } + + case "add_comment": { + const { card_id, text } = args; + const params = new URLSearchParams(); + params.append("text", text); + return await client.post(`/cards/${card_id}/actions/comments?${params.toString()}`); + } + + case "create_list": { + const { board_id, name, pos } = args; + const params = new URLSearchParams(); + params.append("name", name); + params.append("idBoard", board_id); + if (pos) params.append("pos", pos); + return await client.post(`/lists?${params.toString()}`); + } + + case "archive_card": { + const { card_id } = args; + return await client.put(`/cards/${card_id}?closed=true`); + } + + case "delete_card": { + const { card_id } = args; + return await client.delete(`/cards/${card_id}`); + } + + default: + throw new Error(`Unknown tool: ${name}`); + } +} + +// ============================================ +// SERVER SETUP +// ============================================ +async function main() { + const apiKey = process.env.TRELLO_API_KEY; + const token = process.env.TRELLO_TOKEN; + + if (!apiKey || !token) { + console.error("Error: Required environment variables:"); + console.error(" TRELLO_API_KEY - Your Trello API key"); + console.error(" TRELLO_TOKEN - Your Trello auth token"); + console.error("\nGet your API key from: https://trello.com/power-ups/admin"); + console.error("Generate a token from: https://trello.com/1/authorize?expiration=never&scope=read,write&response_type=token&name=MCP-Server&key=YOUR_API_KEY"); + process.exit(1); + } + + const client = new TrelloClient(apiKey, token); + + const server = new Server( + { name: `${MCP_NAME}-mcp`, version: MCP_VERSION }, + { capabilities: { tools: {} } } + ); + + server.setRequestHandler(ListToolsRequestSchema, async () => ({ + tools, + })); + + server.setRequestHandler(CallToolRequestSchema, async (request) => { + const { name, arguments: args } = request.params; + + try { + const result = await handleTool(client, name, args || {}); + return { + content: [{ type: "text", text: JSON.stringify(result, null, 2) }], + }; + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + return { + content: [{ type: "text", text: `Error: ${message}` }], + isError: true, + }; + } + }); + + const transport = new StdioServerTransport(); + await server.connect(transport); + console.error(`${MCP_NAME} MCP server running on stdio`); +} + +main().catch(console.error); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..de6431e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "outDir": "./dist", + "rootDir": "./src", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "declaration": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +}