@theyahia/megaplan-mcp 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +119 -157
  3. package/dist/client.d.ts +3 -13
  4. package/dist/client.js +224 -82
  5. package/dist/client.js.map +1 -1
  6. package/dist/format.d.ts +12 -0
  7. package/dist/format.js +148 -0
  8. package/dist/format.js.map +1 -0
  9. package/dist/http.d.ts +3 -0
  10. package/dist/http.js +152 -0
  11. package/dist/http.js.map +1 -0
  12. package/dist/index.d.ts +2 -13
  13. package/dist/index.js +97 -23
  14. package/dist/index.js.map +1 -1
  15. package/dist/meta.d.ts +2 -0
  16. package/dist/meta.js +5 -0
  17. package/dist/meta.js.map +1 -0
  18. package/dist/prompts.d.ts +7 -0
  19. package/dist/prompts.js +22 -0
  20. package/dist/prompts.js.map +1 -0
  21. package/dist/query.d.ts +32 -0
  22. package/dist/query.js +61 -0
  23. package/dist/query.js.map +1 -0
  24. package/dist/tools/comments.d.ts +9 -7
  25. package/dist/tools/comments.js +18 -21
  26. package/dist/tools/comments.js.map +1 -1
  27. package/dist/tools/contractors.d.ts +35 -0
  28. package/dist/tools/contractors.js +39 -0
  29. package/dist/tools/contractors.js.map +1 -0
  30. package/dist/tools/deals.d.ts +53 -8
  31. package/dist/tools/deals.js +71 -23
  32. package/dist/tools/deals.js.map +1 -1
  33. package/dist/tools/employees.d.ts +7 -5
  34. package/dist/tools/employees.js +16 -12
  35. package/dist/tools/employees.js.map +1 -1
  36. package/dist/tools/me.d.ts +9 -0
  37. package/dist/tools/me.js +26 -0
  38. package/dist/tools/me.js.map +1 -0
  39. package/dist/tools/programs.d.ts +26 -0
  40. package/dist/tools/programs.js +25 -0
  41. package/dist/tools/programs.js.map +1 -0
  42. package/dist/tools/projects.d.ts +21 -8
  43. package/dist/tools/projects.js +26 -13
  44. package/dist/tools/projects.js.map +1 -1
  45. package/dist/tools/tasks.d.ts +49 -10
  46. package/dist/tools/tasks.js +62 -20
  47. package/dist/tools/tasks.js.map +1 -1
  48. package/dist/types.d.ts +44 -53
  49. package/dist/types.js +4 -0
  50. package/dist/types.js.map +1 -1
  51. package/package.json +69 -63
  52. package/dist/client.d.ts.map +0 -1
  53. package/dist/index.d.ts.map +0 -1
  54. package/dist/server.d.ts +0 -9
  55. package/dist/server.d.ts.map +0 -1
  56. package/dist/server.js +0 -73
  57. package/dist/server.js.map +0 -1
  58. package/dist/tools/comments.d.ts.map +0 -1
  59. package/dist/tools/deals.d.ts.map +0 -1
  60. package/dist/tools/employees.d.ts.map +0 -1
  61. package/dist/tools/projects.d.ts.map +0 -1
  62. package/dist/tools/tasks.d.ts.map +0 -1
  63. package/dist/types.d.ts.map +0 -1
  64. package/smithery.yaml +0 -33
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 theYahia
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 theYahia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,68 +1,64 @@
1
1
  # @theyahia/megaplan-mcp
2
2
 
3
- > MCP server for **Megaplan** project management — tasks, deals, projects, employees, comments via API v3.
4
- > 8 tools + 2 MCP prompts. Token OR Password-grant auth. Stdio + Streamable HTTP transports.
3
+ MCP server for **Megaplan** project management. Tasks, deals, projects,
4
+ employees, clients, and comments via Megaplan API v3.
5
5
 
6
- [![npm](https://img.shields.io/npm/v/@theyahia/megaplan-mcp)](https://www.npmjs.com/package/@theyahia/megaplan-mcp)
7
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ > **v4.0 is a breaking release** (and the first npm release of this overhaul —
7
+ > it supersedes the older 8-tool `3.0.0`). Request/response shapes changed to
8
+ > match the real v3 API, and `--http` now requires an auth token. See
9
+ > [CHANGELOG.md](./CHANGELOG.md) and [Migrating from older versions](#migrating-from-older-versions).
8
10
 
9
- ---
10
-
11
- ### Migrating from v1.x
12
-
13
- If you used v1.x, the v2.0.0 release introduces a few breaking changes:
14
-
15
- - **HTTP transport env var renamed:** `PORT=3000` → `HTTP_PORT=3000`.
16
- - **Removed separate `--http` codepath:** v1 had a hand-rolled `http.ts` triggered by `--http`. v2 uses `@theyahia/mcp-core`'s `runServer` which auto-routes via `--http` flag OR `HTTP_PORT` env. Same CLI flag, different implementation (now with session management, `/health` endpoint, CORS, graceful shutdown).
17
- - **Internal client:** rewritten on `@theyahia/mcp-core`'s `BaseHttpClient` with a custom `MegaplanAuthStrategy` (Password grant flow). The exported `megaplanGet`/`megaplanPost` API is unchanged.
18
- - **Tool errors:** now returned as MCP-spec `CallToolResult` with `isError: true` (via `withErrorHandling`).
19
-
20
- Tool names, arguments, return formats, MCP prompts (`my-tasks-today`, `create-deal-wizard`), and `MEGAPLAN_*` env vars are unchanged.
21
-
22
- ---
23
-
24
- ## Tools (8) + Prompts (2)
25
-
26
- ### Tasks
11
+ ## Tools (18)
27
12
 
28
13
  | Tool | Description |
29
- |------|-------------|
30
- | `get_tasks` | List tasks with filters by status (active / completed / delayed), responsible user, search. |
31
- | `create_task` | Create a new task (name, description, responsible, deadline). |
32
-
33
- ### Deals
34
-
35
- | Tool | Description |
36
- |------|-------------|
37
- | `get_deals` | List deals with filters by status, responsible user, search. |
38
- | `create_deal` | Create a new deal (name, pipeline, responsible, amount). |
39
-
40
- ### Projects & Employees
41
-
42
- | Tool | Description |
43
- |------|-------------|
44
- | `get_projects` | List projects with filters by status and search. |
45
- | `get_employees` | List employees with search and department filter. |
46
-
47
- ### Comments
14
+ |------|------------|
15
+ | `get_tasks` | List tasks; filter by status code(s), responsible, search |
16
+ | `get_task` | Get one task by ID |
17
+ | `create_task` | Create a task (name, description, responsible, deadline) |
18
+ | `update_task` | Update a task (name, description, responsible, deadline, status) |
19
+ | `get_deals` | List deals; filter by status code(s), responsible, search |
20
+ | `get_deal` | Get one deal by ID |
21
+ | `create_deal` | Create a deal (requires a program/pipeline ID) |
22
+ | `update_deal` | Update a deal (name, responsible, amount, description, status) |
23
+ | `get_projects` | List projects; filter by status code(s), search |
24
+ | `get_project` | Get one project by ID |
25
+ | `get_employees` | List employees; search + department filter |
26
+ | `get_deal_programs` | List deal programs (pipelines) — find the `program_id` for `create_deal` |
27
+ | `get_deal_program` | Get one deal program by ID |
28
+ | `list_clients` | List clients (contractors): people (`human`) or orgs (`company`) |
29
+ | `get_client` | Get one client by type + ID |
30
+ | `get_current_user` | Authenticated user's employee record (**experimental**) |
31
+ | `get_comments` | List comments on a task/deal/project |
32
+ | `create_comment` | Add a comment to a task/deal/project |
33
+
34
+ All list/get tools return a **compact summary** by default; pass `raw: true` for
35
+ the unmodified API JSON. Lists are cursor-paginated: pass the returned
36
+ `nextPageAfter` as `page_after` to get the next page.
37
+
38
+ ## Skills (Prompts)
39
+
40
+ | Skill | Description |
41
+ |-------|------------|
42
+ | `my-tasks-today` | "Мои задачи на сегодня" — your tasks (scoped via `get_current_user`) |
43
+ | `create-deal-wizard` | "Создай сделку" — guided deal creation (lists pipelines first) |
44
+
45
+ ## Setup
46
+
47
+ ### Option A: Access Token
48
48
 
49
- | Tool | Description |
50
- |------|-------------|
51
- | `get_comments` | List comments on a task / deal / project. |
52
- | `create_comment` | Add a comment to a task / deal / project. |
53
-
54
- ### MCP Prompts
49
+ 1. In Megaplan, go to **Settings → Integration → API**.
50
+ 2. Generate an access token, and set it as `MEGAPLAN_TOKEN`.
55
51
 
56
- | Prompt | Description |
57
- |--------|-------------|
58
- | `my-tasks-today` | "Мои задачи на сегодня" — fetches your active tasks sorted by urgency, marks overdue. |
59
- | `create-deal-wizard` | "Создай сделку" — guided deal creation wizard via conversation. |
52
+ ### Option B: Login + Password
60
53
 
61
- ---
54
+ Set `MEGAPLAN_LOGIN` (email) + `MEGAPLAN_PASSWORD`. The server exchanges them for
55
+ an access token (cached in memory, re-authenticated on expiry).
62
56
 
63
- ## Quick Start
57
+ `MEGAPLAN_DOMAIN` is your account host. A bare subdomain like `yourcompany` is
58
+ expanded to `yourcompany.megaplan.ru`; a full host (`crm.example.com`) is used
59
+ as-is.
64
60
 
65
- ### Claude Desktop — token auth
61
+ ## Usage with Claude Desktop
66
62
 
67
63
  ```json
68
64
  {
@@ -72,135 +68,101 @@ Tool names, arguments, return formats, MCP prompts (`my-tasks-today`, `create-de
72
68
  "args": ["-y", "@theyahia/megaplan-mcp"],
73
69
  "env": {
74
70
  "MEGAPLAN_DOMAIN": "yourcompany",
75
- "MEGAPLAN_TOKEN": "your_access_token"
71
+ "MEGAPLAN_TOKEN": "your-access-token"
76
72
  }
77
73
  }
78
74
  }
79
75
  }
80
76
  ```
81
77
 
82
- ### Claude Desktop — login/password auth
83
-
84
- ```json
85
- {
86
- "mcpServers": {
87
- "megaplan": {
88
- "command": "npx",
89
- "args": ["-y", "@theyahia/megaplan-mcp"],
90
- "env": {
91
- "MEGAPLAN_DOMAIN": "yourcompany",
92
- "MEGAPLAN_LOGIN": "user@example.com",
93
- "MEGAPLAN_PASSWORD": "your_password"
94
- }
95
- }
96
- }
97
- }
98
- ```
78
+ Or with login/password — replace `MEGAPLAN_TOKEN` with `MEGAPLAN_LOGIN` +
79
+ `MEGAPLAN_PASSWORD`.
99
80
 
100
- ### Cursor / Windsurf
81
+ ## Finding IDs
101
82
 
102
- Same configuration block under `mcpServers` in the IDE's MCP settings.
83
+ Several tools take IDs. Here's how to discover them via the server itself:
103
84
 
104
- ### VS Code (Copilot)
85
+ - **`responsible_id`, `filter_responsible_id`** → `get_employees` (each item has an `id`).
86
+ - **`filter_department_id`** → IDs appear on employees' `department` (or your Megaplan UI).
87
+ - **`program_id`** (required by `create_deal`) → `get_deal_programs`.
88
+ - **`contact_id`** (for `create_deal`) → `list_clients` with `type: "human"` or `"company"`; pass the matching `contact_type`.
89
+ - **status codes** (`filter_status`) are account-specific enum codes (e.g. `filter_any`), not display names. Find them in your Megaplan UI / account API schema.
105
90
 
106
- Same shape under `.vscode/mcp.json` `servers` key.
91
+ ## Streamable HTTP transport
107
92
 
108
- ### Streamable HTTP transport
93
+ For remote/cloud deployments, run with `--http`. **Auth is mandatory** — the
94
+ server holds your Megaplan credentials, so it refuses to start without
95
+ `MCP_HTTP_TOKEN` and binds to loopback by default.
109
96
 
110
97
  ```bash
111
- HTTP_PORT=3000 \
112
98
  MEGAPLAN_DOMAIN=yourcompany \
113
- MEGAPLAN_TOKEN=your_token \
114
- npx @theyahia/megaplan-mcp
115
- # or: npx @theyahia/megaplan-mcp --http
99
+ MEGAPLAN_TOKEN=xxx \
100
+ MCP_HTTP_TOKEN=$(openssl rand -hex 32) \
101
+ npx @theyahia/megaplan-mcp --http
102
+ # → http://127.0.0.1:3000/mcp (send: Authorization: Bearer $MCP_HTTP_TOKEN)
103
+ # Health: http://127.0.0.1:3000/health
116
104
  ```
117
105
 
118
- Endpoints:
119
- - `POST /mcp` MCP requests
120
- - `GET /mcp` — SSE event stream (per session)
121
- - `DELETE /mcp` — session termination
122
- - `GET /health` — `{ status: "ok", version, tools, uptime, memory_mb }`
123
-
124
- ---
106
+ To expose beyond loopback, set `HOST=0.0.0.0` **and** add the public host:port to
107
+ `MCP_HTTP_ALLOWED_HOSTS` (DNS-rebinding protection is on). Only do this behind
108
+ your own network controls.
125
109
 
126
110
  ## Environment Variables
127
111
 
128
112
  | Variable | Required | Description |
129
113
  |----------|----------|-------------|
130
- | `MEGAPLAN_DOMAIN` | yes | Your Megaplan subdomain (e.g. `mycompany` for `mycompany.megaplan.ru`). |
131
- | `MEGAPLAN_TOKEN` | one of | Bearer access token (preferred — no auth roundtrip). |
132
- | `MEGAPLAN_LOGIN` | one of | Login email (used with `MEGAPLAN_PASSWORD` if no token). |
133
- | `MEGAPLAN_PASSWORD` | one of | Password (used with `MEGAPLAN_LOGIN` if no token). |
134
- | `HTTP_PORT` | no | If set, server runs in HTTP mode on this port. |
135
-
136
- ---
137
-
138
- ## Authentication
139
-
140
- Two options:
141
-
142
- **Option A — Token (recommended):**
143
- 1. In Megaplan, go to **Settings → Integration → API**.
144
- 2. Generate an access token.
145
- 3. Use it as `MEGAPLAN_TOKEN`.
146
-
147
- **Option B Password grant:**
148
- 1. Use your Megaplan login email + password.
149
- 2. The server fetches an access token via `/api/v3/auth/access_token` on the first request and caches it in memory. On HTTP 401 the cache is cleared and re-auth happens automatically.
150
-
151
- ---
152
-
153
- ## Demo Prompts
154
-
155
- Try these in your MCP client:
156
-
157
- > "What active tasks do I have? Sort by urgency."
158
-
159
- > "Create a task 'Review Q2 budget' assigned to user 42, deadline next Friday."
160
-
161
- > "Show me deals in the 'Sales' pipeline (program 1) with status 'in_progress'."
162
-
163
- > "Add a comment to deal 1234: 'Met with the client today, going to send proposal Monday.'"
164
-
165
- > "List all employees in the 'Marketing' department."
166
-
167
- > "Create a deal for 250,000 RUB in pipeline 1 — name 'Acme Corp annual contract'."
168
-
169
- > Use the `my-tasks-today` MCP prompt to get a daily standup view.
170
-
171
- ---
114
+ | `MEGAPLAN_DOMAIN` | Yes | Account host (`yourcompany` `yourcompany.megaplan.ru`, or a full host) |
115
+ | `MEGAPLAN_TOKEN` | One of | Bearer access token |
116
+ | `MEGAPLAN_LOGIN` | One of | Login email (if no token) |
117
+ | `MEGAPLAN_PASSWORD` | One of | Password (if no token) |
118
+ | `MEGAPLAN_DEBUG` | No | `1` to log full upstream error bodies |
119
+ | `PORT` | No | HTTP port for `--http` mode (default: 3000) |
120
+ | `MCP_HTTP_TOKEN` | `--http` | Bearer token required to call `/mcp` (server refuses to start without it) |
121
+ | `HOST` | No | Bind address for `--http` (default `127.0.0.1`) |
122
+ | `MCP_HTTP_ALLOWED_HOSTS` | No | Comma-separated allowed `Host` values (default loopback:port) |
123
+ | `MCP_HTTP_BODY_LIMIT` | No | Max request body size (default `1mb`) |
124
+ | `MCP_HTTP_MAX_SESSIONS` | No | Max concurrent sessions (default `100`) |
125
+ | `MCP_HTTP_SESSION_TTL_MS` | No | Idle session eviction TTL (default 30 min) |
126
+
127
+ ## Migrating from older versions
128
+
129
+ Applies to the previously published 8-tool builds (`1.x`–`3.0.0`):
130
+
131
+ - `get_*` list tools: `offset` → `page_after` (cursor); `filter_status` now takes
132
+ status **code(s)**, not names like `active`.
133
+ - Output is a compact summary by default pass `raw: true` for the old raw JSON.
134
+ - `create_comment`: the text field is now `content` (was `text`).
135
+ - `--http`: set `MCP_HTTP_TOKEN`; the default bind is now `127.0.0.1`.
136
+
137
+ ## Verification status
138
+
139
+ Most behaviour is confirmed against the official v3 RAML and real v3 client
140
+ libraries. A few items are best-effort from docs and marked `TODO(live-verify)`
141
+ in the source (and `experimental` here), pending a test against a live account:
142
+ auth body encoding, the free-text search param name, the `get_current_user`
143
+ endpoint, and the task/deal status-change field shape. Errors are surfaced
144
+ clearly (set `MEGAPLAN_DEBUG=1` for full detail) so any mismatch is diagnosable.
145
+
146
+ ## Referral
147
+
148
+ Get **20-50% recurring** commission by referring Megaplan:
149
+
150
+ - [Megaplan Partner Program](https://megaplan.ru/partners/)
151
+ - Sign up as a partner, get your referral link.
152
+ - Every client you bring = recurring revenue share.
172
153
 
173
154
  ## Development
174
155
 
175
156
  ```bash
176
- pnpm install
177
- pnpm --filter @theyahia/megaplan-mcp build
178
- pnpm --filter @theyahia/megaplan-mcp test
179
- pnpm --filter @theyahia/megaplan-mcp dev # tsx watch mode
180
- ```
181
-
182
- Project layout:
183
-
184
- ```
185
- servers/megaplan/
186
- ├── src/
187
- │ ├── index.ts — bin entry, runServer
188
- │ ├── server.ts — createServer factory + 8 tools + 2 prompts
189
- │ ├── client.ts — BaseHttpClient + MegaplanAuthStrategy (token OR Password grant)
190
- │ ├── types.ts — TypeScript types
191
- │ └── tools/
192
- │ ├── comments.ts
193
- │ ├── deals.ts
194
- │ ├── employees.ts
195
- │ ├── projects.ts
196
- │ └── tasks.ts
197
- └── tests/
198
- ├── client.test.ts — token + Password grant + 401 re-auth + body
199
- └── server.test.ts — createServer factory smoke
157
+ npm install
158
+ npm run build # tsc -> dist/
159
+ npm run typecheck # tsc --noEmit (src + tests)
160
+ npm run lint # eslint
161
+ npm test # vitest
162
+ npm run dev # stdio mode with tsx
163
+ npm run start:http # HTTP mode (needs MCP_HTTP_TOKEN)
200
164
  ```
201
165
 
202
- ---
203
-
204
166
  ## License
205
167
 
206
- MIT — see [LICENSE](./LICENSE).
168
+ MIT
package/dist/client.d.ts CHANGED
@@ -1,14 +1,4 @@
1
- /**
2
- * Megaplan API client.
3
- *
4
- * Custom auth that supports BOTH:
5
- * 1. Direct token via MEGAPLAN_TOKEN env var (preferred)
6
- * 2. Password grant via MEGAPLAN_LOGIN + MEGAPLAN_PASSWORD (with token caching)
7
- *
8
- * Wraps @theyahia/mcp-core's BaseHttpClient. Re-exports megaplanGet/megaplanPost
9
- * as functional API so tools/* keep their signatures unchanged.
10
- */
11
- export declare function resetClient(): void;
12
- export declare function megaplanGet(path: string, params?: Record<string, string>): Promise<unknown>;
1
+ /** Test helper: reset cached auth state between cases. */
2
+ export declare function __resetAuth(): void;
3
+ export declare function megaplanGet(path: string, params?: Record<string, unknown>): Promise<unknown>;
13
4
  export declare function megaplanPost(path: string, body: unknown): Promise<unknown>;
14
- //# sourceMappingURL=client.d.ts.map