Skip to content

Conversation

@gagik
Copy link
Collaborator

@gagik gagik commented Dec 15, 2025

This allows for more flexibility when parsing, including specifying custom defaults, environment prefixes, etc..

@gagik gagik requested a review from a team as a code owner December 15, 2025 09:48
Copilot AI review requested due to automatic review settings December 15, 2025 09:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR renames createUserConfig to parseUserConfig and adds support for schema overrides and custom parser options. The changes enable more flexible configuration parsing, including custom environment variable prefixes and default value overrides.

Key changes:

  • Renamed createUserConfig to parseUserConfig throughout the codebase
  • Added support for schema overrides through a new overrides parameter
  • Exposed ParserOptions type and defaultParserOptions for customization
  • Updated public API exports to reflect the new naming

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/common/config/createUserConfig.ts Renamed to parseUserConfig.ts; added overrides and parserOptions parameters to support custom schemas and parser configuration
tests/unit/common/config.test.ts Updated all test calls from createUserConfig to parseUserConfig; added tests for schema overrides and custom environment prefixes
src/lib.ts Updated exports to expose parseUserConfig, defaultParserOptions, and ParserOptions type instead of parseCliArgumentsAsUserConfig
src/index.ts Updated import to use parseUserConfig instead of createUserConfig
src/transports/base.ts Updated documentation comments to reference parseUserConfig instead of createUserConfig
eslint-rules/enforce-zod-v4.js Updated allowed file path from createUserConfig.ts to parseUserConfig.ts
MCP_SERVER_LIBRARY.md Updated documentation to reflect parseUserConfig naming and simplified function signature

export { Server, type ServerOptions } from "./server.js";
export { Session, type SessionOptions } from "./common/session.js";
export { type UserConfig, UserConfigSchema } from "./common/config/userConfig.js";
export { createUserConfig as parseCliArgumentsAsUserConfig } from "./common/config/createUserConfig.js";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

so I unfortunately missed that we're doing this; it's weird to have this discrepancy where our external export is named differently than our internal one. To me the idea that the name isn't straightforward was a code smell.

parseCliArgumentsAsUserConfig is inherently misleading though since by default it also parses environment variables. This can mislead users so it's best to rename it.

It is technically a library breaking change though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then we anticipate the release with this work will bump major version, correct?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Technically, yes, though to avoid a major version bump, let's re-export with the old name and mark as deprecated?

@coveralls
Copy link
Collaborator

coveralls commented Dec 15, 2025

Pull Request Test Coverage Report for Build 20275512293

Details

  • 38 of 45 (84.44%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.002%) to 80.087%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/index.ts 0 2 0.0%
src/lib.ts 3 8 37.5%
Totals Coverage Status
Change from base Build 20169939886: -0.002%
Covered Lines: 6683
Relevant Lines: 8262

💛 - Coveralls

```typescript
function parseCliArgumentsAsUserConfig(options?: {
args?: string[];
helpers?: CreateUserConfigHelpers;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the concept of CreateUserConfigHelpers was unused.

Copy link
Collaborator

@cveticm cveticm left a comment

Choose a reason for hiding this comment

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

LGTM + non-blocking questions for my own understanding

error: string | undefined;
} {
const { error: parseError, warnings, parsed } = parseUserConfigSources(args);
const schema = overrides
Copy link
Collaborator

Choose a reason for hiding this comment

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

Non-blocking q: Which takes precedent: env vars or overrides?
I suspect env vars are applied to the UserConfiSchema before we get to this point and so overrides take precedent.

Copy link
Collaborator Author

@gagik gagik Dec 16, 2025

Choose a reason for hiding this comment

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

generally overrides are applied to the schema and in practice likely only going to be used to modify the default, i.e.

{
    readOnly: UserConfigSchema.shape.readOnly.default(true)
}

so any value (CLI, ENV) will override the default.

I will add some documentation to make it clearer

@gagik gagik merged commit adfe4b5 into main Dec 16, 2025
18 checks passed
@gagik gagik deleted the gagik/custom-defaults branch December 16, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants