Skip to content

feat: adds an export tool and exported-data resource MCP-16 #424

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

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a988af5
feat: adds a session bound export manager
himanshusinghs Aug 5, 2025
dbf8ccf
feat: adds an export tool
himanshusinghs Aug 5, 2025
3e8288e
chore: register export tool with server
himanshusinghs Aug 5, 2025
b815a6f
feat: adds exported-data resource
himanshusinghs Aug 5, 2025
34c31fd
chore: tests for export tool
himanshusinghs Aug 5, 2025
f3606c6
chore: tests for exported-data resource
himanshusinghs Aug 5, 2025
75ab89d
chore: server should advertise listChanged capability
himanshusinghs Aug 5, 2025
a38a45f
chore: test for autocomplete API
himanshusinghs Aug 5, 2025
7a83e8f
chore: fix broken test
himanshusinghs Aug 5, 2025
2aacd85
chore: handle pipeline failures explicitly
himanshusinghs Aug 6, 2025
90fbbd3
chore: handle possible path traversals
himanshusinghs Aug 6, 2025
7ba831f
chore: add accuracy test for export tool
himanshusinghs Aug 6, 2025
6cc5f8f
chore: increase timeout to allow file to expire
himanshusinghs Aug 6, 2025
0c82b2d
chore: increase the cleanupInterval to test expired resource
himanshusinghs Aug 6, 2025
2ac355b
chore: adds a header row for baseline info markdown
himanshusinghs Aug 6, 2025
953751c
chore: sessionId is initialized on Session instantiation
himanshusinghs Aug 6, 2025
ca4c4a5
chore: emit export related events on ExportsManager instance
himanshusinghs Aug 6, 2025
030d81a
chore: SessionExportManager moved to Session instance
himanshusinghs Aug 6, 2025
c8dcf45
chore: handle exports management in memory
himanshusinghs Aug 7, 2025
6d2a364
chore: move proper-lockfile back to dev
himanshusinghs Aug 7, 2025
6d7efe6
chore: adapt logger changes
himanshusinghs Aug 7, 2025
d009b3c
chore: remove indents from exported json
himanshusinghs Aug 7, 2025
4992fa6
chore: PR feedback
himanshusinghs Aug 7, 2025
2762891
chore: limit the exposed property of an export
himanshusinghs Aug 7, 2025
9f0d641
feat: makes export tool async
himanshusinghs Aug 7, 2025
bfa1dee
chore: more reliable SessionExportManager tests
himanshusinghs Aug 7, 2025
af947d5
chore: more reliable export tool and exported-data resource tests
himanshusinghs Aug 7, 2025
816fb0c
chore: model Resources the same way as Tools
himanshusinghs Aug 7, 2025
e0cc924
chore: implements PR feedback
himanshusinghs Aug 7, 2025
397e460
chore rename SessionExportsManager to ExportsManager
himanshusinghs Aug 7, 2025
04cb6e7
chore: remove validation from readExport but keep decodeURIComponent
himanshusinghs Aug 7, 2025
1df2690
chore: publish resource updated notification only when there are subs…
himanshusinghs Aug 7, 2025
d3d81d6
chore: remove sideeffect from ctor
himanshusinghs Aug 8, 2025
2b2d615
chore: small improvements
himanshusinghs Aug 8, 2025
9998d8e
chore: extra guard to avoid having same name export
himanshusinghs Aug 8, 2025
4fb1bbd
chore: when closing ExportsManager should not accept any more requests
himanshusinghs Aug 8, 2025
50f9122
chore: more tests for exportsManager
himanshusinghs Aug 8, 2025
c1d0117
chore: detect local run use-case better
himanshusinghs Aug 8, 2025
5bcac97
chore: ask for export description in the tool itself
himanshusinghs Aug 8, 2025
5d7657e
chore: also apply exportTitle to tests
himanshusinghs Aug 8, 2025
2136a88
chore: move event subs to register in ExportedData resource
himanshusinghs Aug 8, 2025
701003f
chore: remove wasInitialized
himanshusinghs Aug 8, 2025
a3df32c
chore: disconnect sessionId and ExportsManager unique path id
himanshusinghs Aug 8, 2025
85cb524
chore: track long running ops and abort them on close
himanshusinghs Aug 8, 2025
c0031ff
chore: implement read write lock
himanshusinghs Aug 8, 2025
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
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"@mongodb-js/devtools-proxy-support": "^0.5.1",
"@mongosh/service-provider-node-driver": "^3.10.2",
"@vitest/eslint-plugin": "^1.3.4",
"async-rwlock": "^1.1.1",
"bson": "^6.10.4",
"express": "^5.1.0",
"lru-cache": "^11.1.0",
Expand Down
1 change: 1 addition & 0 deletions scripts/accuracy/generateTestSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ function generateMarkdownBrief(
markdownTexts.push(
...[
"## 📊 Baseline Comparison",
"| Metric | Value |",
"|--------|-------|",
`| **Baseline Commit** | \`${baselineInfo.commitSHA}\` |`,
`| **Baseline Run ID** | \`${baselineInfo.accuracyRunId}\` |`,
Expand Down
24 changes: 17 additions & 7 deletions src/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export interface UserConfig {
apiClientSecret?: string;
telemetry: "enabled" | "disabled";
logPath: string;
exportsPath: string;
exportTimeoutMs: number;
exportCleanupIntervalMs: number;
connectionString?: string;
connectOptions: ConnectOptions;
disabledTools: Array<string>;
Expand All @@ -35,6 +38,9 @@ export interface UserConfig {
const defaults: UserConfig = {
apiBaseUrl: "https://cloud.mongodb.com/",
logPath: getLogPath(),
exportsPath: getExportsPath(),
exportTimeoutMs: 300000, // 5 minutes
exportCleanupIntervalMs: 120000, // 2 minutes
connectOptions: {
readConcern: "local",
readPreference: "secondaryPreferred",
Expand All @@ -59,17 +65,21 @@ export const config = {
...getCliConfig(),
};

function getLogPath(): string {
const localDataPath =
process.platform === "win32"
? path.join(process.env.LOCALAPPDATA || process.env.APPDATA || os.homedir(), "mongodb")
: path.join(os.homedir(), ".mongodb");

const logPath = path.join(localDataPath, "mongodb-mcp", ".app-logs");
function getLocalDataPath(): string {
return process.platform === "win32"
? path.join(process.env.LOCALAPPDATA || process.env.APPDATA || os.homedir(), "mongodb")
: path.join(os.homedir(), ".mongodb");
}

function getLogPath(): string {
const logPath = path.join(getLocalDataPath(), "mongodb-mcp", ".app-logs");
return logPath;
}

function getExportsPath(): string {
return path.join(getLocalDataPath(), "mongodb-mcp", "exports");
}

// Gets the config supplied by the user as environment variables. The variable names
// are prefixed with `MDB_MCP_` and the keys match the UserConfig keys, but are converted
// to SNAKE_UPPER_CASE.
Expand Down
Loading
Loading