Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/mcp/tools/device/build_device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import * as z from 'zod';
import { XcodePlatform } from '../../../types/common.ts';
import { executeXcodeBuildCommand } from '../../../utils/build/index.ts';
import type { CommandExecutor } from '../../../utils/execution/index.ts';
import { getDefaultCommandExecutor } from '../../../utils/execution/index.ts';
Expand All @@ -19,12 +18,14 @@ import { nullifyEmptyStrings } from '../../../utils/schema-helpers.ts';
import { startBuildPipeline } from '../../../utils/xcodebuild-pipeline.ts';
import { finalizeInlineXcodebuild } from '../../../utils/xcodebuild-output.ts';
import { formatToolPreflight } from '../../../utils/build-preflight.ts';
import { mapDevicePlatform } from './build-settings.ts';

// Unified schema: XOR between projectPath and workspacePath
const baseSchemaObject = z.object({
projectPath: z.string().optional().describe('Path to the .xcodeproj file'),
workspacePath: z.string().optional().describe('Path to the .xcworkspace file'),
scheme: z.string().describe('The scheme to build'),
platform: z.enum(['iOS', 'watchOS', 'tvOS', 'visionOS']).optional().describe('default: iOS'),
configuration: z.string().optional().describe('Build configuration (Debug, Release)'),
derivedDataPath: z.string().optional(),
extraArgs: z.array(z.string()).optional(),
Expand All @@ -48,6 +49,7 @@ const publicSchemaObject = baseSchemaObject.omit({
projectPath: true,
workspacePath: true,
scheme: true,
platform: true,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The new platform parameter in build_device is omitted from the public schema, making it inaccessible to users in the default session-aware mode and preventing multi-platform builds.
Severity: HIGH

Suggested Fix

Remove the 'platform' key from the .omit() call on publicSchemaObject in build_device.ts. This will expose the parameter to users in the default mode. The same fix should be applied to get_device_app_path.ts.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/mcp/tools/device/build_device.ts#L52

Potential issue: The `platform` parameter, intended for multi-platform device builds, is
added to the `baseSchemaObject` but then explicitly removed from the
`publicSchemaObject` via `.omit()`. In the default session-aware mode, this public
schema is used for validation, which rejects or ignores the `platform` parameter. As a
result, `params.platform` is `undefined`, causing the build to default to iOS regardless
of user intent. This makes the new multi-platform build feature non-functional for users
in the default configuration. The same issue exists in `get_device_app_path`, breaking
the toolchain.

Also affects:

  • src/mcp/tools/device/get_device_app_path.ts:48-53

Did we get this right? 👍 / 👎 to inform future reviews.

configuration: true,
derivedDataPath: true,
preferXcodebuild: true,
Expand All @@ -62,14 +64,15 @@ export async function buildDeviceLogic(
executor: CommandExecutor,
): Promise<void> {
const ctx = getHandlerContext();
const platform = mapDevicePlatform(params.platform);
const processedParams = {
...params,
configuration: params.configuration ?? 'Debug',
};

const platformOptions = {
platform: XcodePlatform.iOS,
logPrefix: 'iOS Device Build',
platform,
logPrefix: `${platform} Device Build`,
};

const preflightText = formatToolPreflight({
Expand All @@ -78,15 +81,15 @@ export async function buildDeviceLogic(
workspacePath: params.workspacePath,
projectPath: params.projectPath,
configuration: processedParams.configuration,
platform: 'iOS',
platform: String(platform),
});

const pipelineParams = {
scheme: params.scheme,
workspacePath: params.workspacePath,
projectPath: params.projectPath,
configuration: processedParams.configuration,
platform: 'iOS',
platform: String(platform),
preflight: preflightText,
};

Expand Down Expand Up @@ -119,6 +122,7 @@ export async function buildDeviceLogic(
ctx.nextStepParams = {
get_device_app_path: {
scheme: params.scheme,
platform: String(platform),
},
};
}
Expand Down