Skip to content

Commit 7f2efe9

Browse files
committed
refactor: rename mcp-tool to gateway-target across CLI (#377)
1 parent 56134db commit 7f2efe9

34 files changed

+207
-183
lines changed

src/cli/commands/add/__tests__/add-mcp-tool.test.ts renamed to src/cli/commands/add/__tests__/add-gateway-target.test.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ import { join } from 'node:path';
66
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
77

88
// MCP Tool feature is disabled (coming soon) - skip all tests
9-
describe.skip('add mcp-tool command', () => {
9+
describe.skip('add gateway-target command', () => {
1010
let testDir: string;
1111
let projectDir: string;
1212
const agentName = 'TestAgent';
1313
const gatewayName = 'test-gateway'; // Used in skipped behind-gateway tests
1414

1515
beforeAll(async () => {
16-
testDir = join(tmpdir(), `agentcore-add-mcp-tool-${randomUUID()}`);
16+
testDir = join(tmpdir(), `agentcore-add-gateway-target-${randomUUID()}`);
1717
await mkdir(testDir, { recursive: true });
1818

1919
// Create project with agent
20-
const projectName = 'McpToolProj';
20+
const projectName = 'GatewayTargetProj';
2121
let result = await runCLI(['create', '--name', projectName, '--no-agent'], testDir);
2222
if (result.exitCode !== 0) {
2323
throw new Error(`Failed to create project: ${result.stdout} ${result.stderr}`);
@@ -54,15 +54,18 @@ describe.skip('add mcp-tool command', () => {
5454

5555
describe('validation', () => {
5656
it('requires name flag', async () => {
57-
const result = await runCLI(['add', 'mcp-tool', '--json'], projectDir);
57+
const result = await runCLI(['add', 'gateway-target', '--json'], projectDir);
5858
expect(result.exitCode).toBe(1);
5959
const json = JSON.parse(result.stdout);
6060
expect(json.success).toBe(false);
6161
expect(json.error.includes('--name'), `Error: ${json.error}`).toBeTruthy();
6262
});
6363

6464
it('requires exposure flag', async () => {
65-
const result = await runCLI(['add', 'mcp-tool', '--name', 'test', '--language', 'Python', '--json'], projectDir);
65+
const result = await runCLI(
66+
['add', 'gateway-target', '--name', 'test', '--language', 'Python', '--json'],
67+
projectDir
68+
);
6669
expect(result.exitCode).toBe(1);
6770
const json = JSON.parse(result.stdout);
6871
expect(json.success).toBe(false);
@@ -73,7 +76,7 @@ describe.skip('add mcp-tool command', () => {
7376
const result = await runCLI(
7477
[
7578
'add',
76-
'mcp-tool',
79+
'gateway-target',
7780
'--name',
7881
'test',
7982
'--language',
@@ -99,7 +102,7 @@ describe.skip('add mcp-tool command', () => {
99102
const result = await runCLI(
100103
[
101104
'add',
102-
'mcp-tool',
105+
'gateway-target',
103106
'--name',
104107
'container-tool',
105108
'--language',
@@ -130,7 +133,7 @@ describe.skip('add mcp-tool command', () => {
130133
const result = await runCLI(
131134
[
132135
'add',
133-
'mcp-tool',
136+
'gateway-target',
134137
'--name',
135138
toolName,
136139
'--language',
@@ -163,7 +166,7 @@ describe.skip('add mcp-tool command', () => {
163166

164167
it('requires agents for mcp-runtime', async () => {
165168
const result = await runCLI(
166-
['add', 'mcp-tool', '--name', 'no-agents', '--language', 'Python', '--exposure', 'mcp-runtime', '--json'],
169+
['add', 'gateway-target', '--name', 'no-agents', '--language', 'Python', '--exposure', 'mcp-runtime', '--json'],
167170
projectDir
168171
);
169172
expect(result.exitCode).toBe(1);
@@ -176,7 +179,7 @@ describe.skip('add mcp-tool command', () => {
176179
const result = await runCLI(
177180
[
178181
'add',
179-
'mcp-tool',
182+
'gateway-target',
180183
'--name',
181184
'runtime-container',
182185
'--language',
@@ -204,7 +207,7 @@ describe.skip('add mcp-tool command', () => {
204207
const result = await runCLI(
205208
[
206209
'add',
207-
'mcp-tool',
210+
'gateway-target',
208211
'--name',
209212
toolName,
210213
'--language',
@@ -236,7 +239,7 @@ describe.skip('add mcp-tool command', () => {
236239
const result = await runCLI(
237240
[
238241
'add',
239-
'mcp-tool',
242+
'gateway-target',
240243
'--name',
241244
'no-gw',
242245
'--language',
@@ -259,7 +262,7 @@ describe.skip('add mcp-tool command', () => {
259262
const result = await runCLI(
260263
[
261264
'add',
262-
'mcp-tool',
265+
'gateway-target',
263266
'--name',
264267
'no-host',
265268
'--language',
@@ -282,7 +285,7 @@ describe.skip('add mcp-tool command', () => {
282285
const result = await runCLI(
283286
[
284287
'add',
285-
'mcp-tool',
288+
'gateway-target',
286289
'--name',
287290
'gateway-container',
288291
'--language',

src/cli/commands/add/__tests__/validate.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import type {
22
AddAgentOptions,
33
AddGatewayOptions,
4+
AddGatewayTargetOptions,
45
AddIdentityOptions,
5-
AddMcpToolOptions,
66
AddMemoryOptions,
77
} from '../types.js';
88
import {
99
validateAddAgentOptions,
1010
validateAddGatewayOptions,
11+
validateAddGatewayTargetOptions,
1112
validateAddIdentityOptions,
12-
validateAddMcpToolOptions,
1313
validateAddMemoryOptions,
1414
} from '../validate.js';
1515
import { describe, expect, it } from 'vitest';
@@ -46,14 +46,14 @@ const validGatewayOptionsJwt: AddGatewayOptions = {
4646
allowedClients: 'client1,client2',
4747
};
4848

49-
const validMcpToolOptionsMcpRuntime: AddMcpToolOptions = {
49+
const validGatewayTargetOptionsMcpRuntime: AddGatewayTargetOptions = {
5050
name: 'test-tool',
5151
language: 'Python',
5252
exposure: 'mcp-runtime',
5353
agents: 'Agent1,Agent2',
5454
};
5555

56-
const validMcpToolOptionsBehindGateway: AddMcpToolOptions = {
56+
const validGatewayTargetOptionsBehindGateway: AddGatewayTargetOptions = {
5757
name: 'test-tool',
5858
language: 'Python',
5959
exposure: 'behind-gateway',
@@ -235,55 +235,55 @@ describe('validate', () => {
235235
});
236236
});
237237

238-
describe('validateAddMcpToolOptions', () => {
238+
describe('validateAddGatewayTargetOptions', () => {
239239
// AC15: Required fields validated
240240
it('returns error for missing required fields', () => {
241-
const requiredFields: { field: keyof AddMcpToolOptions; error: string }[] = [
241+
const requiredFields: { field: keyof AddGatewayTargetOptions; error: string }[] = [
242242
{ field: 'name', error: '--name is required' },
243243
{ field: 'language', error: '--language is required' },
244244
{ field: 'exposure', error: '--exposure is required' },
245245
];
246246

247247
for (const { field, error } of requiredFields) {
248-
const opts = { ...validMcpToolOptionsMcpRuntime, [field]: undefined };
249-
const result = validateAddMcpToolOptions(opts);
248+
const opts = { ...validGatewayTargetOptionsMcpRuntime, [field]: undefined };
249+
const result = validateAddGatewayTargetOptions(opts);
250250
expect(result.valid, `Should fail for missing ${String(field)}`).toBe(false);
251251
expect(result.error).toBe(error);
252252
}
253253
});
254254

255255
// AC16: Invalid values rejected
256256
it('returns error for invalid values', () => {
257-
let result = validateAddMcpToolOptions({ ...validMcpToolOptionsMcpRuntime, language: 'Java' as any });
257+
let result = validateAddGatewayTargetOptions({ ...validGatewayTargetOptionsMcpRuntime, language: 'Java' as any });
258258
expect(result.valid).toBe(false);
259259
expect(result.error?.includes('Invalid language')).toBeTruthy();
260260

261-
result = validateAddMcpToolOptions({ ...validMcpToolOptionsMcpRuntime, exposure: 'invalid' as any });
261+
result = validateAddGatewayTargetOptions({ ...validGatewayTargetOptionsMcpRuntime, exposure: 'invalid' as any });
262262
expect(result.valid).toBe(false);
263263
expect(result.error?.includes('Invalid exposure')).toBeTruthy();
264264
});
265265

266266
// AC17: mcp-runtime exposure requires agents
267267
it('returns error for mcp-runtime without agents', () => {
268-
let result = validateAddMcpToolOptions({ ...validMcpToolOptionsMcpRuntime, agents: undefined });
268+
let result = validateAddGatewayTargetOptions({ ...validGatewayTargetOptionsMcpRuntime, agents: undefined });
269269
expect(result.valid).toBe(false);
270270
expect(result.error).toBe('--agents is required for mcp-runtime exposure');
271271

272-
result = validateAddMcpToolOptions({ ...validMcpToolOptionsMcpRuntime, agents: ',,,' });
272+
result = validateAddGatewayTargetOptions({ ...validGatewayTargetOptionsMcpRuntime, agents: ',,,' });
273273
expect(result.valid).toBe(false);
274274
expect(result.error).toBe('At least one agent is required');
275275
});
276276

277277
// AC18: behind-gateway exposure is disabled (coming soon)
278278
it('returns coming soon error for behind-gateway exposure', () => {
279-
const result = validateAddMcpToolOptions({ ...validMcpToolOptionsBehindGateway });
279+
const result = validateAddGatewayTargetOptions({ ...validGatewayTargetOptionsBehindGateway });
280280
expect(result.valid).toBe(false);
281281
expect(result.error).toContain('coming soon');
282282
});
283283

284284
// AC19: Valid options pass
285285
it('passes for valid mcp-runtime options', () => {
286-
expect(validateAddMcpToolOptions(validMcpToolOptionsMcpRuntime)).toEqual({ valid: true });
286+
expect(validateAddGatewayTargetOptions(validGatewayTargetOptionsMcpRuntime)).toEqual({ valid: true });
287287
});
288288
});
289289

src/cli/commands/add/actions.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@ import { createGatewayFromWizard, createToolFromWizard } from '../../operations/
2727
import { createMemory } from '../../operations/memory/create-memory';
2828
import { createRenderer } from '../../templates';
2929
import type { MemoryOption } from '../../tui/screens/generate/types';
30-
import type { AddGatewayConfig, AddMcpToolConfig } from '../../tui/screens/mcp/types';
30+
import type { AddGatewayConfig, AddGatewayTargetConfig } from '../../tui/screens/mcp/types';
3131
import { DEFAULT_EVENT_EXPIRY } from '../../tui/screens/memory/types';
32-
import type { AddAgentResult, AddGatewayResult, AddIdentityResult, AddMcpToolResult, AddMemoryResult } from './types';
32+
import type {
33+
AddAgentResult,
34+
AddGatewayResult,
35+
AddGatewayTargetResult,
36+
AddIdentityResult,
37+
AddMemoryResult,
38+
} from './types';
3339
import { mkdirSync } from 'fs';
3440
import { dirname, join } from 'path';
3541

@@ -57,7 +63,7 @@ export interface ValidatedAddGatewayOptions {
5763
agents?: string;
5864
}
5965

60-
export interface ValidatedAddMcpToolOptions {
66+
export interface ValidatedAddGatewayTargetOptions {
6167
name: string;
6268
description?: string;
6369
language: 'Python' | 'TypeScript' | 'Other';
@@ -276,7 +282,7 @@ export async function handleAddGateway(options: ValidatedAddGatewayOptions): Pro
276282
}
277283

278284
// MCP Tool handler
279-
function buildMcpToolConfig(options: ValidatedAddMcpToolOptions): AddMcpToolConfig {
285+
function buildGatewayTargetConfig(options: ValidatedAddGatewayTargetOptions): AddGatewayTargetConfig {
280286
const sourcePath = `${APP_DIR}/${MCP_APP_SUBDIR}/${options.name}`;
281287

282288
const description = options.description ?? `Tool for ${options.name}`;
@@ -303,9 +309,11 @@ function buildMcpToolConfig(options: ValidatedAddMcpToolOptions): AddMcpToolConf
303309
};
304310
}
305311

306-
export async function handleAddMcpTool(options: ValidatedAddMcpToolOptions): Promise<AddMcpToolResult> {
312+
export async function handleAddGatewayTarget(
313+
options: ValidatedAddGatewayTargetOptions
314+
): Promise<AddGatewayTargetResult> {
307315
try {
308-
const config = buildMcpToolConfig(options);
316+
const config = buildGatewayTargetConfig(options);
309317
const result = await createToolFromWizard(config);
310318
return { success: true, toolName: result.toolName, sourcePath: result.projectPath };
311319
} catch (err) {

src/cli/commands/add/command.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
import { COMMAND_DESCRIPTIONS } from '../../tui/copy';
22
import { requireProject } from '../../tui/guards';
33
import { AddFlow } from '../../tui/screens/add/AddFlow';
4-
import { handleAddAgent, handleAddGateway, handleAddIdentity, handleAddMcpTool, handleAddMemory } from './actions';
4+
import {
5+
handleAddAgent,
6+
handleAddGateway,
7+
handleAddGatewayTarget,
8+
handleAddIdentity,
9+
handleAddMemory,
10+
} from './actions';
511
import type {
612
AddAgentOptions,
713
AddGatewayOptions,
14+
AddGatewayTargetOptions,
815
AddIdentityOptions,
9-
AddMcpToolOptions,
1016
AddMemoryOptions,
1117
} from './types';
1218
import {
1319
validateAddAgentOptions,
1420
validateAddGatewayOptions,
21+
validateAddGatewayTargetOptions,
1522
validateAddIdentityOptions,
16-
validateAddMcpToolOptions,
1723
validateAddMemoryOptions,
1824
} from './validate';
1925
import type { Command } from '@commander-js/extra-typings';
@@ -92,8 +98,8 @@ async function _handleAddGatewayCLI(options: AddGatewayOptions): Promise<void> {
9298
}
9399

94100
// MCP Tool disabled - prefix with underscore until feature is re-enabled
95-
async function _handleAddMcpToolCLI(options: AddMcpToolOptions): Promise<void> {
96-
const validation = validateAddMcpToolOptions(options);
101+
async function _handleAddGatewayTargetCLI(options: AddGatewayTargetOptions): Promise<void> {
102+
const validation = validateAddGatewayTargetOptions(options);
97103
if (!validation.valid) {
98104
if (options.json) {
99105
console.log(JSON.stringify({ success: false, error: validation.error }));
@@ -103,7 +109,7 @@ async function _handleAddMcpToolCLI(options: AddMcpToolOptions): Promise<void> {
103109
process.exit(1);
104110
}
105111

106-
const result = await handleAddMcpTool({
112+
const result = await handleAddGatewayTarget({
107113
name: options.name!,
108114
description: options.description,
109115
language: options.language! as 'Python' | 'TypeScript',
@@ -252,10 +258,10 @@ export function registerAdd(program: Command) {
252258
process.exit(1);
253259
});
254260

255-
// Subcommand: add mcp-tool (disabled - coming soon)
261+
// Subcommand: add gateway-target (disabled - coming soon)
256262
addCmd
257-
.command('mcp-tool', { hidden: true })
258-
.description('Add an MCP tool to the project')
263+
.command('gateway-target', { hidden: true })
264+
.description('Add a gateway target to the project')
259265
.option('--name <name>', 'Tool name')
260266
.option('--description <desc>', 'Tool description')
261267
.option('--language <lang>', 'Language: Python or TypeScript')

src/cli/commands/add/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export interface AddGatewayResult {
4242
}
4343

4444
// MCP Tool types
45-
export interface AddMcpToolOptions {
45+
export interface AddGatewayTargetOptions {
4646
name?: string;
4747
description?: string;
4848
language?: 'Python' | 'TypeScript' | 'Other';
@@ -53,7 +53,7 @@ export interface AddMcpToolOptions {
5353
json?: boolean;
5454
}
5555

56-
export interface AddMcpToolResult {
56+
export interface AddGatewayTargetResult {
5757
success: boolean;
5858
toolName?: string;
5959
sourcePath?: string;

src/cli/commands/add/validate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import {
1010
import type {
1111
AddAgentOptions,
1212
AddGatewayOptions,
13+
AddGatewayTargetOptions,
1314
AddIdentityOptions,
14-
AddMcpToolOptions,
1515
AddMemoryOptions,
1616
} from './types';
1717

@@ -154,7 +154,7 @@ export function validateAddGatewayOptions(options: AddGatewayOptions): Validatio
154154
}
155155

156156
// MCP Tool validation
157-
export function validateAddMcpToolOptions(options: AddMcpToolOptions): ValidationResult {
157+
export function validateAddGatewayTargetOptions(options: AddGatewayTargetOptions): ValidationResult {
158158
if (!options.name) {
159159
return { valid: false, error: '--name is required' };
160160
}

0 commit comments

Comments
 (0)