@swarmify/agents-mcp 0.2.12 → 0.2.14

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.
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Postinstall script for @swarmify/agents-mcp
5
+ * Detects installed agent CLIs and registers this MCP server with each.
6
+ */
7
+
8
+ import { execSync, spawnSync } from 'child_process';
9
+
10
+ const MCP_NAME = 'Swarm';
11
+ const MCP_COMMAND = 'npx -y @swarmify/agents-mcp@latest';
12
+
13
+ // Agent configurations: CLI name, detection command, register command
14
+ const AGENTS = {
15
+ claude: {
16
+ name: 'Claude Code',
17
+ cli: 'claude',
18
+ register: `claude mcp add --scope user ${MCP_NAME} -- ${MCP_COMMAND}`,
19
+ unregister: `claude mcp remove ${MCP_NAME} --scope user`,
20
+ },
21
+ codex: {
22
+ name: 'Codex',
23
+ cli: 'codex',
24
+ register: `codex mcp add ${MCP_NAME.toLowerCase()} -- ${MCP_COMMAND}`,
25
+ unregister: `codex mcp remove ${MCP_NAME.toLowerCase()}`,
26
+ },
27
+ gemini: {
28
+ name: 'Gemini CLI',
29
+ cli: 'gemini',
30
+ register: `gemini mcp add ${MCP_NAME} "${MCP_COMMAND}"`,
31
+ unregister: `gemini mcp remove ${MCP_NAME}`,
32
+ },
33
+ };
34
+
35
+ function isCliInstalled(cli) {
36
+ try {
37
+ execSync(`which ${cli}`, { stdio: 'ignore' });
38
+ return true;
39
+ } catch {
40
+ return false;
41
+ }
42
+ }
43
+
44
+ function registerWithAgent(agentId, config) {
45
+ try {
46
+ const result = spawnSync('sh', ['-c', config.register], {
47
+ stdio: 'pipe',
48
+ timeout: 30000,
49
+ });
50
+
51
+ if (result.status === 0) {
52
+ return { success: true };
53
+ } else {
54
+ const stderr = result.stderr?.toString() || '';
55
+ if (stderr.includes('already exists') || stderr.includes('already registered')) {
56
+ return { success: true, alreadyExists: true };
57
+ }
58
+ return { success: false, error: stderr || 'Unknown error' };
59
+ }
60
+ } catch (err) {
61
+ return { success: false, error: err.message };
62
+ }
63
+ }
64
+
65
+ function main() {
66
+ if (process.env.CI || process.env.CONTINUOUS_INTEGRATION) {
67
+ return;
68
+ }
69
+
70
+ if (process.env.AGENTS_MCP_SKIP_POSTINSTALL === '1') {
71
+ return;
72
+ }
73
+
74
+ console.log('\n@swarmify/agents-mcp - Auto-registering with detected agents...\n');
75
+
76
+ const detected = [];
77
+ const registered = [];
78
+ const skipped = [];
79
+ const failed = [];
80
+
81
+ for (const [agentId, config] of Object.entries(AGENTS)) {
82
+ if (isCliInstalled(config.cli)) {
83
+ detected.push(config.name);
84
+ const result = registerWithAgent(agentId, config);
85
+
86
+ if (result.success) {
87
+ if (result.alreadyExists) {
88
+ skipped.push(`${config.name} (already registered)`);
89
+ } else {
90
+ registered.push(config.name);
91
+ }
92
+ } else {
93
+ failed.push(`${config.name}: ${result.error}`);
94
+ }
95
+ }
96
+ }
97
+
98
+ if (detected.length === 0) {
99
+ console.log(' No supported agent CLIs detected.');
100
+ console.log(' Install Claude, Codex, or Gemini CLI, then run:');
101
+ console.log(' npx @swarmify/agents-mcp --register\n');
102
+ return;
103
+ }
104
+
105
+ if (registered.length > 0) {
106
+ console.log(' Registered with:');
107
+ for (const name of registered) {
108
+ console.log(` + ${name}`);
109
+ }
110
+ }
111
+
112
+ if (skipped.length > 0) {
113
+ console.log(' Already registered:');
114
+ for (const name of skipped) {
115
+ console.log(` - ${name}`);
116
+ }
117
+ }
118
+
119
+ if (failed.length > 0) {
120
+ console.log(' Failed:');
121
+ for (const msg of failed) {
122
+ console.log(` x ${msg}`);
123
+ }
124
+ }
125
+
126
+ console.log('\n Restart your agent to use Swarm tools.\n');
127
+ }
128
+
129
+ main();
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Preuninstall script for @swarmify/agents-mcp
5
+ * Unregisters this MCP server from all detected agents.
6
+ */
7
+
8
+ import { execSync, spawnSync } from 'child_process';
9
+
10
+ const MCP_NAME = 'Swarm';
11
+
12
+ const AGENTS = {
13
+ claude: {
14
+ name: 'Claude Code',
15
+ cli: 'claude',
16
+ unregister: `claude mcp remove ${MCP_NAME} --scope user`,
17
+ },
18
+ codex: {
19
+ name: 'Codex',
20
+ cli: 'codex',
21
+ unregister: `codex mcp remove ${MCP_NAME.toLowerCase()}`,
22
+ },
23
+ gemini: {
24
+ name: 'Gemini CLI',
25
+ cli: 'gemini',
26
+ unregister: `gemini mcp remove ${MCP_NAME}`,
27
+ },
28
+ };
29
+
30
+ function isCliInstalled(cli) {
31
+ try {
32
+ execSync(`which ${cli}`, { stdio: 'ignore' });
33
+ return true;
34
+ } catch {
35
+ return false;
36
+ }
37
+ }
38
+
39
+ function unregisterFromAgent(config) {
40
+ try {
41
+ const result = spawnSync('sh', ['-c', config.unregister], {
42
+ stdio: 'pipe',
43
+ timeout: 30000,
44
+ });
45
+ return { success: result.status === 0 };
46
+ } catch {
47
+ return { success: false };
48
+ }
49
+ }
50
+
51
+ function main() {
52
+ if (process.env.CI || process.env.CONTINUOUS_INTEGRATION) {
53
+ return;
54
+ }
55
+
56
+ if (process.env.AGENTS_MCP_SKIP_PREUNINSTALL === '1') {
57
+ return;
58
+ }
59
+
60
+ console.log('\n@swarmify/agents-mcp - Unregistering from agents...\n');
61
+
62
+ const removed = [];
63
+
64
+ for (const [agentId, config] of Object.entries(AGENTS)) {
65
+ if (isCliInstalled(config.cli)) {
66
+ const result = unregisterFromAgent(config);
67
+ if (result.success) {
68
+ removed.push(config.name);
69
+ }
70
+ }
71
+ }
72
+
73
+ if (removed.length > 0) {
74
+ console.log(' Unregistered from:');
75
+ for (const name of removed) {
76
+ console.log(` - ${name}`);
77
+ }
78
+ console.log('');
79
+ }
80
+ }
81
+
82
+ main();
@@ -0,0 +1,51 @@
1
+ #!/bin/bash
2
+ # Build and publish the Swarm MCP server package to npm
3
+
4
+ set -euo pipefail
5
+
6
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
+ SWARM_DIR="$(dirname "$SCRIPT_DIR")"
8
+
9
+ cd "$SWARM_DIR"
10
+
11
+ if [[ $# -ne 1 ]]; then
12
+ echo "Usage: $0 x.y.z"
13
+ exit 1
14
+ fi
15
+
16
+ VERSION="$1"
17
+ if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
18
+ echo "Invalid version: $VERSION"
19
+ echo "Expected format: x.y.z"
20
+ exit 1
21
+ fi
22
+
23
+ if ! command -v bun >/dev/null 2>&1; then
24
+ echo "bun is required but was not found in PATH"
25
+ exit 1
26
+ fi
27
+
28
+ if ! command -v npm >/dev/null 2>&1; then
29
+ echo "npm is required but was not found in PATH"
30
+ exit 1
31
+ fi
32
+
33
+ # Ensure dependencies are installed
34
+ bun install
35
+
36
+ # Build TypeScript output
37
+ rm -rf dist
38
+ bun run build
39
+
40
+ # Bump package version without git tagging
41
+ npm version "$VERSION" --no-git-tag-version
42
+
43
+ # Verify npm auth before publishing
44
+ if ! npm whoami >/dev/null 2>&1; then
45
+ echo "npm login required before publishing"
46
+ exit 1
47
+ fi
48
+
49
+ npm publish --access public
50
+
51
+ echo "Publish complete"