@agilemonster/mcp-server 1.0.6 → 1.0.8

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.
package/bin/mcp.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { runStdioServer } from '../dist/server.js';
3
+ import { MCP_SERVER_VERSION } from '../dist/client.js';
3
4
 
4
5
  const cliCommands = new Set([
5
6
  'bootstrap',
@@ -19,7 +20,10 @@ const cliCommands = new Set([
19
20
  ]);
20
21
 
21
22
  const firstArg = process.argv[2];
22
- if (firstArg && cliCommands.has(firstArg)) {
23
+ if (firstArg === '--version' || firstArg === '-v' || firstArg === 'version') {
24
+ console.log(MCP_SERVER_VERSION);
25
+ process.exit(0);
26
+ } else if (firstArg && cliCommands.has(firstArg)) {
23
27
  // Delegate to orchestrator CLI
24
28
  await import('./orchestrator.js');
25
29
  } else {
package/dist/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { AgileMonsterProjectConfig, Board, BoardAgentConfig, Card, ContextResponse } from './types.js';
1
+ import { AgileMonsterProjectConfig, Board, BoardAgentConfig, Card, ContextResponse, DiscoveredProject, PulseResponse } from './types.js';
2
+ export declare const MCP_SERVER_VERSION = "1.0.8";
2
3
  export declare class AgileMonsterClient {
3
4
  private apiKey;
4
5
  private baseUrl;
@@ -29,6 +30,18 @@ export declare class AgileMonsterClient {
29
30
  saveBoardAgents(boardId: string, agents: BoardAgentConfig[], projectName?: string, projectPath?: string, gitRemote?: string): Promise<{
30
31
  agents: BoardAgentConfig[];
31
32
  }>;
33
+ pulse(options: {
34
+ boardId: string;
35
+ provider?: string;
36
+ projectName?: string;
37
+ projectPath?: string;
38
+ discoveredProjects?: DiscoveredProject[];
39
+ }): Promise<PulseResponse>;
40
+ /**
41
+ * Scan the developer's local workspace roots (sibling folders in parent dev dir, ~/dev, ~/Projects, etc.)
42
+ * to discover real project folders so the web UI can auto-match and let the user pick from a dropdown.
43
+ */
44
+ discoverLocalProjects(): DiscoveredProject[];
32
45
  listAssigned(provider?: string, status?: string, boardId?: string, workspaceId?: string): Promise<{
33
46
  provider: string;
34
47
  cards: Card[];
package/dist/client.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
+ import { execSync } from 'node:child_process';
4
+ export const MCP_SERVER_VERSION = '1.0.8';
3
5
  export class AgileMonsterClient {
4
6
  apiKey = '';
5
7
  baseUrl;
@@ -122,6 +124,7 @@ export class AgileMonsterClient {
122
124
  Authorization: `Bearer ${this.apiKey}`,
123
125
  'Content-Type': 'application/json',
124
126
  Accept: 'application/json',
127
+ 'X-AgileMonster-MCP-Version': MCP_SERVER_VERSION,
125
128
  ...(options.headers || {}),
126
129
  };
127
130
  const res = await fetch(url, {
@@ -178,10 +181,112 @@ export class AgileMonsterClient {
178
181
  project_name: projectName,
179
182
  project_path: projectPath,
180
183
  git_remote: gitRemote,
184
+ mcp_version: MCP_SERVER_VERSION,
181
185
  connected: true,
182
186
  }),
183
187
  });
184
188
  }
189
+ async pulse(options) {
190
+ return this.request('/api/agent/pulse', {
191
+ method: 'POST',
192
+ body: JSON.stringify({
193
+ board_id: options.boardId,
194
+ provider: options.provider || 'any',
195
+ project_name: options.projectName,
196
+ project_path: options.projectPath,
197
+ mcp_version: MCP_SERVER_VERSION,
198
+ discovered_projects: options.discoveredProjects,
199
+ }),
200
+ });
201
+ }
202
+ /**
203
+ * Scan the developer's local workspace roots (sibling folders in parent dev dir, ~/dev, ~/Projects, etc.)
204
+ * to discover real project folders so the web UI can auto-match and let the user pick from a dropdown.
205
+ */
206
+ discoverLocalProjects() {
207
+ const roots = new Set();
208
+ const parentDir = path.dirname(this.cwd);
209
+ if (parentDir && parentDir !== '/' && parentDir !== this.cwd) {
210
+ roots.add(parentDir);
211
+ }
212
+ const homedir = process.env.HOME || process.env.USERPROFILE || '';
213
+ if (homedir) {
214
+ for (const sub of ['dev', 'Projects', 'Code', 'repos', 'Developer']) {
215
+ const candidate = path.join(homedir, sub);
216
+ if (fs.existsSync(candidate)) {
217
+ roots.add(candidate);
218
+ }
219
+ }
220
+ }
221
+ const projectMarkers = [
222
+ '.git',
223
+ '.agilemonster.json',
224
+ 'package.json',
225
+ 'pubspec.yaml',
226
+ 'composer.json',
227
+ 'pyproject.toml',
228
+ 'requirements.txt',
229
+ 'Cargo.toml',
230
+ 'go.mod',
231
+ 'Podfile',
232
+ 'CMakeLists.txt',
233
+ 'frontend-flutter',
234
+ 'frontend-nextjs',
235
+ 'backend-php',
236
+ 'src',
237
+ 'lib',
238
+ 'app',
239
+ ];
240
+ const ignoreNames = /^(untitled folder.*|node_modules|vendor|dist|build|archive.*|.*backup.*|\..*)$/i;
241
+ const found = new Map();
242
+ for (const root of roots) {
243
+ let entries = [];
244
+ try {
245
+ entries = fs.readdirSync(root, { withFileTypes: true });
246
+ }
247
+ catch {
248
+ continue;
249
+ }
250
+ for (const entry of entries) {
251
+ if (!entry.isDirectory())
252
+ continue;
253
+ const name = entry.name.trim();
254
+ if (!name || ignoreNames.test(name))
255
+ continue;
256
+ if (/\s\d+$/.test(name))
257
+ continue; // skip "Folder 2", "Folder 3" copies
258
+ const fullPath = path.join(root, name);
259
+ let isProject = false;
260
+ for (const marker of projectMarkers) {
261
+ if (fs.existsSync(path.join(fullPath, marker))) {
262
+ isProject = true;
263
+ break;
264
+ }
265
+ }
266
+ if (!isProject)
267
+ continue;
268
+ let gitRemote = null;
269
+ if (fs.existsSync(path.join(fullPath, '.git'))) {
270
+ try {
271
+ gitRemote =
272
+ execSync('git config --get remote.origin.url', {
273
+ cwd: fullPath,
274
+ stdio: ['ignore', 'pipe', 'ignore'],
275
+ })
276
+ .toString()
277
+ .trim() || null;
278
+ }
279
+ catch { }
280
+ }
281
+ found.set(fullPath, {
282
+ name,
283
+ path: fullPath,
284
+ git_remote: gitRemote,
285
+ });
286
+ }
287
+ }
288
+ return Array.from(found.values()).sort((a, b) => a.name.localeCompare(b.name));
289
+ }
185
290
  async listAssigned(provider = 'any', status, boardId, workspaceId) {
186
291
  const params = new URLSearchParams();
187
292
  if (provider)
@@ -361,7 +361,7 @@ export class AgileMonsterOrchestrator {
361
361
  existing.mcpServers = existing.mcpServers || {};
362
362
  existing.mcpServers.agilemonster = {
363
363
  command: 'npx',
364
- args: ['-y', '@agilemonster/mcp-server'],
364
+ args: ['-y', '@agilemonster/mcp-server@latest'],
365
365
  env: {
366
366
  AGILEMONSTER_API_KEY: apiKey,
367
367
  AGILEMONSTER_API_URL: 'https://api.agilemonster.com',
@@ -388,7 +388,7 @@ export class AgileMonsterOrchestrator {
388
388
  existing.mcpServers = existing.mcpServers || {};
389
389
  existing.mcpServers.agilemonster = {
390
390
  command: 'npx',
391
- args: ['-y', '@agilemonster/mcp-server'],
391
+ args: ['-y', '@agilemonster/mcp-server@latest'],
392
392
  env: {
393
393
  AGILEMONSTER_API_KEY: apiKey,
394
394
  AGILEMONSTER_API_URL: 'https://api.agilemonster.com',
@@ -419,7 +419,7 @@ export class AgileMonsterOrchestrator {
419
419
  existing.mcpServers = existing.mcpServers || {};
420
420
  existing.mcpServers.agilemonster = {
421
421
  command: 'npx',
422
- args: ['-y', '@agilemonster/mcp-server'],
422
+ args: ['-y', '@agilemonster/mcp-server@latest'],
423
423
  env: {
424
424
  AGILEMONSTER_API_KEY: apiKey,
425
425
  AGILEMONSTER_API_URL: 'https://api.agilemonster.com',
@@ -450,7 +450,7 @@ export class AgileMonsterOrchestrator {
450
450
  existing.mcpServers = existing.mcpServers || {};
451
451
  existing.mcpServers.agilemonster = {
452
452
  command: 'npx',
453
- args: ['-y', '@agilemonster/mcp-server'],
453
+ args: ['-y', '@agilemonster/mcp-server@latest'],
454
454
  env: {
455
455
  AGILEMONSTER_API_KEY: apiKey,
456
456
  AGILEMONSTER_API_URL: 'https://api.agilemonster.com',
@@ -479,7 +479,7 @@ export class AgileMonsterOrchestrator {
479
479
  existing.mcpServers = existing.mcpServers || {};
480
480
  existing.mcpServers.agilemonster = {
481
481
  command: 'npx',
482
- args: ['-y', '@agilemonster/mcp-server'],
482
+ args: ['-y', '@agilemonster/mcp-server@latest'],
483
483
  env: {
484
484
  AGILEMONSTER_API_KEY: apiKey,
485
485
  AGILEMONSTER_API_URL: 'https://api.agilemonster.com',
package/dist/server.d.ts CHANGED
@@ -34,4 +34,5 @@ export declare function createServer(client?: AgileMonsterClient): Server<{
34
34
  } | undefined;
35
35
  } | undefined;
36
36
  }>;
37
+ export declare function startBuiltInPullPulse(server: Server, client: AgileMonsterClient, intervalMs?: number): NodeJS.Timeout;
37
38
  export declare function runStdioServer(): Promise<void>;
package/dist/server.js CHANGED
@@ -3,17 +3,18 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
3
3
  import { CallToolRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
4
4
  import path from 'node:path';
5
5
  import fs from 'node:fs';
6
- import { AgileMonsterClient } from './client.js';
6
+ import { spawn } from 'node:child_process';
7
+ import { AgileMonsterClient, MCP_SERVER_VERSION } from './client.js';
7
8
  import { AGENT_GUIDELINES_MARKDOWN } from './guidelines.js';
8
9
  export function createServer(client = new AgileMonsterClient()) {
9
10
  const server = new Server({
10
11
  name: 'agilemonster-mcp-server',
11
- version: '1.0.0',
12
+ version: MCP_SERVER_VERSION,
12
13
  }, {
13
14
  capabilities: {
14
15
  tools: {},
15
16
  prompts: {},
16
- resources: {},
17
+ resources: { subscribe: true, listChanged: true },
17
18
  },
18
19
  });
19
20
  // -------------------------------------------------------------------------
@@ -704,8 +705,199 @@ Please strictly follow the Agile Monster Task Lifecycle Protocol:
704
705
  });
705
706
  return server;
706
707
  }
708
+ function sendDesktopNotification(title, message) {
709
+ if (process.platform === 'darwin') {
710
+ try {
711
+ const safeTitle = title.replace(/["\\]/g, '');
712
+ const safeMsg = message.replace(/["\\]/g, '').slice(0, 180);
713
+ const child = spawn('osascript', ['-e', `display notification "${safeMsg}" with title "${safeTitle}" sound name "Glass"`], { stdio: 'ignore', detached: true });
714
+ child.unref();
715
+ }
716
+ catch { }
717
+ }
718
+ }
719
+ function syncIdeTaskRules(boardName, queuedCards) {
720
+ const cwd = process.cwd();
721
+ const cursorRulesDir = path.join(cwd, '.cursor', 'rules');
722
+ const cursorRuleFile = path.join(cursorRulesDir, 'agilemonster-queue.mdc');
723
+ if (queuedCards.length === 0) {
724
+ try {
725
+ if (fs.existsSync(cursorRuleFile)) {
726
+ fs.unlinkSync(cursorRuleFile);
727
+ }
728
+ }
729
+ catch { }
730
+ return;
731
+ }
732
+ const lines = [
733
+ '---',
734
+ 'description: Active Agile Monster queued tasks assigned to this repository',
735
+ 'globs: ',
736
+ 'alwaysApply: true',
737
+ '---',
738
+ `# 🔔 Queued Agile Monster Tasks for Board "${boardName}"`,
739
+ '',
740
+ `There ${queuedCards.length === 1 ? 'is 1 queued task' : `are ${queuedCards.length} queued tasks`} assigned on the "${boardName}" board waiting to be claimed:`,
741
+ '',
742
+ ];
743
+ for (const c of queuedCards) {
744
+ const worker = c.agent_display_name || c.agent_provider || 'agent';
745
+ const model = c.agent_model && c.agent_model !== 'auto' ? ` (Preferred Model: ${c.agent_model})` : '';
746
+ lines.push(`- **${c.title}** (Card ID: \`${c.id}\` | Assigned to: \`${worker}\`${model})`);
747
+ if (c.description) {
748
+ lines.push(` - Details: ${c.description.replace(/\r?\n/g, ' ').slice(0, 280)}`);
749
+ }
750
+ }
751
+ lines.push('');
752
+ lines.push('When the user starts a task or asks what is next, call `agilemonster_claim_task` with the Card ID above, implement the solution, and submit it for review with `agilemonster_submit_for_review`.');
753
+ try {
754
+ if (fs.existsSync(path.join(cwd, '.cursor'))) {
755
+ if (!fs.existsSync(cursorRulesDir)) {
756
+ fs.mkdirSync(cursorRulesDir, { recursive: true });
757
+ }
758
+ fs.writeFileSync(cursorRuleFile, lines.join('\n') + '\n', 'utf8');
759
+ }
760
+ }
761
+ catch { }
762
+ }
763
+ function triggerBackgroundSelfUpdate() {
764
+ try {
765
+ // 1. Pre-warm latest @agilemonster/mcp-server in npx cache
766
+ const child = spawn('npx', ['-y', '@agilemonster/mcp-server@latest', '--version'], {
767
+ stdio: 'ignore',
768
+ detached: true,
769
+ });
770
+ child.unref();
771
+ // 2. Ensure local .cursor/mcp.json and .mcp.json use @latest so next IDE reload uses latest
772
+ const cwd = process.cwd();
773
+ for (const rel of ['.cursor/mcp.json', '.mcp.json', '.vscode/mcp.json']) {
774
+ const p = path.join(cwd, rel);
775
+ if (fs.existsSync(p)) {
776
+ try {
777
+ const parsed = JSON.parse(fs.readFileSync(p, 'utf8'));
778
+ if (parsed?.mcpServers?.agilemonster) {
779
+ parsed.mcpServers.agilemonster.args = ['-y', '@agilemonster/mcp-server@latest'];
780
+ fs.writeFileSync(p, JSON.stringify(parsed, null, 2), 'utf8');
781
+ }
782
+ }
783
+ catch { }
784
+ }
785
+ }
786
+ }
787
+ catch { }
788
+ }
789
+ export function startBuiltInPullPulse(server, client, intervalMs = 20000) {
790
+ const notifiedCardIds = new Set();
791
+ let updateTriggered = false;
792
+ let pulseCount = 0;
793
+ const autoProvisionSavedBindings = (apiKey, bindings) => {
794
+ for (const b of bindings) {
795
+ const projPath = (b.project_path || '').trim();
796
+ if (!projPath || !fs.existsSync(projPath))
797
+ continue;
798
+ const amConfigPath = path.join(projPath, '.agilemonster.json');
799
+ let needsWrite = true;
800
+ if (fs.existsSync(amConfigPath)) {
801
+ try {
802
+ const existing = JSON.parse(fs.readFileSync(amConfigPath, 'utf8'));
803
+ if (existing?.board_id === b.board_id) {
804
+ needsWrite = false;
805
+ }
806
+ }
807
+ catch { }
808
+ }
809
+ if (needsWrite) {
810
+ try {
811
+ fs.writeFileSync(amConfigPath, JSON.stringify({
812
+ workspace_id: b.workspace_id,
813
+ board_id: b.board_id,
814
+ board_name: b.board_name,
815
+ project_name: b.project_name || path.basename(projPath),
816
+ project_path: projPath,
817
+ provider: b.provider || 'cursor',
818
+ review_list: 'In Review',
819
+ done_list: 'Done',
820
+ api_key: apiKey,
821
+ }, null, 2), 'utf8');
822
+ // Also ensure .cursor/mcp.json and .mcp.json exist in that bound project folder
823
+ const mcpPayload = JSON.stringify({
824
+ mcpServers: {
825
+ agilemonster: {
826
+ command: 'npx',
827
+ args: ['-y', '@agilemonster/mcp-server@latest'],
828
+ env: {
829
+ AGILEMONSTER_API_KEY: apiKey,
830
+ AGILEMONSTER_API_URL: 'https://api.agilemonster.com',
831
+ },
832
+ },
833
+ },
834
+ }, null, 2);
835
+ const cursorDir = path.join(projPath, '.cursor');
836
+ if (!fs.existsSync(cursorDir))
837
+ fs.mkdirSync(cursorDir, { recursive: true });
838
+ const cursorMcp = path.join(cursorDir, 'mcp.json');
839
+ if (!fs.existsSync(cursorMcp))
840
+ fs.writeFileSync(cursorMcp, mcpPayload, 'utf8');
841
+ const claudeMcp = path.join(projPath, '.mcp.json');
842
+ if (!fs.existsSync(claudeMcp))
843
+ fs.writeFileSync(claudeMcp, mcpPayload, 'utf8');
844
+ }
845
+ catch { }
846
+ }
847
+ }
848
+ };
849
+ const runPulse = async () => {
850
+ try {
851
+ const config = client.loadProjectConfig();
852
+ const apiKey = client.getApiKey();
853
+ if (!config?.board_id || !apiKey) {
854
+ return;
855
+ }
856
+ const includeDiscovery = pulseCount === 0 || pulseCount % 15 === 0;
857
+ pulseCount++;
858
+ const res = await client.pulse({
859
+ boardId: config.board_id,
860
+ provider: 'any',
861
+ projectName: config.project_name || path.basename(process.cwd()),
862
+ projectPath: config.project_path || process.cwd(),
863
+ discoveredProjects: includeDiscovery ? client.discoverLocalProjects() : undefined,
864
+ });
865
+ if (res.saved_bindings && res.saved_bindings.length > 0) {
866
+ autoProvisionSavedBindings(apiKey, res.saved_bindings);
867
+ }
868
+ const queued = res.queued_cards || [];
869
+ syncIdeTaskRules(config.board_name || 'Board', queued);
870
+ for (const card of queued) {
871
+ if (!notifiedCardIds.has(card.id)) {
872
+ notifiedCardIds.add(card.id);
873
+ const worker = card.agent_display_name || card.agent_provider || 'AI Agent';
874
+ const modelTag = card.agent_model && card.agent_model !== 'auto' ? ` [${card.agent_model}]` : '';
875
+ sendDesktopNotification(`Agile Monster -> ${worker}${modelTag}`, `New task queued on ${config.board_name || 'Board'}: "${card.title}"`);
876
+ try {
877
+ await server.sendResourceUpdated({ uri: 'agilemonster://project/context' });
878
+ }
879
+ catch { }
880
+ }
881
+ }
882
+ if ((res.version?.force_update_requested || res.version?.update_available) &&
883
+ !updateTriggered) {
884
+ updateTriggered = true;
885
+ triggerBackgroundSelfUpdate();
886
+ }
887
+ }
888
+ catch {
889
+ // Silent during background pulse
890
+ }
891
+ };
892
+ setTimeout(runPulse, 2500).unref();
893
+ const timer = setInterval(runPulse, intervalMs);
894
+ timer.unref();
895
+ return timer;
896
+ }
707
897
  export async function runStdioServer() {
708
- const server = createServer();
898
+ const client = new AgileMonsterClient();
899
+ const server = createServer(client);
709
900
  const transport = new StdioServerTransport();
710
901
  await server.connect(transport);
902
+ startBuiltInPullPulse(server, client, 20000);
711
903
  }
package/dist/types.d.ts CHANGED
@@ -18,6 +18,9 @@ export interface Card {
18
18
  position?: number;
19
19
  due_date?: string | null;
20
20
  agent_provider?: string | null;
21
+ agent_id?: string | null;
22
+ agent_model?: string | null;
23
+ agent_display_name?: string | null;
21
24
  agent_status?: string | null;
22
25
  agent_run_ref?: string | null;
23
26
  max_budget_usd?: number | null;
@@ -59,9 +62,39 @@ export interface BoardAgentConfig {
59
62
  project_name?: string | null;
60
63
  project_path?: string | null;
61
64
  git_remote?: string | null;
65
+ mcp_version?: string | null;
62
66
  connected?: boolean;
63
67
  last_connected_at?: string | null;
64
68
  }
69
+ export interface PulseVersionInfo {
70
+ client_version: string | null;
71
+ latest_version: string;
72
+ min_supported_version: string;
73
+ update_available: boolean;
74
+ update_required: boolean;
75
+ force_update_requested: boolean;
76
+ update_command: string;
77
+ }
78
+ export interface DiscoveredProject {
79
+ name: string;
80
+ path: string;
81
+ git_remote?: string | null;
82
+ }
83
+ export interface PulseResponse {
84
+ board_id: string;
85
+ pulsed_at: string;
86
+ queued_cards: Card[];
87
+ in_progress_cards: Card[];
88
+ version: PulseVersionInfo;
89
+ saved_bindings?: Array<{
90
+ board_id: string;
91
+ board_name: string;
92
+ workspace_id: string;
93
+ provider: string;
94
+ project_name: string;
95
+ project_path?: string | null;
96
+ }>;
97
+ }
65
98
  export interface ContextResponse {
66
99
  matched_board: Board | null;
67
100
  ai_match?: AiBoardMatch | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilemonster/mcp-server",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "type": "module",
5
5
  "description": "Official Model Context Protocol (MCP) server & Orchestrator for Agile Monster (Cursor, Claude Code, Antigravity, Codex, Hermes, Windsurf)",
6
6
  "main": "dist/server.js",