-
Notifications
You must be signed in to change notification settings - Fork 139
refactor: move configuration to be passed #101
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 5 commits
ed59914
6775bfb
c32f842
7276731
4e8b791
e2393e8
dc7c637
0e4f5c7
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 | ||||
---|---|---|---|---|---|---|
@@ -1,22 +1,27 @@ | ||||||
import { NodeDriverServiceProvider } from "@mongosh/service-provider-node-driver"; | ||||||
import { ApiClient, ApiClientCredentials } from "./common/atlas/apiClient.js"; | ||||||
import config from "./config.js"; | ||||||
|
||||||
export interface SessionOptions { | ||||||
apiBaseUrl?: string; | ||||||
apiClientId?: string; | ||||||
apiClientSecret?: string; | ||||||
} | ||||||
|
||||||
export class Session { | ||||||
serviceProvider?: NodeDriverServiceProvider; | ||||||
apiClient: ApiClient; | ||||||
|
||||||
constructor() { | ||||||
constructor(options?: SessionOptions) { | ||||||
|
constructor(options?: SessionOptions) { | |
constructor(options: SessionOptions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(or setting a default)
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,3 @@ | ||||||
import packageJson from "../package.json" with { type: "json" }; | ||||||
|
||||||
export default packageJson.version; | ||||||
|
export default packageJson.version; | |
export const version = packageJson.version; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're using this in only one place we could do:
import { version } from "../package.json" with { type: "json" };
and not have this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's read in two places right now, renamed to packageInfo.ts
added another string in there, we can remove it later
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,11 +4,9 @@ import { Server } from "../../src/server.js"; | |||||
import runner, { MongoCluster } from "mongodb-runner"; | ||||||
import path from "path"; | ||||||
import fs from "fs/promises"; | ||||||
import { Session } from "../../src/session.js"; | ||||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; | ||||||
import { MongoClient, ObjectId } from "mongodb"; | ||||||
import { toIncludeAllMembers } from "jest-extended"; | ||||||
import config from "../../src/config.js"; | ||||||
import { config, UserConfig } from "../../src/config.js"; | ||||||
import { McpError } from "@modelcontextprotocol/sdk/types.js"; | ||||||
|
||||||
interface ParameterInfo { | ||||||
|
@@ -29,7 +27,7 @@ export interface IntegrationTest { | |||||
randomDbName: () => string; | ||||||
} | ||||||
|
||||||
export function setupIntegrationTest(): IntegrationTest { | ||||||
export function setupIntegrationTest(cfg: UserConfig = config): IntegrationTest { | ||||||
|
export function setupIntegrationTest(cfg: UserConfig = config): IntegrationTest { | |
export function setupIntegrationTest(userConfig: UserConfig = config): IntegrationTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's beneficial for example for us to create a test server here as opposed to expanding the config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drive-by: duplicated from atlasHelpers.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'd be better for the server to be passed in the MCP server + session as it was before, from dependency injection perspective. We might i.e. have other constructs that use the MCP server or the session, so we don't want it to be a derivative of the server (though one can also argue this class is like the main function).