Skip to content

feat(@angular/cli): support custom port in MCP devserver start tool#32855

Merged
alan-agius4 merged 1 commit intoangular:mainfrom
amishne:port
Mar 27, 2026
Merged

feat(@angular/cli): support custom port in MCP devserver start tool#32855
alan-agius4 merged 1 commit intoangular:mainfrom
amishne:port

Conversation

@amishne
Copy link
Contributor

@amishne amishne commented Mar 26, 2026

Agents tend to recreate the devserver frequently instead of keeping it alive, plus getting a random port each time can be annoying. This change slightly changes the descriptions, and adds an optional port parameter, to prevent these two problems.

This is a "feature" but a very small one, plus done to an experimental capability to start with, so patch is okay.

@amishne amishne requested a review from dgp1130 March 26, 2026 22:58
@amishne amishne added area: @angular/cli target: patch This PR is targeted for the next patch release labels Mar 26, 2026
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Mar 26, 2026
@amishne amishne marked this pull request as ready for review March 26, 2026 23:18
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ability to specify a port number for the development server and adds a utility to check port availability. The feedback identifies a potential race condition in the port check implementation where the promise resolves before the test server is fully closed, and points out an unused import in the test suite.

Copy link
Collaborator

@dgp1130 dgp1130 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +63 to +73
let port: number;
if (input.port) {
if (!(await context.host.isPortAvailable(input.port))) {
throw new Error(
`Port ${input.port} is unavailable. Try calling this tool again without the 'port' parameter to auto-assign a free port.`,
);
}
port = input.port;
} else {
port = await context.host.getAvailablePort();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Consider moving this into a function to reduce mutations.

const port = getPort(input, context);

fail('Should have thrown an error');
} catch (e) {
expect((e as Error).message).toContain(
"Port 55555 is unavailable. Try calling this tool again without the 'port' parameter to auto-assign a free port.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider: The agent can also just pick a different point. Maybe "Try using a different port or omitting the port parameter to auto-assign a free port."

@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Mar 27, 2026
@alan-agius4 alan-agius4 merged commit 87d99e9 into angular:main Mar 27, 2026
35 of 36 checks passed
@alan-agius4
Copy link
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

@alan-agius4 alan-agius4 added target: minor This PR is targeted for the next minor release target: patch This PR is targeted for the next patch release and removed target: patch This PR is targeted for the next patch release target: minor This PR is targeted for the next minor release labels Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/cli detected: feature PR contains a feature commit target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants