-
Notifications
You must be signed in to change notification settings - Fork 176
chore: support schema overrides and custom parserOptions MCP-338 #800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
4b8fe45
5ad2fa4
d90ea39
b9961ab
93ef973
666ab2b
3b4a437
6faa450
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,7 @@ import { | |
| Session, | ||
| UserConfig, | ||
| UserConfigSchema, | ||
| parseCliArgumentsAsUserConfig, | ||
| parseUserConfig, | ||
| StreamableHttpRunner, | ||
| StdioRunner, | ||
| TransportRunnerBase, | ||
|
|
@@ -811,26 +811,25 @@ const customConfig = UserConfigSchema.parse({ | |
|
|
||
| This approach ensures you get all the default values without having to specify every configuration key manually. | ||
|
|
||
| ### parseCliArgumentsAsUserConfig | ||
| ### parseUserConfig | ||
|
|
||
| Utility function to parse command-line arguments and environment variables into a UserConfig object, using the same parsing logic as the MongoDB MCP server CLI. | ||
|
|
||
| _Note: This is what MongoDB MCP server uses internally._ | ||
|
|
||
| ```typescript | ||
| function parseCliArgumentsAsUserConfig(options?: { | ||
| function parseUserConfig(options?: { | ||
| args?: string[]; | ||
| helpers?: CreateUserConfigHelpers; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the concept of CreateUserConfigHelpers was unused. |
||
| }): UserConfig; | ||
| ``` | ||
|
|
||
| **Example:** | ||
|
|
||
| ```typescript | ||
| import { parseCliArgumentsAsUserConfig, StdioRunner } from "mongodb-mcp-server"; | ||
| import { parseUserConfig, StdioRunner } from "mongodb-mcp-server"; | ||
|
|
||
| // Parse config from process.argv and environment variables | ||
| const config = parseCliArgumentsAsUserConfig(); | ||
| const config = parseUserConfig(); | ||
gagik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const runner = new StdioRunner({ userConfig: config }); | ||
| await runner.start(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| 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"; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
It is technically a library breaking change though.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
| export { parseUserConfig, defaultParserOptions, type ParserOptions } from "./common/config/parseUserConfig.js"; | ||
| export { LoggerBase, type LogPayload, type LoggerType, type LogLevel } from "./common/logger.js"; | ||
| export { StreamableHttpRunner } from "./transports/streamableHttp.js"; | ||
| export { StdioRunner } from "./transports/stdio.js"; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.