@heroku/mcp-server 1.0.7-alpha.1 → 1.1.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.
- package/README.md +133 -50
- package/bin/heroku-mcp-server.mjs +1 -0
- package/dist/index.js +10 -2
- package/dist/repl/heroku-cli-repl.js +44 -2
- package/dist/repl/heroku-cli-repl.spec.js +161 -0
- package/dist/resources/dev-center-resource.js +34 -0
- package/dist/resources/dev-center-resource.spec.js +19 -0
- package/dist/tools/addons.spec.js +53 -84
- package/dist/tools/ai.spec.js +38 -54
- package/dist/tools/apps.js +0 -23
- package/dist/tools/apps.spec.js +56 -120
- package/dist/tools/data.spec.js +110 -92
- package/dist/tools/logs.spec.js +17 -22
- package/dist/tools/maintenance.spec.js +34 -36
- package/dist/tools/pipelines.spec.js +88 -75
- package/dist/tools/ps.spec.js +56 -53
- package/dist/tools/spaces.spec.js +12 -19
- package/dist/tools/teams.spec.js +13 -19
- package/dist/utils/mcp-tool-mocks.spec.js +71 -0
- package/dist/utils/mcp-tool-mocks.spechelper.js +33 -0
- package/package.json +20 -9
|
@@ -1,55 +1,48 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { HerokuREPL } from '../repl/heroku-cli-repl.js';
|
|
3
1
|
import { TOOL_COMMAND_MAP } from '../utils/tool-commands.js';
|
|
4
2
|
import { registerPipelinesCreateTool, registerPipelinesPromoteTool, registerPipelinesListTool, registerPipelinesInfoTool, registerPipelinesTool } from './pipelines.js';
|
|
5
3
|
import { expect } from 'chai';
|
|
6
4
|
import sinon from 'sinon';
|
|
5
|
+
import { setupMcpToolMocks } from '../utils/mcp-tool-mocks.spechelper.js';
|
|
7
6
|
describe('Pipeline Tools', () => {
|
|
8
|
-
let server;
|
|
9
|
-
let herokuRepl;
|
|
10
|
-
let toolCallback;
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
server = sinon.createStubInstance(McpServer);
|
|
13
|
-
herokuRepl = sinon.createStubInstance(HerokuREPL);
|
|
14
|
-
server.tool.callsFake((_name, _description, _schema, callback) => {
|
|
15
|
-
toolCallback = callback;
|
|
16
|
-
return server;
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
7
|
afterEach(() => {
|
|
20
8
|
sinon.restore();
|
|
21
9
|
});
|
|
22
10
|
describe('pipelines:create', () => {
|
|
11
|
+
let mocks;
|
|
12
|
+
let toolCallback;
|
|
23
13
|
beforeEach(() => {
|
|
24
|
-
|
|
14
|
+
mocks = setupMcpToolMocks();
|
|
15
|
+
registerPipelinesCreateTool(mocks.server, mocks.herokuRepl);
|
|
16
|
+
toolCallback = mocks.getToolCallback();
|
|
25
17
|
});
|
|
26
18
|
it('should register the tool with correct parameters', () => {
|
|
27
|
-
|
|
28
|
-
expect(
|
|
29
|
-
expect(
|
|
30
|
-
expect(
|
|
31
|
-
expect(
|
|
19
|
+
const tool = mocks.server.tool;
|
|
20
|
+
expect(tool.calledOnce).to.be.true;
|
|
21
|
+
expect(tool.firstCall.args[0]).to.equal('pipelines_create');
|
|
22
|
+
expect(tool.firstCall.args[1]).to.be.a('string');
|
|
23
|
+
expect(tool.firstCall.args[2]).to.be.an('object');
|
|
24
|
+
expect(tool.firstCall.args[3]).to.be.a('function');
|
|
32
25
|
});
|
|
33
26
|
it('should build correct command with required parameters', async () => {
|
|
34
|
-
herokuRepl.executeCommand.resolves('Creating pipeline myapp-pipeline... done\n');
|
|
27
|
+
mocks.herokuRepl.executeCommand.resolves('Creating pipeline myapp-pipeline... done\n');
|
|
35
28
|
await toolCallback({ name: 'myapp-pipeline' });
|
|
36
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
37
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES_CREATE} -- myapp-pipeline`);
|
|
29
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
30
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES_CREATE} -- myapp-pipeline`);
|
|
38
31
|
});
|
|
39
32
|
it('should build correct command with all parameters', async () => {
|
|
40
|
-
herokuRepl.executeCommand.resolves('Creating pipeline myapp-pipeline... done\n');
|
|
33
|
+
mocks.herokuRepl.executeCommand.resolves('Creating pipeline myapp-pipeline... done\n');
|
|
41
34
|
await toolCallback({
|
|
42
35
|
name: 'myapp-pipeline',
|
|
43
36
|
stage: 'production',
|
|
44
37
|
app: 'myapp',
|
|
45
38
|
team: 'myteam'
|
|
46
39
|
});
|
|
47
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
48
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES_CREATE} --stage=production --app=myapp --team=myteam -- myapp-pipeline`);
|
|
40
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
41
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES_CREATE} --stage=production --app=myapp --team=myteam -- myapp-pipeline`);
|
|
49
42
|
});
|
|
50
43
|
it('should handle error response', async () => {
|
|
51
44
|
const errorResponse = '<<<ERROR>>>\nError: Pipeline already exists\n<<<END ERROR>>>\n';
|
|
52
|
-
herokuRepl.executeCommand.resolves(errorResponse);
|
|
45
|
+
mocks.herokuRepl.executeCommand.resolves(errorResponse);
|
|
53
46
|
const result = await toolCallback({ name: 'myapp-pipeline' });
|
|
54
47
|
expect(result).to.deep.equal({
|
|
55
48
|
content: [
|
|
@@ -63,111 +56,131 @@ describe('Pipeline Tools', () => {
|
|
|
63
56
|
});
|
|
64
57
|
});
|
|
65
58
|
describe('pipelines:promote', () => {
|
|
59
|
+
let mocks;
|
|
60
|
+
let toolCallback;
|
|
66
61
|
beforeEach(() => {
|
|
67
|
-
|
|
62
|
+
mocks = setupMcpToolMocks();
|
|
63
|
+
registerPipelinesPromoteTool(mocks.server, mocks.herokuRepl);
|
|
64
|
+
toolCallback = mocks.getToolCallback();
|
|
68
65
|
});
|
|
69
66
|
it('should register the tool with correct parameters', () => {
|
|
70
|
-
|
|
71
|
-
expect(
|
|
72
|
-
expect(
|
|
73
|
-
expect(
|
|
74
|
-
expect(
|
|
67
|
+
const tool = mocks.server.tool;
|
|
68
|
+
expect(tool.calledOnce).to.be.true;
|
|
69
|
+
expect(tool.firstCall.args[0]).to.equal('pipelines_promote');
|
|
70
|
+
expect(tool.firstCall.args[1]).to.be.a('string');
|
|
71
|
+
expect(tool.firstCall.args[2]).to.be.an('object');
|
|
72
|
+
expect(tool.firstCall.args[3]).to.be.a('function');
|
|
75
73
|
});
|
|
76
74
|
it('should build correct command with required parameters', async () => {
|
|
77
|
-
herokuRepl.executeCommand.resolves('Promoting myapp to production... done\n');
|
|
75
|
+
mocks.herokuRepl.executeCommand.resolves('Promoting myapp to production... done\n');
|
|
78
76
|
await toolCallback({ app: 'myapp' });
|
|
79
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
80
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES_PROMOTE} --app=myapp`);
|
|
77
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
78
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES_PROMOTE} --app=myapp`);
|
|
81
79
|
});
|
|
82
80
|
it('should build correct command with all parameters', async () => {
|
|
83
|
-
herokuRepl.executeCommand.resolves('Promoting myapp to production... done\n');
|
|
81
|
+
mocks.herokuRepl.executeCommand.resolves('Promoting myapp to production... done\n');
|
|
84
82
|
await toolCallback({
|
|
85
83
|
app: 'myapp',
|
|
86
84
|
to: 'production'
|
|
87
85
|
});
|
|
88
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
89
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES_PROMOTE} --app=myapp --to=production`);
|
|
86
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
87
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES_PROMOTE} --app=myapp --to=production`);
|
|
90
88
|
});
|
|
91
89
|
});
|
|
92
90
|
describe('pipelines:list', () => {
|
|
91
|
+
let mocks;
|
|
92
|
+
let toolCallback;
|
|
93
93
|
beforeEach(() => {
|
|
94
|
-
|
|
94
|
+
mocks = setupMcpToolMocks();
|
|
95
|
+
registerPipelinesListTool(mocks.server, mocks.herokuRepl);
|
|
96
|
+
toolCallback = mocks.getToolCallback();
|
|
95
97
|
});
|
|
96
98
|
it('should register the tool with correct parameters', () => {
|
|
97
|
-
|
|
98
|
-
expect(
|
|
99
|
-
expect(
|
|
100
|
-
expect(
|
|
101
|
-
expect(
|
|
99
|
+
const tool = mocks.server.tool;
|
|
100
|
+
expect(tool.calledOnce).to.be.true;
|
|
101
|
+
expect(tool.firstCall.args[0]).to.equal('pipelines_list');
|
|
102
|
+
expect(tool.firstCall.args[1]).to.be.a('string');
|
|
103
|
+
expect(tool.firstCall.args[2]).to.be.an('object');
|
|
104
|
+
expect(tool.firstCall.args[3]).to.be.a('function');
|
|
102
105
|
});
|
|
103
106
|
it('should build correct command with no parameters', async () => {
|
|
104
|
-
herokuRepl.executeCommand.resolves('=== My Pipelines\nmyapp-pipeline\n');
|
|
107
|
+
mocks.herokuRepl.executeCommand.resolves('=== My Pipelines\nmyapp-pipeline\n');
|
|
105
108
|
await toolCallback({});
|
|
106
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
107
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(TOOL_COMMAND_MAP.PIPELINES);
|
|
109
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
110
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(TOOL_COMMAND_MAP.PIPELINES);
|
|
108
111
|
});
|
|
109
112
|
it('should build correct command with all parameters', async () => {
|
|
110
|
-
herokuRepl.executeCommand.resolves('=== My Pipelines\nmyapp-pipeline\n');
|
|
113
|
+
mocks.herokuRepl.executeCommand.resolves('=== My Pipelines\nmyapp-pipeline\n');
|
|
111
114
|
await toolCallback({
|
|
112
115
|
json: true,
|
|
113
116
|
team: 'myteam'
|
|
114
117
|
});
|
|
115
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
116
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES} --json`);
|
|
118
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
119
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES} --json`);
|
|
117
120
|
});
|
|
118
121
|
});
|
|
119
122
|
describe('pipelines:info', () => {
|
|
123
|
+
let mocks;
|
|
124
|
+
let toolCallback;
|
|
120
125
|
beforeEach(() => {
|
|
121
|
-
|
|
126
|
+
mocks = setupMcpToolMocks();
|
|
127
|
+
registerPipelinesInfoTool(mocks.server, mocks.herokuRepl);
|
|
128
|
+
toolCallback = mocks.getToolCallback();
|
|
122
129
|
});
|
|
123
130
|
it('should register the tool with correct parameters', () => {
|
|
124
|
-
|
|
125
|
-
expect(
|
|
126
|
-
expect(
|
|
127
|
-
expect(
|
|
128
|
-
expect(
|
|
131
|
+
const tool = mocks.server.tool;
|
|
132
|
+
expect(tool.calledOnce).to.be.true;
|
|
133
|
+
expect(tool.firstCall.args[0]).to.equal('pipelines_info');
|
|
134
|
+
expect(tool.firstCall.args[1]).to.be.a('string');
|
|
135
|
+
expect(tool.firstCall.args[2]).to.be.an('object');
|
|
136
|
+
expect(tool.firstCall.args[3]).to.be.a('function');
|
|
129
137
|
});
|
|
130
138
|
it('should build correct command with required parameters', async () => {
|
|
131
|
-
herokuRepl.executeCommand.resolves('=== myapp-pipeline\nStaging: myapp-staging\nProduction: myapp-prod\n');
|
|
139
|
+
mocks.herokuRepl.executeCommand.resolves('=== myapp-pipeline\nStaging: myapp-staging\nProduction: myapp-prod\n');
|
|
132
140
|
await toolCallback({ pipeline: 'myapp-pipeline' });
|
|
133
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
134
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES_INFO} -- myapp-pipeline`);
|
|
141
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
142
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES_INFO} -- myapp-pipeline`);
|
|
135
143
|
});
|
|
136
144
|
it('should build correct command with all parameters', async () => {
|
|
137
|
-
herokuRepl.executeCommand.resolves('{"pipeline": "myapp-pipeline", "apps": {...}}\n');
|
|
145
|
+
mocks.herokuRepl.executeCommand.resolves('{"pipeline": "myapp-pipeline", "apps": {...}}\n');
|
|
138
146
|
await toolCallback({
|
|
139
147
|
pipeline: 'myapp-pipeline',
|
|
140
148
|
json: true
|
|
141
149
|
});
|
|
142
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
143
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES_INFO} --json -- myapp-pipeline`);
|
|
150
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
151
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PIPELINES_INFO} --json -- myapp-pipeline`);
|
|
144
152
|
});
|
|
145
153
|
});
|
|
146
154
|
describe('pipelines', () => {
|
|
155
|
+
let mocks;
|
|
156
|
+
let toolCallback;
|
|
147
157
|
beforeEach(() => {
|
|
148
|
-
|
|
158
|
+
mocks = setupMcpToolMocks();
|
|
159
|
+
registerPipelinesTool(mocks.server, mocks.herokuRepl);
|
|
160
|
+
toolCallback = mocks.getToolCallback();
|
|
149
161
|
});
|
|
150
162
|
it('should register the tool with correct parameters', () => {
|
|
151
|
-
|
|
152
|
-
expect(
|
|
153
|
-
expect(
|
|
154
|
-
expect(
|
|
155
|
-
expect(
|
|
163
|
+
const tool = mocks.server.tool;
|
|
164
|
+
expect(tool.calledOnce).to.be.true;
|
|
165
|
+
expect(tool.firstCall.args[0]).to.equal('pipelines');
|
|
166
|
+
expect(tool.firstCall.args[1]).to.be.a('string');
|
|
167
|
+
expect(tool.firstCall.args[2]).to.be.an('object');
|
|
168
|
+
expect(tool.firstCall.args[3]).to.be.a('function');
|
|
156
169
|
});
|
|
157
170
|
it('should build correct command with no parameters', async () => {
|
|
158
|
-
herokuRepl.executeCommand.resolves('=== My Pipelines\nmyapp-pipeline\n');
|
|
171
|
+
mocks.herokuRepl.executeCommand.resolves('=== My Pipelines\nmyapp-pipeline\n');
|
|
159
172
|
await toolCallback({});
|
|
160
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
161
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal('pipelines');
|
|
173
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
174
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal('pipelines');
|
|
162
175
|
});
|
|
163
176
|
it('should build correct command with json parameter', async () => {
|
|
164
|
-
herokuRepl.executeCommand.resolves('{"pipelines": [...]}\n');
|
|
177
|
+
mocks.herokuRepl.executeCommand.resolves('{"pipelines": [...]}\n');
|
|
165
178
|
await toolCallback({ json: true });
|
|
166
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
167
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal('pipelines --json');
|
|
179
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
180
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal('pipelines --json');
|
|
168
181
|
});
|
|
169
182
|
it('should handle undefined response', async () => {
|
|
170
|
-
herokuRepl.executeCommand.resolves(undefined);
|
|
183
|
+
mocks.herokuRepl.executeCommand.resolves(undefined);
|
|
171
184
|
const result = await toolCallback({});
|
|
172
185
|
expect(result).to.deep.equal({
|
|
173
186
|
content: [
|
package/dist/tools/ps.spec.js
CHANGED
|
@@ -1,53 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HerokuREPL } from '../repl/heroku-cli-repl.js';
|
|
1
|
+
import { setupMcpToolMocks } from '../utils/mcp-tool-mocks.spechelper.js';
|
|
3
2
|
import { TOOL_COMMAND_MAP } from '../utils/tool-commands.js';
|
|
4
3
|
import { registerPsListTool, registerPsScaleTool, registerPsRestartTool } from './ps.js';
|
|
5
4
|
import { expect } from 'chai';
|
|
6
5
|
import sinon from 'sinon';
|
|
7
6
|
describe('Process Management Tools', () => {
|
|
8
|
-
let server;
|
|
9
|
-
let herokuRepl;
|
|
10
|
-
let toolCallback;
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
server = sinon.createStubInstance(McpServer);
|
|
13
|
-
herokuRepl = sinon.createStubInstance(HerokuREPL);
|
|
14
|
-
server.tool.callsFake((_name, _description, _schema, callback) => {
|
|
15
|
-
toolCallback = callback;
|
|
16
|
-
return server;
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
7
|
afterEach(() => {
|
|
20
8
|
sinon.restore();
|
|
21
9
|
});
|
|
22
10
|
describe('ps:list', () => {
|
|
11
|
+
let mocks;
|
|
12
|
+
let toolCallback;
|
|
23
13
|
beforeEach(() => {
|
|
24
|
-
|
|
14
|
+
mocks = setupMcpToolMocks();
|
|
15
|
+
registerPsListTool(mocks.server, mocks.herokuRepl);
|
|
16
|
+
toolCallback = mocks.getToolCallback();
|
|
25
17
|
});
|
|
26
18
|
it('should register the tool with correct parameters', () => {
|
|
27
|
-
|
|
28
|
-
expect(
|
|
29
|
-
expect(
|
|
30
|
-
expect(
|
|
31
|
-
expect(
|
|
19
|
+
const tool = mocks.server.tool;
|
|
20
|
+
expect(tool.calledOnce).to.be.true;
|
|
21
|
+
expect(tool.firstCall.args[0]).to.equal('ps_list');
|
|
22
|
+
expect(tool.firstCall.args[1]).to.be.a('string');
|
|
23
|
+
expect(tool.firstCall.args[2]).to.be.an('object');
|
|
24
|
+
expect(tool.firstCall.args[3]).to.be.a('function');
|
|
32
25
|
});
|
|
33
26
|
it('should build correct command with required parameters', async () => {
|
|
34
|
-
herokuRepl.executeCommand.resolves('=== run: one-off processes\n=== web: web processes\nweb.1: up\n');
|
|
27
|
+
mocks.herokuRepl.executeCommand.resolves('=== run: one-off processes\n=== web: web processes\nweb.1: up\n');
|
|
35
28
|
await toolCallback({ app: 'myapp' });
|
|
36
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
37
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS} --app=myapp`);
|
|
29
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
30
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS} --app=myapp`);
|
|
38
31
|
});
|
|
39
32
|
it('should build correct command with all parameters', async () => {
|
|
40
|
-
herokuRepl.executeCommand.resolves('=== run: one-off processes\n=== web: web processes\nweb.1: up\n');
|
|
33
|
+
mocks.herokuRepl.executeCommand.resolves('=== run: one-off processes\n=== web: web processes\nweb.1: up\n');
|
|
41
34
|
await toolCallback({
|
|
42
35
|
app: 'myapp',
|
|
43
36
|
json: true
|
|
44
37
|
});
|
|
45
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
46
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS} --app=myapp --json`);
|
|
38
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
39
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS} --app=myapp --json`);
|
|
47
40
|
});
|
|
48
41
|
it('should handle error response', async () => {
|
|
49
42
|
const errorResponse = '<<<ERROR>>>\nError: App not found\n<<<END ERROR>>>\n';
|
|
50
|
-
herokuRepl.executeCommand.resolves(errorResponse);
|
|
43
|
+
mocks.herokuRepl.executeCommand.resolves(errorResponse);
|
|
51
44
|
const result = await toolCallback({ app: 'myapp' });
|
|
52
45
|
expect(result).to.deep.equal({
|
|
53
46
|
content: [
|
|
@@ -61,67 +54,77 @@ describe('Process Management Tools', () => {
|
|
|
61
54
|
});
|
|
62
55
|
});
|
|
63
56
|
describe('ps:scale', () => {
|
|
57
|
+
let mocks;
|
|
58
|
+
let toolCallback;
|
|
64
59
|
beforeEach(() => {
|
|
65
|
-
|
|
60
|
+
mocks = setupMcpToolMocks();
|
|
61
|
+
registerPsScaleTool(mocks.server, mocks.herokuRepl);
|
|
62
|
+
toolCallback = mocks.getToolCallback();
|
|
66
63
|
});
|
|
67
64
|
it('should register the tool with correct parameters', () => {
|
|
68
|
-
|
|
69
|
-
expect(
|
|
70
|
-
expect(
|
|
71
|
-
expect(
|
|
72
|
-
expect(
|
|
65
|
+
const tool = mocks.server.tool;
|
|
66
|
+
expect(tool.calledOnce).to.be.true;
|
|
67
|
+
expect(tool.firstCall.args[0]).to.equal('ps_scale');
|
|
68
|
+
expect(tool.firstCall.args[1]).to.be.a('string');
|
|
69
|
+
expect(tool.firstCall.args[2]).to.be.an('object');
|
|
70
|
+
expect(tool.firstCall.args[3]).to.be.a('function');
|
|
73
71
|
});
|
|
74
72
|
it('should build correct command with required parameters', async () => {
|
|
75
|
-
herokuRepl.executeCommand.resolves('Scaling dynos... done, now running web at 2:Standard-1X\n');
|
|
73
|
+
mocks.herokuRepl.executeCommand.resolves('Scaling dynos... done, now running web at 2:Standard-1X\n');
|
|
76
74
|
await toolCallback({ app: 'myapp', dyno: 'web=2' });
|
|
77
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
78
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS_SCALE} --app=myapp -- web=2`);
|
|
75
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
76
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS_SCALE} --app=myapp -- web=2`);
|
|
79
77
|
});
|
|
80
78
|
it('should build correct command with remote parameter', async () => {
|
|
81
|
-
herokuRepl.executeCommand.resolves('Scaling dynos... done, now running web at 2:Standard-1X\n');
|
|
79
|
+
mocks.herokuRepl.executeCommand.resolves('Scaling dynos... done, now running web at 2:Standard-1X\n');
|
|
82
80
|
await toolCallback({
|
|
83
81
|
app: 'myapp',
|
|
84
82
|
dyno: 'web=2'
|
|
85
83
|
});
|
|
86
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
87
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS_SCALE} --app=myapp -- web=2`);
|
|
84
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
85
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS_SCALE} --app=myapp -- web=2`);
|
|
88
86
|
});
|
|
89
87
|
});
|
|
90
88
|
describe('ps:restart', () => {
|
|
89
|
+
let mocks;
|
|
90
|
+
let toolCallback;
|
|
91
91
|
beforeEach(() => {
|
|
92
|
-
|
|
92
|
+
mocks = setupMcpToolMocks();
|
|
93
|
+
registerPsRestartTool(mocks.server, mocks.herokuRepl);
|
|
94
|
+
toolCallback = mocks.getToolCallback();
|
|
93
95
|
});
|
|
94
96
|
it('should register the tool with correct parameters', () => {
|
|
95
|
-
|
|
96
|
-
expect(
|
|
97
|
-
expect(
|
|
98
|
-
expect(
|
|
99
|
-
expect(
|
|
97
|
+
const tool = mocks.server.tool;
|
|
98
|
+
expect(tool.calledOnce).to.be.true;
|
|
99
|
+
expect(tool.firstCall.args[0]).to.equal('ps_restart');
|
|
100
|
+
expect(tool.firstCall.args[1]).to.be.a('string');
|
|
101
|
+
expect(tool.firstCall.args[2]).to.be.an('object');
|
|
102
|
+
expect(tool.firstCall.args[3]).to.be.a('function');
|
|
100
103
|
});
|
|
101
104
|
it('should build correct command with required parameters', async () => {
|
|
102
|
-
herokuRepl.executeCommand.resolves('Restarting all dynos... done\n');
|
|
105
|
+
mocks.herokuRepl.executeCommand.resolves('Restarting all dynos... done\n');
|
|
103
106
|
await toolCallback({ app: 'myapp' });
|
|
104
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
105
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS_RESTART} --app=myapp`);
|
|
107
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
108
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS_RESTART} --app=myapp`);
|
|
106
109
|
});
|
|
107
110
|
it('should build correct command with specific dyno', async () => {
|
|
108
|
-
herokuRepl.executeCommand.resolves('Restarting web.1 dyno... done\n');
|
|
111
|
+
mocks.herokuRepl.executeCommand.resolves('Restarting web.1 dyno... done\n');
|
|
109
112
|
await toolCallback({
|
|
110
113
|
app: 'myapp',
|
|
111
114
|
'dyno-name': 'web.1'
|
|
112
115
|
});
|
|
113
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
114
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS_RESTART} --app=myapp --dyno-name=web.1`);
|
|
116
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
117
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS_RESTART} --app=myapp --dyno-name=web.1`);
|
|
115
118
|
});
|
|
116
119
|
it('should build correct command with all parameters', async () => {
|
|
117
|
-
herokuRepl.executeCommand.resolves('Restarting web dynos... done\n');
|
|
120
|
+
mocks.herokuRepl.executeCommand.resolves('Restarting web dynos... done\n');
|
|
118
121
|
await toolCallback({
|
|
119
122
|
app: 'myapp',
|
|
120
123
|
'dyno-name': 'web.1',
|
|
121
124
|
'process-type': 'web'
|
|
122
125
|
});
|
|
123
|
-
expect(herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
124
|
-
expect(herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS_RESTART} --app=myapp --dyno-name=web.1 --process-type=web`);
|
|
126
|
+
expect(mocks.herokuRepl.executeCommand.calledOnce).to.be.true;
|
|
127
|
+
expect(mocks.herokuRepl.executeCommand.firstCall.args[0]).to.equal(`${TOOL_COMMAND_MAP.PS_RESTART} --app=myapp --dyno-name=web.1 --process-type=web`);
|
|
125
128
|
});
|
|
126
129
|
});
|
|
127
130
|
});
|
|
@@ -1,40 +1,33 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
import sinon from 'sinon';
|
|
3
|
-
import {
|
|
4
|
-
import { HerokuREPL } from '../repl/heroku-cli-repl.js';
|
|
3
|
+
import { setupMcpToolMocks } from '../utils/mcp-tool-mocks.spechelper.js';
|
|
5
4
|
import { listPrivateSpacesOptionsSchema, registerListPrivateSpacesTool } from './spaces.js';
|
|
6
5
|
import { CommandBuilder } from '../utils/command-builder.js';
|
|
7
6
|
import { TOOL_COMMAND_MAP } from '../utils/tool-commands.js';
|
|
8
7
|
describe('spaces topic tools', () => {
|
|
9
8
|
describe('registerListPrivateSpacesTool', () => {
|
|
10
|
-
let
|
|
11
|
-
let herokuRepl;
|
|
9
|
+
let mocks;
|
|
12
10
|
let toolCallback;
|
|
13
11
|
beforeEach(() => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
server.tool.callsFake((_name, _description, _schema, callback) => {
|
|
18
|
-
toolCallback = callback;
|
|
19
|
-
return server;
|
|
20
|
-
});
|
|
21
|
-
registerListPrivateSpacesTool(server, herokuRepl);
|
|
12
|
+
mocks = setupMcpToolMocks();
|
|
13
|
+
registerListPrivateSpacesTool(mocks.server, mocks.herokuRepl);
|
|
14
|
+
toolCallback = mocks.getToolCallback();
|
|
22
15
|
});
|
|
23
16
|
afterEach(() => {
|
|
24
17
|
sinon.restore();
|
|
25
18
|
});
|
|
26
19
|
it('registers the tool with correct name and schema', () => {
|
|
27
|
-
expect(server.tool.calledOnce).to.be.true;
|
|
28
|
-
const call = server.tool.getCall(0);
|
|
20
|
+
expect(mocks.server.tool.calledOnce).to.be.true;
|
|
21
|
+
const call = mocks.server.tool.getCall(0);
|
|
29
22
|
expect(call.args[0]).to.equal('list_private_spaces');
|
|
30
23
|
expect(call.args[2]).to.deep.equal(listPrivateSpacesOptionsSchema.shape);
|
|
31
24
|
});
|
|
32
25
|
it('executes command successfully with json flag', async () => {
|
|
33
26
|
const expectedOutput = '{"spaces": []}';
|
|
34
27
|
const expectedCommand = new CommandBuilder(TOOL_COMMAND_MAP.LIST_PRIVATE_SPACES).addFlags({ json: true }).build();
|
|
35
|
-
herokuRepl.executeCommand.resolves(expectedOutput);
|
|
28
|
+
mocks.herokuRepl.executeCommand.resolves(expectedOutput);
|
|
36
29
|
const result = await toolCallback({ json: true }, {});
|
|
37
|
-
expect(herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
|
|
30
|
+
expect(mocks.herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
|
|
38
31
|
expect(result).to.deep.equal({
|
|
39
32
|
content: [{ type: 'text', text: expectedOutput }]
|
|
40
33
|
});
|
|
@@ -44,16 +37,16 @@ describe('spaces topic tools', () => {
|
|
|
44
37
|
const expectedCommand = new CommandBuilder(TOOL_COMMAND_MAP.LIST_PRIVATE_SPACES)
|
|
45
38
|
.addFlags({ json: false })
|
|
46
39
|
.build();
|
|
47
|
-
herokuRepl.executeCommand.resolves(expectedOutput);
|
|
40
|
+
mocks.herokuRepl.executeCommand.resolves(expectedOutput);
|
|
48
41
|
const result = await toolCallback({ json: false }, {});
|
|
49
|
-
expect(herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
|
|
42
|
+
expect(mocks.herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
|
|
50
43
|
expect(result).to.deep.equal({
|
|
51
44
|
content: [{ type: 'text', text: expectedOutput }]
|
|
52
45
|
});
|
|
53
46
|
});
|
|
54
47
|
it('handles CLI errors properly', async () => {
|
|
55
48
|
const expectedOutput = '<<<BEGIN RESULTS>>>\n<<<ERROR>>>API error<<<END ERROR>>><<<END RESULTS>>>';
|
|
56
|
-
herokuRepl.executeCommand.resolves(expectedOutput);
|
|
49
|
+
mocks.herokuRepl.executeCommand.resolves(expectedOutput);
|
|
57
50
|
const result = await toolCallback({}, {});
|
|
58
51
|
expect(result).to.deep.equal({
|
|
59
52
|
isError: true,
|
package/dist/tools/teams.spec.js
CHANGED
|
@@ -1,40 +1,34 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
import sinon from 'sinon';
|
|
3
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
-
import { HerokuREPL } from '../repl/heroku-cli-repl.js';
|
|
5
3
|
import { listTeamsOptionsSchema, registerListTeamsTool } from './teams.js';
|
|
6
4
|
import { CommandBuilder } from '../utils/command-builder.js';
|
|
7
5
|
import { TOOL_COMMAND_MAP } from '../utils/tool-commands.js';
|
|
6
|
+
import { setupMcpToolMocks } from '../utils/mcp-tool-mocks.spechelper.js';
|
|
8
7
|
describe('teams', () => {
|
|
9
8
|
describe('registerListTeamsTool', () => {
|
|
10
|
-
let
|
|
11
|
-
let herokuRepl;
|
|
9
|
+
let mocks;
|
|
12
10
|
let toolCallback;
|
|
13
11
|
beforeEach(() => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
server.tool.callsFake((_name, _description, _schema, callback) => {
|
|
18
|
-
toolCallback = callback;
|
|
19
|
-
return server;
|
|
20
|
-
});
|
|
21
|
-
registerListTeamsTool(server, herokuRepl);
|
|
12
|
+
mocks = setupMcpToolMocks();
|
|
13
|
+
registerListTeamsTool(mocks.server, mocks.herokuRepl);
|
|
14
|
+
toolCallback = mocks.getToolCallback();
|
|
22
15
|
});
|
|
23
16
|
afterEach(() => {
|
|
24
17
|
sinon.restore();
|
|
25
18
|
});
|
|
26
19
|
it('registers the tool with correct name and schema', () => {
|
|
27
|
-
|
|
28
|
-
const call =
|
|
20
|
+
const tool = mocks.server.tool;
|
|
21
|
+
const call = tool.getCall(0);
|
|
22
|
+
expect(tool.calledOnce).to.be.true;
|
|
29
23
|
expect(call.args[0]).to.equal('list_teams');
|
|
30
24
|
expect(call.args[2]).to.deep.equal(listTeamsOptionsSchema.shape);
|
|
31
25
|
});
|
|
32
26
|
it('executes command successfully with json flag', async () => {
|
|
33
27
|
const expectedOutput = '[{"name": "test-team", "role": "collaborator"}]';
|
|
34
28
|
const expectedCommand = new CommandBuilder(TOOL_COMMAND_MAP.LIST_TEAMS).addFlags({ json: true }).build();
|
|
35
|
-
herokuRepl.executeCommand.resolves(expectedOutput);
|
|
29
|
+
mocks.herokuRepl.executeCommand.resolves(expectedOutput);
|
|
36
30
|
const result = await toolCallback({ json: true }, {});
|
|
37
|
-
expect(herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
|
|
31
|
+
expect(mocks.herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
|
|
38
32
|
expect(result).to.deep.equal({
|
|
39
33
|
content: [{ type: 'text', text: expectedOutput }]
|
|
40
34
|
});
|
|
@@ -42,16 +36,16 @@ describe('teams', () => {
|
|
|
42
36
|
it('executes command successfully without json flag', async () => {
|
|
43
37
|
const expectedOutput = ' Team Role \n' + ' ───────── ──────────── \n' + ' test-team collaborator \n';
|
|
44
38
|
const expectedCommand = new CommandBuilder(TOOL_COMMAND_MAP.LIST_TEAMS).addFlags({ json: false }).build();
|
|
45
|
-
herokuRepl.executeCommand.resolves(expectedOutput);
|
|
39
|
+
mocks.herokuRepl.executeCommand.resolves(expectedOutput);
|
|
46
40
|
const result = await toolCallback({ json: false }, {});
|
|
47
|
-
expect(herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
|
|
41
|
+
expect(mocks.herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
|
|
48
42
|
expect(result).to.deep.equal({
|
|
49
43
|
content: [{ type: 'text', text: expectedOutput }]
|
|
50
44
|
});
|
|
51
45
|
});
|
|
52
46
|
it('handles CLI errors properly', async () => {
|
|
53
47
|
const expectedOutput = '<<<BEGIN RESULTS>>>\n<<<ERROR>>>API error<<<END ERROR>>><<<END RESULTS>>>';
|
|
54
|
-
herokuRepl.executeCommand.resolves(expectedOutput);
|
|
48
|
+
mocks.herokuRepl.executeCommand.resolves(expectedOutput);
|
|
55
49
|
const result = await toolCallback({}, {});
|
|
56
50
|
expect(result).to.deep.equal({
|
|
57
51
|
isError: true,
|